@Test
public void testWrite() throws Exception {

	assertTestingInputStream(this.list);
	
	File tmpFile = File.createTempFile("dbfwriter", ".dbf");  //$NON-NLS-1$//$NON-NLS-2$
	tmpFile.deleteOnExit();
	
	try {
		// Write the file
		DBaseFileWriter writer = new DBaseFileWriter(tmpFile);
		writer.write(ArrayUtil.toArray(this.list, AttributeProvider.class));
		writer.close();
		
		// Read the content of the just written file
		List<AttributeProvider>  newContent = readFile(new FileInputStream(tmpFile));
		
		// Compare the two lists of attributes
		boolean found;
		for(AttributeProvider provider : this.list) {
			// Search for the provider
			found = false;
			for(AttributeProvider provider2 : newContent) {
				if (sameProvider(provider,provider2)) {
					newContent.remove(provider2);
					found = true;
					break;
				}
			}
			if (!found)
				fail("some data was not correctly written"); //$NON-NLS-1$
		}
		
		if (!newContent.isEmpty())
			fail("the written content has more data than the source"); //$NON-NLS-1$
	}
	finally {
		tmpFile.delete();
	}
}