Esempio n. 1
0
        public void AmazonAnalyticsService_GetNumberOfShippedProducts_ShouldReturnPersistedEntriesShippedProductsCount()
        {
            var items = Enumerable.Range(0, 10).Select(i => new AmazonOrder()
            {
                OrderTotalAmount       = 1,
                NumberOfItemsShipped   = 1,
                NumberOfItemsUnshipped = 0,
                Status       = i >= 5 ? AmazonOrderStatus.Shipped : AmazonOrderStatus.Unshipped,
                PurchaseDate = CurrentRequestData.Now.Date.AddDays(1),
                CreatedOn    = CurrentRequestData.Now.Date.AddDays(1),
                Site         = CurrentRequestData.CurrentSite,
            }).ToList();

            foreach (var amazonOrder in items)
            {
                amazonOrder.Items = new List <AmazonOrderItem>()
                {
                    new AmazonOrderItem()
                    {
                        AmazonOrder     = amazonOrder,
                        QuantityOrdered = 1,
                        QuantityShipped = 1
                    }
                };
            }
            Session.Transact(session => items.ForEach(item => session.Save(item)));

            var results = _amazonAnalyticsService.GetNumberOfShippedProducts(CurrentRequestData.Now.Date.AddDays(-20),
                                                                             CurrentRequestData.Now.Date.AddDays(20));

            results.Should().Be(10);
        }