public void GetMarketplaceOrdersTestReturnsNone()
 {
     IMarketplaceIntegration integration = new AmazonIntegration.AmazonIntegration();
     var createdAfter = DateTime.Now.AddMinutes(-2);
     IEnumerable<MarketplaceOrder> orders = integration.GetMarketplaceOrders(createdAfter);
     Assert.AreEqual(0, orders.Count());
 }
        public void GetMarketplaceOrdersTestReturnsNone()
        {
            IMarketplaceIntegration integration = new AmazonIntegration.AmazonIntegration();
            var createdAfter = DateTime.Now.AddMinutes(-2);
            IEnumerable <MarketplaceOrder> orders = integration.GetMarketplaceOrders(createdAfter);

            Assert.AreEqual(0, orders.Count());
        }
 public void GetMarketplaceOrdersTestForPast3Days()
 {
     IMarketplaceIntegration integration = new AmazonIntegration.AmazonIntegration();
     // get the orders for the past 3 days
     var createdAfter = DateTime.Now.AddDays(-3);
     IEnumerable<MarketplaceOrder> orders = integration.GetMarketplaceOrders(createdAfter);
     Assert.IsTrue(orders.Count() > 0);
     foreach (var order in orders)
     {
         Assert.IsTrue(!string.IsNullOrWhiteSpace(order.BuyerName));
         Assert.IsTrue(!string.IsNullOrWhiteSpace(order.MarketplaceOrderId));
         Assert.AreEqual(EMarketplace.Amazon, order.Marketplace);
         Assert.AreNotEqual(EOrderStatus.Shipped, order.OrderStatus);
         foreach (var item in order.Items)
         {
             Assert.IsTrue(!string.IsNullOrWhiteSpace(item.MarketplaceItemId));
             Assert.IsTrue(!string.IsNullOrWhiteSpace(item.MarketplaceOrderItemId));
             Assert.IsTrue(!string.IsNullOrWhiteSpace(item.SKU));
         }
     }
 }
        public void GetMarketplaceOrdersTestForPast3Days()
        {
            IMarketplaceIntegration integration = new AmazonIntegration.AmazonIntegration();
            // get the orders for the past 3 days
            var createdAfter = DateTime.Now.AddDays(-3);
            IEnumerable <MarketplaceOrder> orders = integration.GetMarketplaceOrders(createdAfter);

            Assert.IsTrue(orders.Count() > 0);
            foreach (var order in orders)
            {
                Assert.IsTrue(!string.IsNullOrWhiteSpace(order.BuyerName));
                Assert.IsTrue(!string.IsNullOrWhiteSpace(order.MarketplaceOrderId));
                Assert.AreEqual(EMarketplace.Amazon, order.Marketplace);
                Assert.AreNotEqual(EOrderStatus.Shipped, order.OrderStatus);
                foreach (var item in order.Items)
                {
                    Assert.IsTrue(!string.IsNullOrWhiteSpace(item.MarketplaceItemId));
                    Assert.IsTrue(!string.IsNullOrWhiteSpace(item.MarketplaceOrderItemId));
                    Assert.IsTrue(!string.IsNullOrWhiteSpace(item.SKU));
                }
            }
        }
        public void UpdateMarketplaceTrackingSuccessfulTest()
        {
            IMarketplaceIntegration integration = new AmazonIntegration.AmazonIntegration();
            var order  = integration.GetMarketplaceOrders(DateTime.Now.AddDays(-1)).FirstOrDefault();
            var orders = new[] {
                new MarketplaceOrderFulfillment
                {
                    Carrier               = new Carrier(Carrier.FedExCarrierCode),
                    FulfillmentDate       = DateTime.Now,
                    Marketplace           = EMarketplace.Amazon,
                    MarketplaceOrderId    = order.MarketplaceOrderId,
                    ShippingMethod        = "Express Saver",
                    ShipperTrackingNumber = "425921896955",
                    Items = new List <MarketplaceOrderFulfillmentItem> {
                        new MarketplaceOrderFulfillmentItem
                        {
                            MarketplaceOrderItemId = order.Items.First().MarketplaceOrderItemId,
                            Quantity = order.Items.First().QuantityUnshipped
                        }
                    }
                }
            };

            try
            {
                //integration.UpdateMarketplaceTracking(orders);
                // this should throw an exception.
            }
            catch (AmazonOrderFulfillmentException e)
            {
                Assert.Fail();
            }
            catch (Exception e)
            {
                // no other exception should be thrown.
                Assert.Fail();
            }
        }
 public void UpdateMarketplaceTrackingSuccessfulTest()
 {
     IMarketplaceIntegration integration = new AmazonIntegration.AmazonIntegration();
     var order = integration.GetMarketplaceOrders(DateTime.Now.AddDays(-1)).FirstOrDefault();
     var orders = new[] {
         new MarketplaceOrderFulfillment
         {
             Carrier = new Carrier(Carrier.FedExCarrierCode),
             FulfillmentDate = DateTime.Now,
             Marketplace = EMarketplace.Amazon,
             MarketplaceOrderId = order.MarketplaceOrderId,
             ShippingMethod = "Express Saver",
             ShipperTrackingNumber= "425921896955",
             Items = new List<MarketplaceOrderFulfillmentItem>{
                 new MarketplaceOrderFulfillmentItem
                 {
                     MarketplaceOrderItemId = order.Items.First().MarketplaceOrderItemId,
                     Quantity = order.Items.First().QuantityUnshipped
                 }
             }
         }
     };
     try
     {
         //integration.UpdateMarketplaceTracking(orders);
         // this should throw an exception.
     }
     catch (AmazonOrderFulfillmentException e)
     {
         Assert.Fail();
     }
     catch (Exception e)
     {
         // no other exception should be thrown.
         Assert.Fail();
     }
 }