public void TestSearch_EmptyString_ReturnEmptyList() { //Arrange: FileSearcher fileSearcher = new FileSearcher("NoSuchFile"); //Act: List<int> result = fileSearcher.Search(""); //Assert: Assert.AreEqual(result.Count, 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"); }
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); }
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)); }
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); }
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); }