예제 #1
0
        public async Task ShoudCreateOrderWhenThereIsNoOverLappingDates()
        {
            var gasStation = _orderDateFixture.GasStations.First();

            var orderInputDTO = new OrderInputDTO
            {
                CarrierId = _orderDateFixture.Carriers.First().Id,
                Comments  = "Manual Order",
                OrderType = _orderDateFixture.OrderStrategies
                            .First(x => x.GasStationId == gasStation.Id)
                            .OrderType,
                FromDateTime = new DateTime(2020, 12, 1, 8, 0, 0),
                ToDateTime   = new DateTime(2020, 12, 1, 12, 0, 0),
                GasStationId = gasStation.Id,
                LineItems    = gasStation.Tanks.Select(
                    x => new OrderInputDTO.OrderProductInputDTO
                {
                    TankId   = x.Id,
                    Quantity = 500,
                    Unit     = TankMeasurement.Gallons
                })
            };

            var result = await _orderApp.AddAsync(orderInputDTO);

            Assert.True(result.IsSuccess);
            Assert.True(result.OrderId > 0);
            Assert.Single(result.Message);
            Assert.True(result.Message.First() == OrderConstant.successMessage);
            _mockHelper.MockManagerOrderRepository.Verify(repo =>
                                                          repo.GetOrderByGasStationIdDeliveryDateAsync(It.IsAny <Guid>(), It.IsAny <DateTimeRange>()),
                                                          Times.Once);
            _mockHelper.MockManagerOrderRepository.Verify(repo =>
                                                          repo.UpsertAsync(It.IsAny <ManageOrder>()), Times.Once);
        }
        public async Task <ActionResult <IEnumerable <WeatherForecast> > > Get()
        {
            _logger.LogInformation("Hello from controller");

            var result = await _orderApp.AddAsync(
                new SmartBuy.OrderManagement.Application.InputDTOs.OrderInputDTO
            {
                GasStationId = Guid.NewGuid()
            });

            // throw new Exception("User should not see this exception");

            return(Ok(new List <WeatherForecast> {
                new WeatherForecast {
                    Summary = "Weather is good",
                    Date = DateTime.Now,
                    TemperatureC = 30
                }
            }));
        }