Beispiel #1
0
 public void DeleteRestaurant()
 {
     try
     {
         // Arrange
         var restaurantRepository = new RestaurantRepository(RestaurantReviewsContext);
         var newRestaurant        = new Restaurant
         {
             Address      = "10 Leninskiy Rayon",
             City         = "Novosibirsk",
             Country      = "Russian Federation",
             EmailAddress = "*****@*****.**",
             IsConfirmed  = true,
             Name         = "Novosibirsk Eats 3",
             Phone        = "+7 961 222-87-45",
             PostalCode   = "630001",
             State        = "Siberia",
             WebsiteUrl   = "www.novosibirskeats.com"
         };
         restaurantRepository.CreateRestaurant(newRestaurant).Wait();
         var savedRestaurant = restaurantRepository.GetRestaurantById(newRestaurant.Id).Result;
         Assert.IsNotNull(savedRestaurant, string.Format("Restaurant {0} was not saved in the database", newRestaurant.Id));
         Assert.IsTrue(savedRestaurant.Name == newRestaurant.Name, string.Format("Restaurant({0}).Name was not saved in the database", newRestaurant.Id));
         // Act
         restaurantRepository.DeleteRestaurant(savedRestaurant).Wait();
         // Assert
         var shouldBeDeletedRestaurant = restaurantRepository.GetRestaurantById(newRestaurant.Id).Result;
         Assert.IsTrue(shouldBeDeletedRestaurant.IsEmptyObject(), string.Format("Restaurant({0}) was not deleted from the database", newRestaurant.Id));
     }
     catch (Exception ex)
     {
         Assert.Fail(string.Format("An unexpected exception occurred in DeleteRestaurant {0}", ex.Message));
     }
 }