Beispiel #1
0
        public async Task UpdateDrafted_Should_Return_Bad_Request()
        {
            // Arrange
            var lotteryViewModel = new EditDraftedLotteryViewModel
            {
                Id    = 31,
                Title = "Hello"
            };

            var lotteryDto = new LotteryDto
            {
                Id    = 31,
                Title = "Hello"
            };

            _mapper.Map <EditDraftedLotteryViewModel, LotteryDto>(lotteryViewModel)
            .Returns(lotteryDto);

            _lotteryService.When(x => x.EditDraftedLotteryAsync(lotteryDto))
            .Do(_ => throw new LotteryException("Exception"));

            // Act
            var response = await _lotteryController.UpdateDrafted(lotteryViewModel);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsInstanceOf <BadRequestErrorMessageResult>(response);
            await _lotteryService.Received(1).EditDraftedLotteryAsync(lotteryDto);
        }