public async void CreateTwoTripBagsForTrip()
        {
            var dow = new DayOfWork
            {
                User     = user,
                Elements = new List <TripElement>
                {
                    new TripElement {
                        Id = 1, Weight = 30
                    },
                    new TripElement {
                        Id = 2, Weight = 30
                    },
                    new TripElement {
                        Id = 3, Weight = 1
                    },
                    new TripElement {
                        Id = 4, Weight = 1
                    }
                }
            };
            var result = await calculationService.CalculateTripAsync(dow);

            Assert.Equal(2, result.Bags.Count);
            Assert.True(result.Bags.All(b => b.BagWeight == 31));
        }
Exemple #2
0
        public async Task <ActionResult <TripDto> > CalculateTrip([FromBody] DayOfWork dow)
        {
            _logger.Log(LogLevel.Information, $"{nameof(TripController)}: {nameof(CalculateTrip)}", dow);
            if (string.IsNullOrEmpty(dow.User.IdentityNumber))
            {
                var ex = new NullReferenceException("IdentityNumber in DayOfWork.User is empty or null");
                _logger.LogError($"{nameof(TripController)}: {nameof(CalculateTrip)}", ex);
                return(null);
            }
            var trip = await _calculationService.CalculateTripAsync(dow);

            var tripDto = _mapper.Map <TripDto>(trip);

            return(Ok(tripDto));
        }