public async Task <IActionResult> UpdateCertificateWithAmendReason([FromBody] UpdateCertificateWithAmendReasonCommand command) { try { await _mediator.Send(command); } catch (NotFoundException) { throw new ResourceNotFoundException(); } return(Ok()); }
public void WhenCalledWithInvalidCertificate_ThenThrowsNotFoundException(UpdateCertificateWithAmendReasonCommand command) { // Arrange var fixture = new UpdateCertificateWithAmendReasonCommandHandlerTestsFixture() .WithCertificate(command.CertificateReference); command.OtherReason = string.Empty; // Act & Assert Assert.ThrowsAsync <NotFoundException>(async() => await fixture.Handle(new UpdateCertificateWithAmendReasonCommand { CertificateReference = command.CertificateReference + "NotValid", IncidentNumber = command.IncidentNumber, Reasons = command.Reasons, OtherReason = command.OtherReason, Username = command.Username })); }
public async Task WhenCalledWithOtherReason_ThenUpdateIsCalled_ForCertificateReference(UpdateCertificateWithAmendReasonCommand command) { // Arrange var fixture = new UpdateCertificateWithAmendReasonCommandHandlerTestsFixture() .WithCertificate(command.CertificateReference); command.OtherReason = "Some other reason"; // Act await fixture.Handle(new UpdateCertificateWithAmendReasonCommand { CertificateReference = command.CertificateReference, IncidentNumber = command.IncidentNumber, Reasons = command.Reasons, OtherReason = command.OtherReason, Username = command.Username }); // Assert fixture.VerifyUpdateCalled(command.CertificateReference, command.IncidentNumber, command.Reasons, command.Username, CertificateActions.AmendReason, command.OtherReason); }
public async Task Handle(UpdateCertificateWithAmendReasonCommand command) { await _sut.Handle(command, new CancellationToken()); }