public async Task CallMediatorWithCorrectParameters() { var mediator = new Mock <IMediator>(); var command = new CalculatePriceCommand(); var controller = new PricingController(mediator.Object); await controller.Post(command); mediator.Verify(x => x.Send(command, default(CancellationToken)), Times.Once()); }
public async Task ReturnJsonResult() { var mediator = new Mock <IMediator>(); var command = new CalculatePriceCommand(); var calculatePriceResult = new CalculatePriceResult { TotalPrice = 12 }; mediator.Setup(x => x.Send(command, default(CancellationToken))).ReturnsAsync(calculatePriceResult); var controller = new PricingController(mediator.Object); var result = await controller.Post(command); Assert.IsAssignableFrom <JsonResult>(result); Assert.Equal(calculatePriceResult, ((JsonResult)result).Value); }