示例#1
0
        public void TestSearch_EmptyString_ReturnEmptyList()
        {
            //Arrange:
            FileSearcher fileSearcher = new FileSearcher("NoSuchFile");

            //Act:
            List<int> result = fileSearcher.Search("");

            //Assert:
            Assert.AreEqual(result.Count, 0);
        }
示例#2
0
        public void TestInit_NoSuchFile_ReturnFalse()
        {
            //Arrange:
            FileSearcher fileSearcher = new FileSearcher("NoSuchFile");

            //Act:
            bool result = fileSearcher.Init();

            //Assert:
            Assert.IsFalse(result);
            Assert.AreEqual(fileSearcher.ErrorMessage, "File cannot be opened");
        }
示例#3
0
        public void TestSearch_MultipleNameOccurances_ReturnListWithThreeId()
        {
            //Arrange:
            string filePath = @"..\..\SearchInFile.csv";
            FileSearcher fileSearcher = new FileSearcher(filePath);
            bool initResult = fileSearcher.Init();

            //Act:
            List<int> result = fileSearcher.Search("Jane Cockrum");

            //Assert:
            Assert.AreEqual(result.Count, 4);
        }
示例#4
0
        public void TestInit_FileExits_ReturnTrue()
        {
            //Arrange:
            string filePath = @"..\..\EmptyFile.csv";
            FileSearcher fileSearcher = new FileSearcher(filePath);

            //Act:
            bool result = fileSearcher.Init();

            //Assert:
            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(fileSearcher.ErrorMessage));
        }
示例#5
0
        public void TestSearch_NoSuchEmail_ReturnEmptyList()
        {
            //Arrange:
            string filePath = @"..\..\EmptyFile.csv";
            FileSearcher fileSearcher = new FileSearcher(filePath);
            bool initResult = fileSearcher.Init();

            //Act:
            List<int> result = fileSearcher.Search("*****@*****.**");

            //Assert:
            Assert.AreEqual(result.Count, 0);
        }
示例#6
0
        public void TestSearch_SingleNameOccurance_ReturnListWithOneId()
        {
            //Arrange:
            string filePath = @"..\..\SearchInFile.csv";
            FileSearcher fileSearcher = new FileSearcher(filePath);
            bool initResult = fileSearcher.Init();

            //Act:
            List<int> result = fileSearcher.Search("Denis Dentler");

            //Assert:
            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result[0], 25);
        }