public void DBContainsKeywordShouldReturnFalseIfKeywordNotInDB(string kw, bool useAsync) { //Arrange var options = new DbContextOptionsBuilder <Project2DBContext>() .UseInMemoryDatabase(databaseName: "StaticFilledKeywordDB") .Options; bool result; KeywordRepo kRepo; //Act using (var context = new Project2DBContext(options)) { kRepo = new KeywordRepo(context); if (useAsync) { result = kRepo.DBContainsKeywordAsync(kw).Result; } else { result = kRepo.DBContainsKeyword(kw); } } //Assert Assert.False(result); }
public void DBContainsKeywordShouldReturnFalseIfIfDBIsEmpty(string kw, bool useAsync) { //Arrange var options = new DbContextOptionsBuilder <Project2DBContext>() .UseInMemoryDatabase(databaseName: "EmptyKeywordDB3") .Options; bool result; KeywordRepo kRepo; //Act using (var context = new Project2DBContext(options)) { kRepo = new KeywordRepo(context); if (useAsync) { result = kRepo.DBContainsKeywordAsync(kw).Result; } else { result = kRepo.DBContainsKeyword(kw); } } //If exception is throw, test will exit before reaching Assert //Assert Assert.False(result); }