コード例 #1
0
        public void TestSortByLastName()
        {
            //Arrange
            string savedFolder                   = "../../../SortingNames/App_Data";
            string unsortedFileName              = "sample-for-unit-test.txt";
            string sortedFileName                = "sorted-names-list.txt";
            string fullPath                      = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, savedFolder, unsortedFileName);
            SortingNameRepository sortingNames   = new SortingNameRepository();
            List <string>         expectedResult = new List <string>();

            expectedResult.Add("Hailey Avie Annakin");
            expectedResult.Add("Erna Dorey Battelle");
            expectedResult.Add("Selle Bellison");
            expectedResult.Add("Flori Chaunce Franzel");
            expectedResult.Add("Orson Milka Iddins");
            expectedResult.Add("Odetta Sue Kaspar");
            expectedResult.Add("Roy Ketti Kopfen");
            expectedResult.Add("Madel Bordie Mapplebeck");
            expectedResult.Add("Debra Micheli");
            expectedResult.Add("Leonerd Adda Mitchell Monaghan");

            //Act
            IEnumerable <PersonModel> model = sortingNames.SortNames(fullPath, savedFolder, sortedFileName);

            IEnumerable <string> fullNames = from p in model
                                             select p.FullName;

            List <string> actualResult = fullNames.ToList();

            //Assert
            CollectionAssert.AreEqual(expectedResult, actualResult);
        }
コード例 #2
0
        public ActionResult SortPerson(string fullPath)
        {
            SortingNameRepository sortingNames = new SortingNameRepository();
            string savedFolder = ConfigurationManager.AppSettings["FilePath"];
            string fileName    = ConfigurationManager.AppSettings["FileName"];

            var model = sortingNames.SortNames(fullPath, savedFolder, fileName);

            return(View("Index", model));
        }