public void DeleteAttributeTest2()
        {
            var attrObj     = Generator.GenerateAttribute(isProperty: true);
            var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler,
                                                            attrObj);

            AttributeFactory.DeleteAttribute(ApiMsgHandler,
                                             createdAttr.AttributeFQN,
                                             expectedCode: HttpStatusCode.NoContent);
        }
Exemplo n.º 2
0
 public static void CleanUpAttributes(ServiceClientMessageHandler handler, List <string> attributeFQNs)
 {
     foreach (var attributeFQN in attributeFQNs)
     {
         //should return NoContent, bypass for now
         try
         {
             AttributeFactory.DeleteAttribute(handler, attributeFQN);
         }
         catch (TestFailException e)  //work around the bug
         {
             // ToDo: e.ActualReturnCode
         }
     }
 }
        public void DeleteAttributeTest1()
        {
            var attrObj     = Generator.GenerateAttribute(isProperty: true);
            var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attrObj);

            attributeFQN1.Add(createdAttr.AttributeFQN);
            var myPT = Generator.GenerateProductType(createdAttr,
                                                     Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));
            var createdPT = ProductTypeFactory.AddProductType(ApiMsgHandler, myPT);

            productTypeId1.Add(createdPT.Id.Value);
            var myProduct      = Generator.GenerateProduct(createdPT);
            var createdProduct = ProductFactory.AddProduct(ApiMsgHandler, myProduct);

            productCode1.Add(createdProduct.ProductCode);
            AttributeFactory.DeleteAttribute(ApiMsgHandler, createdAttr.AttributeFQN, expectedCode: HttpStatusCode.Conflict);
        }
 public void DeleteAttributeTest3()
 {
     AttributeFactory.DeleteAttribute(ApiMsgHandler,
                                      Generator.RandomString(5, Generator.RandomCharacterGroup.AlphaOnly),
                                      expectedCode: HttpStatusCode.NotFound);
 }
Exemplo n.º 5
0
        /// <summary>
        /// clean up products, attributes, productypes and categories since provisioning the tenant
        /// </summary>
        /// <param name="tenantId"></param>
        /// <param name="masterCatalogId"></param>
        /// <param name="siteId"></param>
        public static void CleanUpProducts(int tenantId, int masterCatalogId, int?catalogId = null, int?siteId = null)
        {
            var tenant            = TenantFactory.GetTenant(ServiceClientMessageFactory.GetTestClientMessage(), tenantId);
            var ApiMessageHandler = ServiceClientMessageFactory.GetTestClientMessage(tenantId: tenantId, masterCatalogId: masterCatalogId, catalogId: catalogId, siteId: siteId);
            var products          = ProductFactory.GetProducts(ApiMessageHandler, noCount: null, pageSize: null, q: null, qLimit: null, sortBy: null, startIndex: null, filter: "createdate gt " + SinceWhen(DateTime.Now.AddDays(-1)));

            foreach (var pro in products.Items)
            {
                ProductFactory.DeleteProduct(ApiMessageHandler, pro.ProductCode);
            }
            var productTypes = ProductTypeFactory.GetProductTypes(handler: ApiMessageHandler, successCode: HttpStatusCode.OK, expectedCode: HttpStatusCode.OK);

            foreach (var pt in productTypes.Items)
            {
                if (pt.AuditInfo.CreateDate.Value > DateTime.Now.AddDays(-1))
                {
                    try
                    {
                        ProductTypeFactory.DeleteProductType(ApiMessageHandler, pt.Id.Value);
                    }
                    catch (TestFailException e)   //getaround base product type
                    {
                        // ToDo: e.ActualReturnCode
                    }
                }
            }
            var attributes = AttributeFactory.GetAttributes(handler: ApiMessageHandler, successCode: HttpStatusCode.OK, expectedCode: HttpStatusCode.OK);

            if (attributes.TotalCount != 0)
            {
                foreach (var attr in attributes.Items)
                {
                    if (attr.AuditInfo.CreateDate.Value > DateTime.Now.AddDays(-1))
                    {
                        //bug 18745, should return NoContent
                        try
                        {
                            AttributeFactory.DeleteAttribute(ApiMessageHandler, attr.AttributeFQN);
                        }
                        catch (TestFailException e)  //get around the bug
                        {
                            // ToDo: e.ActualReturnCode
                        }
                    }
                }
            }
            var cates = CategoryFactory.GetCategories(ApiMessageHandler, pageSize: null, sortBy: null, startIndex: null, filter: "createdate gt " + SinceWhen(DateTime.Now.AddDays(-1)));

            foreach (var cate in cates.Items)
            {
                var messageHandler1 = ServiceClientMessageFactory.GetTestClientMessage(tenantId: tenantId, masterCatalogId: masterCatalogId, catalogId: catalogId, siteId: siteId);
                try
                {
                    CategoryFactory.DeleteCategoryById(handler: messageHandler1, categoryId: (int)cate.Id, cascadeDelete: true);
                }
                catch (TestFailException e)   //work around notfound
                {
                    // ToDo: e.ActualReturnCode
                }
            }
        }