public async Task FinishLottery_Should_Return_Bad_Request() { // Arrange _lotteryService.FinishLotteryAsync(37, UserAndOrganizationArg).Throws(new LotteryException("Exception")); // Act var response = await _lotteryController.FinishLottery(37); // Assert Assert.IsNotNull(response); Assert.IsInstanceOf <BadRequestErrorMessageResult>(response); await _lotteryService.Received(1).FinishLotteryAsync(37, UserAndOrganizationArg); }
public async Task <IHttpActionResult> FinishLottery(int id) { try { await _lotteryService.FinishLotteryAsync(id, GetUserAndOrganization()); return(Ok()); } catch (LotteryException e) { return(BadRequest(e.Message)); } }