public void BadFilename__Exception() { // arrange var service = new FullnameCollectionService(); // act var collection = service.LoadFromFile("BadFileName.bad"); // assert // Exception should be thrown }
public void Null__Exception() { // arrange var service = new FullnameCollectionService(); // act var collection = service.LoadFromFile(null); // assert // Exception should be thrown }
public void LastEntry__OK() { // arrange var service = new FullnameCollectionService(); var collection = service.LoadFromFile(TestFilepath); // act collection = service.SortByLastnameGivenname(collection); // assert // make sure first entry is "zulu zulu zulu zulu" string bottomEntry = collection.Last().ToString(); Assert.IsTrue(bottomEntry == HIGHEST); }
public void FirstEntry__OK() { // arrange var service = new FullnameCollectionService(); var collection = service.LoadFromFile(TestFilepath); // act collection = service.SortByLastnameGivenname(collection); // assert // make sure first entry is "alpha alpha alpha alpha" string topEntry = collection.First().ToString(); Assert.IsTrue(topEntry == LOWEST); }
public void WriteToFile__OK() { // arrange var service = new FullnameCollectionService(); var collection = service.LoadFromFile(TestInputFilepath); if (new System.IO.FileInfo(TestOutputFilepath).Exists) { System.IO.File.Delete(TestOutputFilepath); } // act service.WriteToFile(collection, TestOutputFilepath); // assert // make sure first entry is "alpha alpha alpha alpha" // test out was created Assert.IsTrue(new System.IO.FileInfo(TestOutputFilepath).Exists); // test it has content. Assert.IsTrue(new System.IO.FileInfo(TestOutputFilepath).Length > 30); }
/// <summary> /// Reads a file containing names (one name per line) Sorts them and outputs to new file and to the console. /// </summary> /// <param name="args">args[0] should be the name of the file to read</param> /// <returns></returns> static int Main(string[] args) { if (args.Length != 1 || args[0] == "/?" || args[0].Length == 0) { Usage(); return(-2); } var inputFilepath = args[0]; // var service = new FullnameCollectionService(); // Load the data var allNames = service.LoadFromFile(args[0]); // sort the data allNames = service.SortByLastnameGivenname(allNames); // output the data service.WriteToStream(allNames, Console.Out); service.WriteToFile(allNames, OutputPath); return(0); }