I would like to start using unit tests, but it's hard for me to understand how I can use them in my current project.
My current project is an application that collects files into a "Directory". A Catalogcan then extract information from files that it contains, such as thumbnails and other properties. Users can also tag files with other custom metadata, such as Author and Notes. It can be easily compared to a photo album application such as Picasa or Adobe Lightroom.
I separated the code to create and process Catalogin a separate DLL, which I now want to test. However, most of my classes should never be created on their own. Instead, everything happens through my class Catalog. For example, I can not check my class Filemyself, because it Fileis available only through Catalog.
As an alternative to unit testing, I believe that it would be more appropriate for me to write a test program that starts a series of actions, including creating a directory, reopening the created directory and managing the contents of the directory. See code below.
string testCatalogALocation = "C:\TestCatalogA"
string testCatalogBLocation = "C:\TestCatalogB"
string testFileLocation = "C:\testfile.jpg"
string testFileName = System.IO.Path.GetFileName(testFileLocation);
Catalog catAtemp = Catalog(testCatalogALocation)
Catalog catBtemp = Catalog(testCatalogBLocation );
Catalog catA = Catalog.OpenCatalog(testCatalogALocation);
Catalog catB = Catalog.OpenCatalog(testCatalogBLocation );
using(FileStream fs = new FileStream(testFileLocation )
{
catA.ImportFile(testFileName,fs);
}
File testFile = catA.GetFile(System.IO.Path.GetFileName(testFileLocation));
catB.CopyFileTo(testFile);
System.IO.Directory.Delete(testCatalogALocation);
System.IO.Directory.Delete(testCatalogBLocation);
-, - ? unit test ? -, , , , Visual Studio? " " VS2010 ?
. . , . , . .
. , , "" . , IFile, . , ICatalog, , .
, ICatalog, . - , /.