public void TestSortFile() { //unittest will construct the input file , then test the file //string sFilePath = "c:\\names.txt"; string sWorkingPath = System.Environment.CurrentDirectory; string sFilePath = sWorkingPath + "\\names.txt"; if (!File.Exists(sFilePath)) { ConstructInputFile(sFilePath); } Assert.IsTrue(File.Exists(sFilePath)); //Manual Dependency Injection IContentReader provider = new CSVTextReader(); string sFilepath = sFilePath; DataSortingConsumer consumer = new DataSortingConsumer(provider) { path = sFilepath }; consumer.Process(); //verification on the order of names List<Person> listPersons = consumer.GetSorted(); String prev = null; foreach (Person person in listPersons) { if(prev != null) { //assert it is going ascending Assert.IsTrue(person.ToString().CompareTo(prev) >= 0); } prev = person.ToString(); } }
static public void ProcessNames(string sFilePath) { IKernel kernel = new StandardKernel(); kernel.Load(Assembly.GetExecutingAssembly()); IContentReader provider = kernel.Get<IContentReader>(); string sFilepath = sFilePath; DataConsumer consumer = new DataSortingConsumer(provider) { path = sFilepath }; consumer.Process(); }
static public void ProcessNames(string sFilePath) { IKernel kernel = new StandardKernel(); kernel.Load(Assembly.GetExecutingAssembly()); IContentReader provider = kernel.Get <IContentReader>(); string sFilepath = sFilePath; DataConsumer consumer = new DataSortingConsumer(provider) { path = sFilepath }; consumer.Process(); }