public async Task Handle_ValidRequest_ReturnsSpecialRate() { // Arrange var request = new GetParkingRateQuery() { EntryDateTime = new DateTime(2000, 1, 1, 11, 0, 0), ExitDateTime = new DateTime(2000, 1, 2, 12, 0, 0) }; var speacialParkingRateResponse = new GetParkingRateResponse { Rate = 13.00, Total = 13.00 }; var parkingRateService = new Mock <IParkingRateService>(); parkingRateService.Setup(x => x.GetCheapestSpecialRate(It.IsAny <DateTime>(), It.IsAny <DateTime>())) .Returns(speacialParkingRateResponse); var GetParkingRateQueryHandler = new GetParkingRateQueryHandler(parkingRateService.Object); var response = await GetParkingRateQueryHandler.Handle(request, default); Assert.Equal(speacialParkingRateResponse.Total, response.Total); }
public async Task Validator__DefaultExitDate_InvalidValidation() { // Arrange var request = new GetParkingRateQuery() { EntryDateTime = new DateTime(2000, 1, 1, 12, 0, 0), ExitDateTime = new DateTime() }; // Act & Assert await ValidateInvalidPropertyAsync(request, nameof(GetParkingRateQuery.ExitDateTime)); }
public async Task Validator_ExitAfterEntry_SuccessfulValidation() { // Arrange var request = new GetParkingRateQuery() { EntryDateTime = new DateTime(2000, 1, 1, 11, 0, 0), ExitDateTime = new DateTime(2000, 1, 2, 12, 0, 0) }; // Act & Assert await ValidateValidObjectAsync(request); }
public async Task <ActionResult <GetParkingRateResponse> > Get([FromBody] GetParkingRateQuery query) { return(await Mediator.Send(query)); }