public static ProductTypeDraft DefaultProductTypeDraftWithEmptyAttributes(ProductTypeDraft draft) { var productTypeDraft = DefaultProductTypeDraft(draft); productTypeDraft.Attributes.Clear(); return(productTypeDraft); }
public static ProductTypeDraft DefaultProductTypeDraftWithOnlyTextAttribute(ProductTypeDraft draft) { var productTypeDraft = DefaultProductTypeDraft(draft); productTypeDraft.Attributes.RemoveAll(attribute => attribute.Type.GetType() != typeof(TextAttributeType)); return(productTypeDraft); }
public static ProductTypeDraft DefaultProductTypeDraftWithKey(ProductTypeDraft draft, string key) { var productTypeDraft = DefaultProductTypeDraft(draft); productTypeDraft.Key = key; return(productTypeDraft); }
public ProductType CreateProductType() { ProductTypeDraft productTypeDraft = this.CreateProductTypeDraft(); IClient commerceToolsClient = this.GetService <IClient>(); ProductType createdType = commerceToolsClient.ExecuteAsync(new CreateCommand <ProductType>(productTypeDraft)).Result; return(createdType); }
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); Assert.IsTrue(_project.Currencies.Count > 0); 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); _testProducts = new List <Product>(); for (int i = 0; i < 5; i++) { ProductDraft productDraft = Helper.GetTestProductDraft(_project, _testProductType.Id, _testTaxCategory.Id); productDraft.Publish = true; LocalizedString name = new LocalizedString(); foreach (string language in _project.Languages) { name.SetValue(language, string.Concat("Test Product ", i, " ", language, " ", Helper.GetRandomString(10))); } productDraft.Name = name; Task <Response <Product> > productTask = _client.Products().CreateProductAsync(productDraft); productTask.Wait(); Assert.IsTrue(productTask.Result.Success); Product product = productTask.Result.Result; Assert.NotNull(product.Id); _testProducts.Add(product); } }
public void CreateProductType() { IClient commerceToolsClient = this.productTypeFixture.GetService <IClient>(); ProductTypeDraft typeDraft = this.productTypeFixture.CreateProductTypeDraft(); ProductType type = commerceToolsClient.ExecuteAsync(new CreateCommand <ProductType>(typeDraft)).Result; this.productTypeFixture.ProductTypesToDelete.Add(type); Assert.Equal(typeDraft.Key, type.Key); }
/// <summary> /// Gets a test product type draft. /// </summary> /// <returns>ProductTypeDraft</returns> public static ProductTypeDraft GetTestProductTypeDraft() { string name = string.Concat("Test Product Type ", Helper.GetRandomString(10)); ProductTypeDraft draft = new ProductTypeDraft(name, "Created by commercetools.NET"); draft.Key = Helper.GetRandomString(6); return(draft); }
public void Init() { _client = Helper.GetClient(); Task <Response <Project.Project> > projectTask = _client.Project().GetProjectAsync(); projectTask.Wait(); Assert.IsTrue(projectTask.Result.Success); _project = projectTask.Result.Result; ProductTypeDraft productTypeDraft = Helper.GetTestProductTypeDraft(); Task <Response <ProductType> > productTypeTask = _client.ProductTypes().CreateProductTypeAsync(productTypeDraft); productTypeTask.Wait(); Assert.IsTrue(productTypeTask.Result.Success); ProductType testProductType = productTypeTask.Result.Result; Assert.NotNull(testProductType.Id); TaxCategoryDraft testTaxCategoryDraft = Helper.GetTestTaxCategoryDraft(_project); Task <Response <TaxCategory> > taxCategoryTask = _client.TaxCategories().CreateTaxCategoryAsync(testTaxCategoryDraft); taxCategoryTask.Wait(); Assert.IsTrue(taxCategoryTask.Result.Success); ProductDraft productDraft = Helper.GetTestProductDraft(_project, testProductType.Id, taxCategoryTask.Result.Result.Id); Task <Response <Product> > productTask = _client.Products().CreateProductAsync(productDraft); productTask.Wait(); Assert.IsTrue(productTask.Result.Success); Product testProduct = productTask.Result.Result; Assert.NotNull(testProduct.Id); _testProductId = testProduct.Id; var deleteProduct = _client.Products().DeleteProductAsync(testProduct); deleteProduct.Wait(); Assert.IsTrue(deleteProduct.Result.Success); var deleteProductType = _client.ProductTypes().DeleteProductTypeAsync(testProductType); deleteProductType.Wait(); Assert.IsTrue(deleteProductType.Result.Success); var deleteTaxCategory = _client.TaxCategories().DeleteTaxCategoryAsync(taxCategoryTask.Result.Result); deleteTaxCategory.Wait(); Assert.IsTrue(deleteTaxCategory.Result.Success); }
public void Init() { _client = Helper.GetClient(); Task <Response <Project.Project> > projectTask = _client.Project().GetProjectAsync(); projectTask.Wait(); Assert.IsTrue(projectTask.Result.Success); _project = projectTask.Result.Result; 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); _testProducts = new List <Product>(); for (int i = 0; i < 5; i++) // Default Money { ProductDraft productDraft = Helper.GetTestProductDraft(_project, _testProductType.Id, _testTaxCategory.Id); Task <Response <Product> > productTask = _client.Products().CreateProductAsync(productDraft); productTask.Wait(); Assert.IsTrue(productTask.Result.Success); Product product = productTask.Result.Result; Assert.NotNull(product.Id); _testProducts.Add(product); } //Add Product with Money Price => CentPrecision Money Type _productIdWithCentPrecisionPrice = AddProductWithSpecificMoneyType(MoneyTestTypes.CentPrecision); //Add Product with Money Price => HighPrecision Money Type _productIdWithHighPrecisionPrice = AddProductWithSpecificMoneyType(MoneyTestTypes.HighPrecision); }
/// <summary> /// Test setup /// </summary> public ProductTypeManagerTest() { _client = new Client(Helper.GetConfiguration()); _testProductTypes = new List <ProductType>(); for (int i = 0; i < 5; i++) { ProductTypeDraft productTypeDraft = Helper.GetTestProductTypeDraft(); Task <Response <ProductType> > task = _client.ProductTypes().CreateProductTypeAsync(productTypeDraft); task.Wait(); Assert.True(task.Result.Success); ProductType productType = task.Result.Result; Assert.NotNull(productType.Id); _testProductTypes.Add(productType); } }
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; 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); _testProducts = new List <Product>(); for (int i = 0; i < 5; i++) { ProductDraft productDraft = Helper.GetTestProductDraft(_project, _testProductType.Id, _testTaxCategory.Id); Task <Response <Product> > productTask = _client.Products().CreateProductAsync(productDraft); productTask.Wait(); Assert.IsTrue(productTask.Result.Success); Product product = productTask.Result.Result; Assert.NotNull(product.Id); _testProducts.Add(product); } }
public static ProductTypeDraft DefaultProductTypeDraft(ProductTypeDraft productTypeDraft) { productTypeDraft.Key = TestingUtility.RandomString(10); productTypeDraft.Name = TestingUtility.RandomString(10); productTypeDraft.Description = TestingUtility.RandomString(10); productTypeDraft.Attributes = new List <AttributeDefinitionDraft>(); productTypeDraft.Attributes.Add(CreateTextAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(CreateLocalizedTextAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(CreateBooleanAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(CreateNumberAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(CreateDateAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(CreateDateTimeAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(CreateTimeAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(CreateMoneyAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(CreateReferenceAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(CreateSetAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(CreateEnumAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(CreateLocalizedEnumAttributeDefinitionDraft()); return(productTypeDraft); }
public async Task ShouldCreateAndDeleteProductTypeAsync() { ProductTypeDraft productTypeDraft = Helper.GetTestProductTypeDraft(); Response <ProductType> response = await _client.ProductTypes().CreateProductTypeAsync(productTypeDraft); Assert.True(response.Success); ProductType productType = response.Result; Assert.NotNull(productType.Id); string deletedProductTypeId = productType.Id; Response <JObject> deleteResponse = await _client.ProductTypes().DeleteProductTypeAsync(productType); Assert.True(deleteResponse.Success); response = await _client.ProductTypes().GetProductTypeByIdAsync(deletedProductTypeId); Assert.False(response.Success); }
public ProductTypeDraft CreateProductTypeDraft() { ProductTypeDraft productTypeDraft = new ProductTypeDraft(); productTypeDraft.Key = this.RandomString(10); productTypeDraft.Name = this.RandomString(10); productTypeDraft.Description = this.RandomString(10); productTypeDraft.Attributes = new List <AttributeDefinitionDraft>(); productTypeDraft.Attributes.Add(this.CreateTextAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(this.CreateLocalizedTextAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(this.CreateBooleanAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(this.CreateNumberAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(this.CreateDateAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(this.CreateDateTimeAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(this.CreateTimeAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(this.CreateMoneyAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(this.CreateReferenceAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(this.CreateSetAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(this.CreateEnumAttributeDefinitionDraft()); productTypeDraft.Attributes.Add(this.CreateLocalizedEnumAttributeDefinitionDraft()); return(productTypeDraft); }
public static ProductTypeDraft DefaultProductTypeDraftWithOnlyTextAttributeWithConstraint(ProductTypeDraft draft, AttributeConstraint constraint) { var productTypeDraft = DefaultProductTypeDraft(draft); productTypeDraft.Attributes.RemoveAll(attribute => attribute.Type.GetType() != typeof(TextAttributeType)); productTypeDraft.Attributes[0].AttributeConstraint = constraint; return(productTypeDraft); }
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); }
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 void Init() { _client = Helper.GetClient(); 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); Assert.IsTrue(_project.Currencies.Count > 0); 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); _testProducts = new List <Product>(); for (int i = 0; i < 5; i++) { ProductDraft productDraft = Helper.GetTestProductDraft(_project, _testProductType.Id, _testTaxCategory.Id); productDraft.Publish = true; LocalizedString name = new LocalizedString(); foreach (string language in _project.Languages) { name.SetValue(language, string.Concat("Test Product ", i, " ", language, " ", Helper.GetRandomString(10))); } productDraft.Name = name; Task <Response <Product> > productTask = _client.Products().CreateProductAsync(productDraft); productTask.Wait(); Assert.IsTrue(productTask.Result.Success); Product product = productTask.Result.Result; Assert.NotNull(product.Id); _testProducts.Add(product); } for (int i = 0; i < 12; i++) { var pt = _client.ProductProjectionSearch().SearchProductProjectionsAsync(); pt.Wait(); if (pt.Result.Result.Count > 4) { Console.Error.WriteLine("Product search returned " + pt.Result.Result.Count + " products"); break; } Task.Delay(10000).Wait(); } }