public async void CancelPaymentAsync_ShouldReturnNotFound() { var accountId = Guid.NewGuid(); var paymentId = Guid.NewGuid(); var mediator = new Mock <IMediator>(); mediator.Setup(m => m.Send(It.IsAny <CancelPaymentCommand>(), It.IsAny <CancellationToken>())).Throws(new KeyNotFoundException()); var controller = new PaymentController(mediator.Object); var result = await controller.CancelPaymentAsync(accountId, paymentId, new CancelReasonDTO { Reason = "cancel" }); Assert.True(result is NotFoundResult); }