public async void should_return_400BadRequest_from_middleware_if_restaurant_notfound() { var keyword = "hello"; var type = PlaceType.RESTAURANT.GetDescription(); // Arrange //setup DI //mockService.Setup(repo => repo.ListAsync(keyword)).ReturnsAsync(new List<Restaurant>()); // Act var result = await ControllerUnderTest.CacheRestaurantAsync(keyword); // Assert var badRequest = Assert.IsType <BadRequestResult>(result); //var exception = Assert.IsType<ErrorDetails>(); //Assert.Same(expectedRestaurants, restaurants); }
public async void should_return_OkObjectResult_with_restaurants_with_out_cahce() { var keyword = "hello"; var type = PlaceType.RESTAURANT.GetDescription(); // Arrange //should serialize from JSON var serviceResult = new List <Restaurant> { new Restaurant() { Id = "b1357cd1-2901-3e8c-9852-1e659bceae98", Name = "JK. Rowling", Rating = 4 }, new Restaurant() { Id = "a1357cd1-2901-3e8c-9852-1e659bceae51", Name = "Microsoft", Rating = 5 } }; //setup DI mockService.Setup(repo => repo.ListAsync(keyword)).ReturnsAsync(serviceResult); // Act var result = await ControllerUnderTest.CacheRestaurantAsync(keyword); // Assert var okResult = Assert.IsType <OkObjectResult>(result); var restaurants = Assert.IsType <List <Restaurant> >(okResult.Value); //Log.Information(okResult.Value.GetType().ToString()); Assert.Equal(serviceResult.FirstOrDefault().Id, expectedRestaurants.FirstOrDefault().Id); Assert.Equal(serviceResult.Last().Id, expectedRestaurants.Last().Id); }