示例#1
0
        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);
        }
示例#2
0
        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));
        }
示例#3
0
        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);
        }
示例#4
0
 public async Task <ActionResult <GetParkingRateResponse> > Get([FromBody] GetParkingRateQuery query)
 {
     return(await Mediator.Send(query));
 }