public void GetAttributeTest1() { var attrs = AttributeFactory.GetAttributes(ApiMsgHandler); var getAttr = AttributeFactory.GetAttribute(ApiMsgHandler, attrs.Items.Last().AttributeFQN, expectedCode: HttpStatusCode.OK); Assert.AreEqual(attrs.Items.Last().AttributeFQN, getAttr.AttributeFQN); }
public void GetAttributesTest1() { int pageSize = 5; int totalCount = 0; int startIndex = 0; int expectedTotalCount = 0; while (true) { // Mozu.ProductAdmin.Contracts.Attribute it = AttributeFactory.Attibute; var attrs = AttributeFactory.GetAttributes( ApiMsgHandler, startIndex: startIndex, pageSize: pageSize, expectedCode: HttpStatusCode.OK); Assert.AreEqual(startIndex, attrs.StartIndex); Assert.AreEqual((attrs.TotalCount + attrs.PageSize - 1) / attrs.PageSize, attrs.PageCount); if (attrs.TotalCount <= 5) { Assert.Inconclusive("Not enough attributes for testing."); } totalCount += attrs.Items.Count; startIndex += pageSize; if (attrs.Items.Count < pageSize) { expectedTotalCount = (int)attrs.TotalCount; break; } } Assert.AreEqual(expectedTotalCount, totalCount); }
public void GetAttributesTest3() { var attrs = AttributeFactory.GetAttributes(ApiMsgHandler); var attrs_filter = AttributeFactory.GetAttributes(ApiMsgHandler, filter: "AttributeSequence eq " + attrs.Items.First().AttributeSequence, expectedCode: HttpStatusCode.OK); Assert.AreEqual(1, attrs_filter.TotalCount); Assert.AreEqual(attrs.Items.First().AttributeFQN, attrs_filter.Items.First().AttributeFQN); }
public void GetAttributesTest2() { var attrs = AttributeFactory.GetAttributes(ApiMsgHandler, sortBy: "AttributeCode asc", expectedCode: HttpStatusCode.OK); Assert.IsTrue(string.Compare(attrs.Items.First().AttributeCode, attrs.Items.Last().AttributeCode) < 0); attrs = AttributeFactory.GetAttributes(ApiMsgHandler, sortBy: "AttributeCode desc", expectedCode: HttpStatusCode.OK); Assert.IsTrue(string.Compare(attrs.Items.First().AttributeCode, attrs.Items.Last().AttributeCode) > 0); }
public static List<T> GetAttributes<T>(this Type type) { return AttributeFactory.GetAttributes<T>(type); }
/// <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 } } }
public static List <T> GetAttributes <T>(this PropertyInfo property) { return(AttributeFactory.GetAttributes <T>(property)); }
public static List <T> GetAttributes <T>(this MethodInfo method) { return(AttributeFactory.GetAttributes <T>(method)); }