public static async Task WithUpdateableShippingMethodWithZoneRate(IClient client,
                                                                   Func <ShippingMethod, Task <ShippingMethod> > func)
 {
     await WithTaxCategory(client, async taxCategory =>
     {
         await WithZone(client, async zone =>
         {
             var zoneRates = new List <ZoneRateDraft>
             {
                 new ZoneRateDraft
                 {
                     Zone          = zone.ToKeyResourceIdentifier(),
                     ShippingRates = new List <ShippingRateDraft>
                     {
                         new ShippingRateDraft
                         {
                             Price     = Money.FromDecimal("EUR", 10),
                             FreeAbove = Money.FromDecimal("EUR", 100)
                         }
                     }
                 }
             };
             var draftWithTaxCategory = new ShippingMethodDraft
             {
                 TaxCategory = taxCategory.ToKeyResourceIdentifier(),
                 ZoneRates   = zoneRates
             };
             await WithUpdateableAsync(client, draftWithTaxCategory, DefaultShippingMethodDraft, func);
         });
     });
 }
Exemple #2
0
 public static async Task WithShippingMethodInUsaZone(IClient client, Func <ShippingMethod, Task> func)
 {
     await WithTaxCategory(client, async taxCategory =>
     {
         var usaLocation = new Location {
             Country = "US", State = "New York"
         };
         await WithZone(client, zoneDraft => DefaultZoneWithOneLocation(zoneDraft, usaLocation), async zone =>
         {
             var zoneRates = new List <ZoneRateDraft>
             {
                 new ZoneRateDraft
                 {
                     Zone          = zone.ToKeyResourceIdentifier(),
                     ShippingRates = new List <ShippingRateDraft>
                     {
                         new ShippingRateDraft
                         {
                             Price     = Money.FromDecimal("USD", 12),
                             FreeAbove = Money.FromDecimal("USD", 120)
                         }
                     }
                 }
             };
             var draftWithTaxCategory = new ShippingMethodDraft
             {
                 TaxCategory = taxCategory.ToKeyResourceIdentifier(),
                 ZoneRates   = zoneRates
             };
             await WithAsync(client, draftWithTaxCategory, DefaultShippingMethodDraft, func);
         });
     });
 }
        /// <summary>
        /// Get Shipping Method Draft
        /// </summary>
        /// <param name="country"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public ShippingMethodDraft GetShippingMethodDraft(string country = null, string state = null)
        {
            int    ran             = TestingUtility.RandomInt();
            string shippingCountry = country ?? TestingUtility.GetRandomEuropeCountry();
            string shippingState   = state ?? $"{shippingCountry}_State_{TestingUtility.RandomInt()}";

            TaxCategory         taxCategory         = this.CreateNewTaxCategory(shippingCountry, shippingState);
            ZoneRateDraft       zoneRateDraft       = this.GetNewZoneRateDraft(shippingCountry, shippingState);
            ShippingMethodDraft shippingMethodDraft = new ShippingMethodDraft()
            {
                Name        = $"Dhl_{ran}",
                Key         = $"Dhl_key_{ran}",
                TaxCategory = new ResourceIdentifier <TaxCategory>
                {
                    Key = taxCategory.Key
                },
                ZoneRates = new List <ZoneRateDraft>()
                {
                    zoneRateDraft
                },
                Description = "DHL"
            };

            return(shippingMethodDraft);
        }
        public static ShippingMethodDraft DefaultShippingMethodDraftWithTaxCategory(ShippingMethodDraft draft,
                                                                                    IReference <TaxCategory> taxCategoryReference)
        {
            var shippingMethodDraft = DefaultShippingMethodDraft(draft);

            shippingMethodDraft.TaxCategory = taxCategoryReference;
            return(shippingMethodDraft);
        }
        public static ShippingMethodDraft DefaultShippingMethodDraftWithZoneRate(ShippingMethodDraft draft,
                                                                                 List <ZoneRateDraft> zoneRates)
        {
            var shippingMethodDraft = DefaultShippingMethodDraft(draft);

            shippingMethodDraft.ZoneRates = zoneRates;
            return(shippingMethodDraft);
        }
        public static ShippingMethodDraft DefaultShippingMethodDraft(ShippingMethodDraft shippingMethodDraft)
        {
            var random = TestingUtility.RandomInt();

            shippingMethodDraft.Key  = $"Key_{random}";
            shippingMethodDraft.Name = $"ShippingMethod_{random}";
            return(shippingMethodDraft);
        }
        public ShippingMethod CreateShippingMethod(ShippingMethodDraft shippingMethodDraft)
        {
            IClient        commerceToolsClient = this.GetService <IClient>();
            ShippingMethod shippingMethod      = commerceToolsClient
                                                 .ExecuteAsync(new CreateCommand <ShippingMethod>(shippingMethodDraft)).Result;

            return(shippingMethod);
        }
Exemple #8
0
 public static async Task WithUpdateableShippingMethod(IClient client, Func <ShippingMethod, ShippingMethod> func)
 {
     await WithTaxCategory(client, async taxCategory =>
     {
         var draftWithTaxCategory = new ShippingMethodDraft {
             TaxCategory = taxCategory.ToKeyResourceIdentifier()
         };
         await WithUpdateable(client, draftWithTaxCategory, DefaultShippingMethodDraft, func);
     });
 }
Exemple #9
0
        public void CreateShippingMethod()
        {
            IClient             commerceToolsClient = this.shippingMethodsFixture.GetService <IClient>();
            ShippingMethodDraft shippingMethodDraft = this.shippingMethodsFixture.GetShippingMethodDraft();
            ShippingMethod      shippingMethod      = commerceToolsClient
                                                      .ExecuteAsync(new CreateCommand <ShippingMethod>(shippingMethodDraft)).Result;

            this.shippingMethodsFixture.ShippingMethodsToDelete.Add(shippingMethod);
            Assert.Equal(shippingMethodDraft.Name, shippingMethod.Name);
        }
 public static async Task WithUpdateableShippingMethod(IClient client,
                                                       Func <ShippingMethodDraft, ShippingMethodDraft> draftAction, Func <ShippingMethod, Task <ShippingMethod> > func)
 {
     await WithTaxCategory(client, async taxCategory =>
     {
         var draftWithTaxCategory = new ShippingMethodDraft
         {
             TaxCategory = taxCategory.ToKeyResourceIdentifier()
         };
         var finalDraft = draftAction.Invoke(draftWithTaxCategory);
         await WithUpdateableAsync(client, finalDraft, DefaultShippingMethodDraft, func);
     });
 }
        public static ShippingMethodDraft DefaultShippingMethodDraft(ShippingMethodDraft shippingMethodDraft)
        {
            var random = TestingUtility.RandomInt();

            shippingMethodDraft.Key           = $"Key_{random}";
            shippingMethodDraft.Name          = $"ShippingMethod_{random}";
            shippingMethodDraft.LocalizedName = new LocalizedString {
                { "en", $"ShippingMethod_{random}" }
            };
            shippingMethodDraft.LocalizedDescription = new LocalizedString {
                { "en", $"ShippingMethodDes_{random}" }
            };
            return(shippingMethodDraft);
        }
        public static ShippingMethodDraft DefaultShippingMethodDraftWithCustomType(ShippingMethodDraft draft, Type type, Fields fields)
        {
            var customFieldsDraft = new CustomFieldsDraft
            {
                Type   = type.ToKeyResourceIdentifier(),
                Fields = fields
            };

            var shippingMethodDraft = DefaultShippingMethodDraft(draft);

            shippingMethodDraft.Custom = customFieldsDraft;

            return(shippingMethodDraft);
        }
Exemple #13
0
        /// <summary>
        /// Creates a test shipping method draft.
        /// </summary>
        /// <returns>ShippingMethodDraft</returns>
        public static ShippingMethodDraft GetTestShippingMethodDraft(Project.Project project, TaxCategory taxCategory, Zone zone)
        {
            Reference taxCategoryReference = new Reference();

            taxCategoryReference.Id            = taxCategory.Id;
            taxCategoryReference.ReferenceType = Common.ReferenceType.TaxCategory;

            string name = string.Concat("Test Shipping Method ", Helper.GetRandomString(10));

            ZoneRate zoneRate = Helper.GetTestZoneRate(project, zone);

            ShippingMethodDraft shippingMethodDraft = new ShippingMethodDraft(name, taxCategoryReference, new List <ZoneRate>()
            {
                zoneRate
            });

            shippingMethodDraft.Description = "Created by commercetools.NET";

            return(shippingMethodDraft);
        }
Exemple #14
0
        public async Task ShouldCreateAndDeleteShippingMethodAsync()
        {
            ShippingMethodDraft       shippingMethodDraft = Helper.GetTestShippingMethodDraft(_project, _testTaxCategory, _testZone);
            Response <ShippingMethod> response            = await _client.ShippingMethods().CreateShippingMethodAsync(shippingMethodDraft);

            Assert.True(response.Success);

            ShippingMethod shippingMethod = response.Result;

            Assert.NotNull(shippingMethod.Id);

            string deletedShippingMethodId = shippingMethod.Id;

            response = await _client.ShippingMethods().DeleteShippingMethodAsync(shippingMethod);

            Assert.True(response.Success);

            response = await _client.ShippingMethods().GetShippingMethodByIdAsync(deletedShippingMethodId);

            Assert.False(response.Success);
        }
Exemple #15
0
        public ShippingMethodDraft GetShippingMethodDraft(string country = null)
        {
            int                 ran                 = this.RandomInt();
            TaxCategory         taxCategory         = this.CreateNewTaxCategory(country);
            ZoneRateDraft       zoneRateDraft       = this.GetNewZoneRateDraft(country);
            ShippingMethodDraft shippingMethodDraft = new ShippingMethodDraft()
            {
                Name        = $"Dhl_{ran}",
                Key         = $"Dhl_key_{ran}",
                TaxCategory = new ResourceIdentifier <TaxCategory>
                {
                    Key = taxCategory.Key
                },
                ZoneRates = new List <ZoneRateDraft>()
                {
                    zoneRateDraft
                },
                Description = "DHL"
            };

            return(shippingMethodDraft);
        }
Exemple #16
0
        /// <summary>
        /// Test setup
        /// </summary>
        public ShippingMethodManagerTest()
        {
            _client = new Client(Helper.GetConfiguration());

            Task <Response <Project.Project> > projectTask = _client.Project().GetProjectAsync();

            projectTask.Wait();
            Assert.True(projectTask.Result.Success);
            _project = projectTask.Result.Result;

            Assert.True(_project.Languages.Count > 0);
            Assert.True(_project.Currencies.Count > 0);

            TaxCategoryDraft taxCategoryDraft = Helper.GetTestTaxCategoryDraft(_project);
            Task <Response <TaxCategory> > taxCategoryTask = _client.TaxCategories().CreateTaxCategoryAsync(taxCategoryDraft);

            taxCategoryTask.Wait();
            Assert.True(taxCategoryTask.Result.Success);

            _testTaxCategory = taxCategoryTask.Result.Result;
            Assert.NotNull(_testTaxCategory.Id);

            Task <Response <ZoneQueryResult> > zoneQueryResultTask = _client.Zones().QueryZonesAsync();

            zoneQueryResultTask.Wait();
            Assert.True(zoneQueryResultTask.Result.Success);

            if (zoneQueryResultTask.Result.Result.Results.Count > 0)
            {
                _testZone        = zoneQueryResultTask.Result.Result.Results[0];
                _createdTestZone = false;
            }
            else
            {
                ZoneDraft zoneDraft = Helper.GetTestZoneDraft();
                Task <Response <Zone> > zoneTask = _client.Zones().CreateZoneAsync(zoneDraft);
                zoneTask.Wait();
                Assert.True(zoneTask.Result.Success);
                _testZone        = zoneTask.Result.Result;
                _createdTestZone = true;
            }

            Assert.NotNull(_testZone.Id);

            foreach (string country in _project.Countries)
            {
                Location location =
                    _testZone.Locations
                    .Where(l => l.Country.Equals(country, StringComparison.OrdinalIgnoreCase))
                    .FirstOrDefault();

                if (location == null)
                {
                    location         = new Location();
                    location.Country = country;

                    AddLocationAction       addLocationAction = new AddLocationAction(location);
                    Task <Response <Zone> > updateZoneTask    = _client.Zones().UpdateZoneAsync(_testZone, addLocationAction);
                    updateZoneTask.Wait();
                    Assert.True(updateZoneTask.Result.Success);
                    _testZone = updateZoneTask.Result.Result;
                }
            }

            Assert.NotNull(_testZone.Locations.Count > 0);

            _testShippingMethods = new List <ShippingMethod>();

            for (int i = 0; i < 5; i++)
            {
                ShippingMethodDraft shippingMethodDraft = Helper.GetTestShippingMethodDraft(_project, _testTaxCategory, _testZone);
                Task <Response <ShippingMethod> > shippingMethodTask = _client.ShippingMethods().CreateShippingMethodAsync(shippingMethodDraft);
                shippingMethodTask.Wait();
                Assert.True(shippingMethodTask.Result.Success);

                ShippingMethod shippingMethod = shippingMethodTask.Result.Result;
                Assert.NotNull(shippingMethod.Id);

                _testShippingMethods.Add(shippingMethod);
            }
        }
        public void Init()
        {
            _client = new Client(Helper.GetConfiguration());

            Task <Response <Project.Project> > projectTask = _client.Project().GetProjectAsync();

            projectTask.Wait();
            Assert.IsTrue(projectTask.Result.Success);
            _project = projectTask.Result.Result;

            Assert.IsTrue(_project.Languages.Count > 0, "No Languages");
            Assert.IsTrue(_project.Currencies.Count > 0, "No Currencies");

            _testCustomers = new List <Customer>();
            _testCarts     = new List <Cart>();
            _testCartsExternalAmountTaxMode = new List <Cart>();
            CustomerDraft customerDraft;
            Task <Response <CustomerCreatedMessage> > customerTask;
            CustomerCreatedMessage customerCreatedMessage;
            CartDraft cartDraft;
            Cart      cart;
            Task <Response <Cart> > cartTask;

            for (int i = 0; i < 5; i++)
            {
                customerDraft = Helper.GetTestCustomerDraft();
                customerTask  = _client.Customers().CreateCustomerAsync(customerDraft);
                customerTask.Wait();
                Assert.IsTrue(customerTask.Result.Success);

                customerCreatedMessage = customerTask.Result.Result;
                Assert.NotNull(customerCreatedMessage.Customer);
                Assert.NotNull(customerCreatedMessage.Customer.Id);

                _testCustomers.Add(customerCreatedMessage.Customer);

                cartDraft = Helper.GetTestCartDraft(_project, customerCreatedMessage.Customer.Id);
                cartTask  = _client.Carts().CreateCartAsync(cartDraft);
                cartTask.Wait();
                Assert.NotNull(cartTask.Result);
                Assert.IsTrue(cartTask.Result.Success, "CreateCartAsync failed");
                cart = cartTask.Result.Result;
                Assert.NotNull(cart.Id);
                Console.Error.WriteLine(string.Format("CartManagerTest - Information Only - Init TestCartDraft TaxMode: {0}", cartDraft.TaxMode == null ? "(default)" : cart.TaxMode.ToString()));

                _testCarts.Add(cart);


                cartDraft         = Helper.GetTestCartDraft(_project, customerCreatedMessage.Customer.Id);
                cartDraft.TaxMode = TaxMode.ExternalAmount;
                cartTask          = _client.Carts().CreateCartAsync(cartDraft);
                cartTask.Wait();
                Assert.NotNull(cartTask.Result);
                Assert.IsTrue(cartTask.Result.Success, "CreateCartAsync failed");
                cart = cartTask.Result.Result;
                Assert.IsTrue(cart.TaxMode == TaxMode.ExternalAmount, string.Format("Cart created using ExternalAmount TaxMode failed - TaxMode: {0}", cart.TaxMode));
                Assert.NotNull(cart.Id);
                Console.Error.WriteLine(string.Format("CartManagerTest - Information Only - Init TestCartDraft TaxMode: {0}", cartDraft.TaxMode == null ? "(default)" : cart.TaxMode.ToString()));

                _testCartsExternalAmountTaxMode.Add(cart);
            }

            //customer/cart with external tax mode enabled

            customerDraft = Helper.GetTestCustomerDraft();
            customerTask  = _client.Customers().CreateCustomerAsync(customerDraft);
            customerTask.Wait();
            Assert.IsTrue(customerTask.Result.Success);
            customerCreatedMessage = customerTask.Result.Result;
            Assert.NotNull(customerCreatedMessage.Customer);
            Assert.NotNull(customerCreatedMessage.Customer.Id);

            _testCustomers.Add(customerCreatedMessage.Customer);

            cartDraft = Helper.GetTestCartDraftUsingExternalTaxMode(_project, customerCreatedMessage.Customer.Id);
            cartTask  = _client.Carts().CreateCartAsync(cartDraft);
            cartTask.Wait();
            Assert.NotNull(cartTask.Result);
            Assert.IsTrue(cartTask.Result.Success, "CreateCartAsync failed");
            cart = cartTask.Result.Result;
            Assert.NotNull(cart.Id);
            Console.Error.WriteLine(string.Format("CartManagerTest - Information Only - Init TestCartDraft TaxMode: {0}", cart.TaxMode));

            _testCarts.Add(cart);

            ProductTypeDraft productTypeDraft = Helper.GetTestProductTypeDraft();
            Task <Response <ProductType> > testProductTypeTask =
                _client.ProductTypes().CreateProductTypeAsync(productTypeDraft);

            testProductTypeTask.Wait();
            Assert.IsTrue(testProductTypeTask.Result.Success, "CreateProductType failed");
            _testProductType = testProductTypeTask.Result.Result;
            Assert.NotNull(_testProductType.Id);

            TaxCategoryDraft taxCategoryDraft = Helper.GetTestTaxCategoryDraft(_project);
            Task <Response <TaxCategory> > taxCategoryTask =
                _client.TaxCategories().CreateTaxCategoryAsync(taxCategoryDraft);

            taxCategoryTask.Wait();
            Assert.IsTrue(taxCategoryTask.Result.Success, "CreateTaxCategory failed");
            _testTaxCategory = taxCategoryTask.Result.Result;
            Assert.NotNull(_testTaxCategory.Id);

            Task <Response <ZoneQueryResult> > zoneQueryResultTask = _client.Zones().QueryZonesAsync();

            zoneQueryResultTask.Wait();
            Assert.IsTrue(zoneQueryResultTask.Result.Success);

            if (zoneQueryResultTask.Result.Result.Results.Count > 0)
            {
                _testZone        = zoneQueryResultTask.Result.Result.Results[0];
                _createdTestZone = false;
            }
            else
            {
                ZoneDraft zoneDraft = Helper.GetTestZoneDraft();
                Task <Response <Zone> > zoneTask = _client.Zones().CreateZoneAsync(zoneDraft);
                zoneTask.Wait();
                Assert.IsTrue(zoneTask.Result.Success, "CreateZone failed");
                _testZone        = zoneTask.Result.Result;
                _createdTestZone = true;
            }

            Assert.NotNull(_testZone.Id);

            foreach (string country in _project.Countries)
            {
                Location location =
                    _testZone.Locations
                    .Where(l => l.Country.Equals(country, StringComparison.OrdinalIgnoreCase))
                    .FirstOrDefault();

                if (location == null)
                {
                    location         = new Location();
                    location.Country = country;

                    AddLocationAction       addLocationAction = new AddLocationAction(location);
                    Task <Response <Zone> > updateZoneTask    = _client.Zones().UpdateZoneAsync(_testZone, addLocationAction);
                    updateZoneTask.Wait();
                    Assert.IsTrue(updateZoneTask.Result.Success, "UpdateZone failed");
                    _testZone = updateZoneTask.Result.Result;
                }
            }

            Assert.NotNull(_testZone.Locations.Count > 0);

            ShippingMethodDraft shippingMethodDraft =
                Helper.GetTestShippingMethodDraft(_project, _testTaxCategory, _testZone);
            Task <Response <ShippingMethod> > shippingMethodTask =
                _client.ShippingMethods().CreateShippingMethodAsync(shippingMethodDraft);

            shippingMethodTask.Wait();
            Assert.IsTrue(shippingMethodTask.Result.Success, "CreateShippingMethod failed");
            _testShippingMethod = shippingMethodTask.Result.Result;

            Assert.NotNull(_testShippingMethod.Id);

            ProductDraft productDraft = Helper.GetTestProductDraft(_project, _testProductType.Id, _testTaxCategory.Id);
            Task <Response <Product> > testProductTask = _client.Products().CreateProductAsync(productDraft);

            testProductTask.Wait();
            Assert.IsTrue(testProductTask.Result.Success, "CreateProduct failed");
            _testProduct = testProductTask.Result.Result;

            Assert.NotNull(_testProduct.Id);

            PaymentDraft paymentDraft = Helper.GetTestPaymentDraft(_project, _testCustomers[0].Id);
            Task <Response <Payment> > paymentTask = _client.Payments().CreatePaymentAsync(paymentDraft);

            paymentTask.Wait();
            Assert.IsTrue(paymentTask.Result.Success, "CreatePayment failed");
            _testPayment = paymentTask.Result.Result;

            Assert.NotNull(_testPayment.Id);

            TypeDraft typeDraft = Helper.GetTypeDraft(_project);
            Task <Response <Type> > typeTask = _client.Types().CreateTypeAsync(typeDraft);

            typeTask.Wait();
            Assert.IsTrue(typeTask.Result.Success, "CreateType failed");
            _testType = typeTask.Result.Result;
        }
 public static void SetCartPredicate(this ShippingMethodDraft shippingMethodDraft, Expression <Func <Cart, bool> > expression)
 {
     shippingMethodDraft.Predicate = expression.RenderDiscountPredicate();
 }
Exemple #19
0
        public void Init()
        {
            _client = new Client(Helper.GetConfiguration());

            Task <Response <Project.Project> > projectTask = _client.Project().GetProjectAsync();

            projectTask.Wait();
            Assert.IsTrue(projectTask.Result.Success);
            _project = projectTask.Result.Result;

            _testCustomers = new List <Customer>();

            for (int i = 0; i < 5; i++)
            {
                CustomerDraft customerDraft = Helper.GetTestCustomerDraft();
                Task <Response <CustomerCreatedMessage> > customerTask = _client.Customers().CreateCustomerAsync(customerDraft);
                customerTask.Wait();
                Assert.IsTrue(customerTask.Result.Success);

                CustomerCreatedMessage customerCreatedMessage = customerTask.Result.Result;
                Assert.NotNull(customerCreatedMessage.Customer);
                Assert.NotNull(customerCreatedMessage.Customer.Id);

                _testCustomers.Add(customerCreatedMessage.Customer);
            }

            _testCarts = new List <Cart>();
            Task <Response <Cart> > cartTask;

            for (int i = 0; i < 5; i++)
            {
                CartDraft cartDraft = Helper.GetTestCartDraft(_project, _testCustomers[i].Id);
                cartTask = _client.Carts().CreateCartAsync(cartDraft);
                cartTask.Wait();
                Assert.IsTrue(cartTask.Result.Success);

                Cart cart = cartTask.Result.Result;
                Assert.NotNull(cart.Id);

                _testCarts.Add(cart);
            }

            ProductTypeDraft productTypeDraft = Helper.GetTestProductTypeDraft();
            Task <Response <ProductType> > productTypeTask = _client.ProductTypes().CreateProductTypeAsync(productTypeDraft);

            productTypeTask.Wait();
            Assert.IsTrue(productTypeTask.Result.Success);

            _testProductType = productTypeTask.Result.Result;
            Assert.NotNull(_testProductType.Id);

            TaxCategoryDraft taxCategoryDraft = Helper.GetTestTaxCategoryDraft(_project);
            Task <Response <TaxCategory> > taxCategoryTask = _client.TaxCategories().CreateTaxCategoryAsync(taxCategoryDraft);

            taxCategoryTask.Wait();
            Assert.IsTrue(taxCategoryTask.Result.Success);

            _testTaxCategory = taxCategoryTask.Result.Result;
            Assert.NotNull(_testTaxCategory.Id);

            Task <Response <ZoneQueryResult> > zoneQueryResultTask = _client.Zones().QueryZonesAsync();

            zoneQueryResultTask.Wait();

            if (zoneQueryResultTask.Result.Success && zoneQueryResultTask.Result.Result.Results.Count > 0)
            {
                _testZone        = zoneQueryResultTask.Result.Result.Results[0];
                _createdTestZone = false;
            }
            else
            {
                ZoneDraft zoneDraft = Helper.GetTestZoneDraft();
                Task <Response <Zone> > zoneTask = _client.Zones().CreateZoneAsync(zoneDraft);
                zoneTask.Wait();
                Assert.IsTrue(zoneTask.Result.Success);

                _testZone        = zoneTask.Result.Result;
                _createdTestZone = true;
            }

            Assert.NotNull(_testZone.Id);

            ShippingMethodDraft shippingMethodDraft = Helper.GetTestShippingMethodDraft(_project, _testTaxCategory, _testZone);
            Task <Response <ShippingMethod> > shippingMethodTask = _client.ShippingMethods().CreateShippingMethodAsync(shippingMethodDraft);

            shippingMethodTask.Wait();
            Assert.IsTrue(shippingMethodTask.Result.Success);

            _testShippingMethod = shippingMethodTask.Result.Result;
            Assert.NotNull(_testShippingMethod.Id);

            ProductDraft productDraft = Helper.GetTestProductDraft(_project, _testProductType.Id, _testTaxCategory.Id);
            Task <Response <Product> > productTask = _client.Products().CreateProductAsync(productDraft);

            productTask.Wait();
            Assert.IsTrue(productTask.Result.Success);

            _testProduct = productTask.Result.Result;
            Assert.NotNull(_testProduct.Id);

            int quantity = 1;
            AddLineItemAction addLineItemAction = new AddLineItemAction(_testProduct.Id, _testProduct.MasterData.Current.MasterVariant.Id);

            addLineItemAction.Quantity = quantity;
            cartTask = _client.Carts().UpdateCartAsync(_testCarts[0], addLineItemAction);
            cartTask.Wait();
            Assert.IsTrue(cartTask.Result.Success);

            _testCarts[0] = cartTask.Result.Result;
            Assert.NotNull(_testCarts[0].Id);
            Assert.NotNull(_testCarts[0].LineItems);
            Assert.AreEqual(_testCarts[0].LineItems.Count, 1);
            Assert.AreEqual(_testCarts[0].LineItems[0].ProductId, _testProduct.Id);
            Assert.AreEqual(_testCarts[0].LineItems[0].Variant.Id, _testProduct.MasterData.Current.MasterVariant.Id);
            Assert.AreEqual(_testCarts[0].LineItems[0].Quantity, quantity);

            OrderFromCartDraft       orderFromCartDraft = Helper.GetTestOrderFromCartDraft(_testCarts[0]);
            Task <Response <Order> > orderTask          = _client.Orders().CreateOrderFromCartAsync(orderFromCartDraft);

            orderTask.Wait();
            Assert.IsTrue(orderTask.Result.Success);

            _testOrder = orderTask.Result.Result;
            Assert.NotNull(_testOrder.Id);

            cartTask = _client.Carts().GetCartByIdAsync(_testCarts[0].Id);
            cartTask.Wait();
            Assert.IsTrue(cartTask.Result.Success);

            _testCarts[0] = cartTask.Result.Result;
            Assert.NotNull(_testCarts[0].Id);
        }