public void CreatesCommand() { var commandDto = BuildCancelPurchaseApplicationCommandDto(); var result = CancelPurchaseApplicationCommand.Create(commandDto); result.IsSuccess.Should().BeTrue(); result.IfSuccess(command => { var expectedPurchaseApplicationId = Id.Create(commandDto.PurchaseApplicationId).IfFail(() => null); command.PurchaseApplicationId.Should().Be(expectedPurchaseApplicationId); var expectedRejectionReason = RejectionReason.Create(commandDto.RejectionReason).IfFail(() => null); command.RejectionReason.Should().Be(expectedRejectionReason); }); }
public void CreatesReject() { var result = RejectionReason.Create("Razon del rechazo"); result.IsSuccess.Should().BeTrue(); }
public void DoesNotCancelPurchaseApplicationWhenCommandCreationHasValidationErrors() { var request = BuildRequest(purchaseApplicationId: null); var response = controller.Cancel(request) as ObjectResult; response.StatusCode.Should().Be(StatusCodes.Status400BadRequest); var badRequestResponseModel = (BadRequestResponseModel)response.Value; badRequestResponseModel.ValidationErrors.Should().NotBeNull(); badRequestResponseModel.OperationError.Should().BeNull(); commandHandler .Verify(x => x.Cancel(It.Is <CancelPurchaseApplicationCommand>(y => y.PurchaseApplicationId == Id.Create(request.PurchaseApplicationId).IfFail(() => null) && y.RejectionReason == RejectionReason.Create(request.RejectionReason).IfFail(() => null))), Times.Never); }
public void CancelsPurchaseApplication() { var request = BuildRequest(); commandHandler .Setup(x => x.Cancel(It.IsAny <CancelPurchaseApplicationCommand>())) .Returns(PurchaseApplicationBuilder.Build()); var response = controller.Cancel(request) as StatusCodeResult; response.StatusCode.Should().Be(StatusCodes.Status200OK); commandHandler .Verify(x => x.Cancel(It.Is <CancelPurchaseApplicationCommand>(y => y.PurchaseApplicationId == Id.Create(request.PurchaseApplicationId).IfFail(() => null) && y.RejectionReason == RejectionReason.Create(request.RejectionReason).IfFail(() => null))), Times.Once); }