public async Task Mediatr_test_success() { //Assemble var _mediatorMock = new Mock <IMediator>(); var _mockCmd = new Mock <GeneratePaymentCmd>(); var FirstName = "JOHN"; var LastName = "DOE"; var AnualSalary = 60050; var PaymentPeriod = "1March-31March"; var Super = "9"; var ExpectedIncomeTax = 922; //Arrange var fakeResult = new PaymentDTO() { IncomeTax = ExpectedIncomeTax }; var mockCmd = new GeneratePaymentCmd(FirstName, LastName, AnualSalary, PaymentPeriod, Super); _mediatorMock.Setup(x => x.Send(It.IsAny <GeneratePaymentCmd>(), default(System.Threading.CancellationToken))) .Returns(Task.FromResult(fakeResult)); //Act var payController = new PaymentController(_mediatorMock.Object); var actionResult = await payController.GeneratePaymentAsync(mockCmd); //Assert Assert.AreEqual(actionResult.Value.IncomeTax, ExpectedIncomeTax); }