public async Task <IActionResult> UpdateCertificateWithReprintReason([FromBody] UpdateCertificateWithReprintReasonCommand command) { try { await _mediator.Send(command); } catch (NotFoundException) { throw new ResourceNotFoundException(); } return(Ok()); }
public void WhenCalledWithInvalidCertificate_ThenThrowsNotFoundException(UpdateCertificateWithReprintReasonCommand command) { // Arrange var fixture = new UpdateCertificateWithReprintReasonCommandHandlerTestsFixture() .WithCertificate(command.CertificateReference); command.OtherReason = string.Empty; // Act & Assert Assert.ThrowsAsync <NotFoundException>(async() => await fixture.Handle(new UpdateCertificateWithReprintReasonCommand { CertificateReference = command.CertificateReference + "NotValid", IncidentNumber = command.IncidentNumber, Reasons = command.Reasons, OtherReason = command.OtherReason, Username = command.Username })); }
public async Task WhenCalledWithOtherReason_ThenUpdateIsCalled_ForCertificateReference(UpdateCertificateWithReprintReasonCommand command) { // Arrange var fixture = new UpdateCertificateWithReprintReasonCommandHandlerTestsFixture() .WithCertificate(command.CertificateReference); command.OtherReason = "Some other reason"; // Act await fixture.Handle(new UpdateCertificateWithReprintReasonCommand { 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.ReprintReason, command.OtherReason); }
public async Task Handle(UpdateCertificateWithReprintReasonCommand command) { await _sut.Handle(command, new CancellationToken()); }