public void Can_Get_Restaurant_By_ExternalId() { var context = TestingSetup.GetContext(); var restaurant = new Restaurant() { ExternalId = "31e045af-cc46-4e28-a783-71d456d86400", Name = "New Restaurant" }; context.Restaurants.Add(restaurant); context.SaveChanges(); var controller = new RestaurantController( new RestaurantService( new RestaurantRepository(context))); var task = controller.GetRestaurantByExternalId("31e045af-cc46-4e28-a783-71d456d86400") .ContinueWith(innerTask => { var result = innerTask.Result; Assert.IsType <RestaurantDTO>(result); Assert.Equal("31e045af-cc46-4e28-a783-71d456d86400", result.ExternalId); }); }
public void Can_Get_RestaurantDTO() { var context = TestingSetup.GetContext(); IRestaurantRepository repo = new RestaurantRepository(context); var restaurant = new Restaurant() { ExternalId = "31e045af-cc46-4e28-a783-71d456d86400", Name = "New Restaurant" }; context.Restaurants.Add(restaurant); context.SaveChanges(); var svc = new RestaurantService(repo); Task task = svc.GetRestaurantByIdAsync("31e045af-cc46-4e28-a783-71d456d86400") .ContinueWith(innerTask => { var result = innerTask.Result; Assert.IsType <RestaurantDTO>(result); Assert.Equal("America/New York", result.TimeZone); Assert.Equal("New Restaurant", result.Name); }); }
public void Can_Get_Default_Restaurant_DTO() { var context = TestingSetup.GetContext(); var controller = new RestaurantController( new RestaurantService( new RestaurantRepository(context))); dynamic result = (JsonResult)controller.Default(); Assert.Equal(90, result.Value.MinutesInAdvanceAllowDelivery); }
public void Svc_Can_Save_CreateRestaurantDTO() { var restaurant = new CreateRestaurantDTO(); var context = TestingSetup.GetContext(); var svc = new RestaurantService(new RestaurantRepository(context)); Task task = svc.SaveRestaurantAsync(restaurant) .ContinueWith(innerTask => { var result = innerTask.Result; Assert.Equal("America/New York", result.TimeZone); }); Assert.Single(context.Restaurants); }
public void Can_Save_Restaurant() { var context = TestingSetup.GetContext(); var repo = new RestaurantRepository(context); var restaurant = new Restaurant(); Task task = repo.SaveAsync(restaurant) .ContinueWith(innerTask => { var result = innerTask.Result; Assert.IsType <Restaurant>(result); }); Assert.Single(context.Restaurants); }
public void Post_New_Restuarant() { var context = TestingSetup.GetContext(); var controller = new RestaurantController( new RestaurantService( new RestaurantRepository(context))); var restaurant = new CreateRestaurantDTO(); restaurant.Name = "Mike's Diner"; var task = controller.CreateRestaurant(restaurant) .ContinueWith(innterTask => { var result = innterTask.Result; Assert.IsType <RestaurantDTO>(result); Assert.Equal("Mike's Diner", result.Name); }); }
public void Can_Get_Restuarant_By_ExternalId() { var context = TestingSetup.GetContext(); var repo = new RestaurantRepository(context); var restaurant = new Restaurant() { Name = "New Restaurant" }; context.Restaurants.Add(restaurant); context.SaveChanges(); var existingRestaurant = context.Restaurants.First(); Task task = repo.GetRestaruantByExternalIdAsync(existingRestaurant.ExternalId) .ContinueWith(innerTask => { var result = innerTask.Result; Assert.Equal("New Restaurant", result.Name); }); }