Exemplo n.º 1
0
        public async Task Update_ReturnsNoContent()
        {
            var classUnderTest = new LunchController(_lunchService.Object, _mapper);

            var id       = Guid.NewGuid();
            var lunch    = GetSampleLunch(id);
            var lunchDto = new InputLunchDto
            {
                Date   = lunch.Date,
                MealId = lunch.MealId
            };

            _lunchService.Setup(a => a.UpdateAsync(
                                    It.Is <Lunch>(l =>
                                                  l.MealId == lunchDto.MealId &&
                                                  l.Date == lunchDto.Date &&
                                                  l.Id == id)))
            .ReturnsAsync(lunch);

            var result = await classUnderTest.Update(id, lunchDto);

            Assert.IsType <NoContentResult>(result);

            _lunchService.Verify(a => a.UpdateAsync(
                                     It.Is <Lunch>(l =>
                                                   l.MealId == lunchDto.MealId &&
                                                   l.Date == lunchDto.Date &&
                                                   l.Id == id)), Times.Once);
        }
Exemplo n.º 2
0
        public async Task Update_ReturnsBadRequest_WhenDtoIsNull()
        {
            var classUnderTest = new LunchController(_lunchService.Object, _mapper);

            var result = await classUnderTest.Update(Guid.NewGuid(), null);

            Assert.IsType <BadRequestResult>(result);
            _lunchService.Verify(a => a.UpdateAsync(It.IsAny <Lunch>()), Times.Never);
        }