Пример #1
0
        public async Task AddProductToMeal_WhenCalled_ReturnsTrue()
        {
            // Arrange
            var mealId    = _fixture.Items.FirstOrDefault().Id;
            var productId = 1;

            _mockRepository.Setup(r => r.AddProductToMealAsync(mealId, productId)).ReturnsAsync(true);

            // Act
            var mealResult = await _sut.AddProductToMeal(mealId, productId);

            // Assert
            mealResult.Should().BeTrue();
        }
Пример #2
0
        public async Task <IActionResult> AddProductToMeal(int mealId, int productId)
        {
            _logger.LogInformation("Entered in [POST] AddProductToMeal endpoint with mealId {}, productId {}", mealId, productId);
            IActionResult result;
            bool          added = await _mealService.AddProductToMeal(mealId, productId);

            if (added)
            {
                result = Ok();
            }
            else
            {
                result = BadRequest();
            }

            return(result);
        }