コード例 #1
0
        public async Task GetRecipeIngredients_NotFound2()
        {
            RecipeRepository recipe = new RecipeRepository(_options, new HttpClient(), _cacheServiceMock.Object);

            var controller = new RecipesController(recipe, _mapper, _logger);
            var result     = await controller.GetRecipeIngredients(0);

            result.Should().NotBeNull();
            var notFoundResult = result.Should().BeOfType <NotFoundResult>().Subject;

            Assert.True(notFoundResult.StatusCode.Equals(404));
        }
コード例 #2
0
        public async Task GetRecipeIngredients_OkResult()
        {
            RecipeRepository recipe = new RecipeRepository(_options, new HttpClient(), _cacheServiceMock.Object);

            var controller = new RecipesController(recipe, _mapper, _logger);
            var result     = await controller.GetRecipeIngredients(12);

            result.Should().NotBeNull();
            var okResult = result.Should().BeOfType <OkObjectResult>().Subject;

            Assert.True(okResult.StatusCode.Equals(200));
            var model = okResult.Value.Should().BeAssignableTo <RecipeIngredientsResponse>().Subject;

            model.Ingredients.Should().HaveCount(4);
        }