public void DBContainsRestaurantShouldReturnFalseIfRestaurantIdNotInDB(string Id, bool useAsync) { //Arrange var options = new DbContextOptionsBuilder <Project2DBContext>() .UseInMemoryDatabase(databaseName: "StaticFilledRestaurantDB") .Options; bool result; RestaurantRepo rRepo; //Act using (var context = new Project2DBContext(options)) { rRepo = new RestaurantRepo(context); if (useAsync) { result = rRepo.DBContainsRestaurantAsync(Id).Result; } else { result = rRepo.DBContainsRestaurant(Id); } } //Assert Assert.False(result); }
public void DBContainsRestaurantShouldReturnFalseIfIfDBIsEmpty(string Id, bool useAsync) { //Arrange var options = new DbContextOptionsBuilder <Project2DBContext>() .UseInMemoryDatabase(databaseName: "EmptyDB3") .Options; bool result; RestaurantRepo rRepo; //Act using (var context = new Project2DBContext(options)) { rRepo = new RestaurantRepo(context); if (useAsync) { result = rRepo.DBContainsRestaurantAsync(Id).Result; } else { result = rRepo.DBContainsRestaurant(Id); } } //If exception is throw, test will exit before reaching Assert //Assert Assert.False(result); }