public async Task ClosePledge_Returns_NotFound( int pledgeId, SetClosePledgeRequest closePledgeRequest, [Frozen] Mock <IMediator> mockMediator, [Greedy] PledgeController pledgeController) { var closePledgeResult = new ClosePledgeCommandResult { ErrorContent = string.Empty, StatusCode = HttpStatusCode.NotFound }; mockMediator .Setup(x => x.Send( It.Is <ClosePledgeCommand>((x) => x.PledgeId == pledgeId), It.IsAny <CancellationToken>())) .ReturnsAsync(closePledgeResult); var controllerResponse = await pledgeController.ClosePledge(pledgeId, closePledgeRequest); var statusResult = controllerResponse as StatusCodeResult; Assert.IsNotNull(statusResult); Assert.AreEqual((int)HttpStatusCode.NotFound, statusResult.StatusCode); }
public async Task ClosePledge_Returns_Error( int pledgeId, SetClosePledgeRequest closePledgeRequest, [Frozen] Mock <IMediator> mockMediator, [Greedy] PledgeController pledgeController) { mockMediator .Setup(x => x.Send( It.Is <ClosePledgeCommand>((x) => x.PledgeId == pledgeId), It.IsAny <CancellationToken>())) .Throws(new InvalidOperationException()); var controllerResponse = await pledgeController.ClosePledge(pledgeId, closePledgeRequest); var exception = controllerResponse as StatusCodeResult; Assert.IsNotNull(exception); Assert.AreEqual((int)HttpStatusCode.InternalServerError, exception.StatusCode); }