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 AddAttributeTest6() { var attrObj = Generator.GenerateAttribute(isExtra: true); attrObj.Validation = Generator.GenerateAttributeValidation(DateTime.Now.Date.AddDays(10), DateTime.Now.Date, Generator.RandomInt(8, 20), Generator.RandomInt(1, 7), Generator.RandomInt(10, 20), Generator.RandomInt(1, 10), Generator.RandomString(5, Generator .RandomCharacterGroup .AlphaOnly)); var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attrObj); attributeFQN1.Add(createdAttr.AttributeFQN); var getAttr = AttributeFactory.GetAttribute(ApiMsgHandler, createdAttr.AttributeFQN); Assert.AreEqual(attrObj.Validation.RegularExpression, getAttr.Validation.RegularExpression); Assert.AreEqual(attrObj.Validation.MaxDateValue, getAttr.Validation.MaxDateValue); Assert.AreEqual(attrObj.Validation.MinDateValue, getAttr.Validation.MinDateValue); Assert.AreEqual(attrObj.Validation.MaxNumericValue, getAttr.Validation.MaxNumericValue); Assert.AreEqual(attrObj.Validation.MinNumericValue, getAttr.Validation.MinNumericValue); Assert.AreEqual(attrObj.Validation.MaxStringLength, getAttr.Validation.MaxStringLength); Assert.AreEqual(attrObj.Validation.MinStringLength, getAttr.Validation.MinStringLength); }
public void AddAttributeTest1() { var attr1 = Generator.GenerateAttribute(isProperty: true, isExtra: true); var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attr1); attributeFQN1.Add(createdAttr.AttributeFQN); var getAttr = AttributeFactory.GetAttribute(ApiMsgHandler, createdAttr.AttributeFQN); Assert.AreEqual(attr1.AttributeCode, getAttr.AttributeCode); Assert.AreEqual(createdAttr.AttributeFQN, getAttr.AttributeFQN); }
public void AddAttributeTest9() { var attrObj = Generator.GenerateAttribute(isExtra: true); attrObj.Content = Generator.GenerateAttributeLocalizedContent(); var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attrObj); attributeFQN1.Add(createdAttr.AttributeFQN); var getAttr = AttributeFactory.GetAttribute(ApiMsgHandler, createdAttr.AttributeFQN); Assert.AreEqual(attrObj.Content.Description, getAttr.Content.Description); Assert.AreEqual(attrObj.Content.Name, getAttr.Content.Name); Assert.AreEqual(attrObj.Content.LocaleCode, getAttr.Content.LocaleCode); }
public void AddAttributeTest10() { var attrObj = Generator.GenerateAttribute(isExtra: true); var audit = Generator.GenerateAuditInfoRandom(); attrObj.AuditInfo = audit; var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attrObj); attributeFQN1.Add(createdAttr.AttributeFQN); var getAttr = AttributeFactory.GetAttribute(ApiMsgHandler, createdAttr.AttributeFQN); Assert.AreNotEqual(audit.CreateBy, getAttr.AuditInfo.CreateBy); Assert.AreNotEqual(((DateTime)audit.CreateDate).Date, ((DateTime)getAttr.AuditInfo.CreateDate).Date); Assert.AreNotEqual(audit.UpdateBy, getAttr.AuditInfo.UpdateBy); Assert.AreNotEqual(((DateTime)audit.UpdateDate).Date, ((DateTime)getAttr.AuditInfo.UpdateDate).Date); }
public void AddAttributeTest7() { var attrObj = Generator.GenerateAttribute(Generator.RandomString(5, Generator.RandomCharacterGroup.AlphaOnly), Generator.RandomString(5, Generator.RandomCharacterGroup.AlphaOnly), inputType: "list", valueType: "predefined", dataType: "string", isExtra: true); var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attrObj, expectedCode: HttpStatusCode.Created); attributeFQN1.Add(createdAttr.AttributeFQN); var getAttr = AttributeFactory.GetAttribute(ApiMsgHandler, createdAttr.AttributeFQN); Assert.AreEqual(attrObj.VocabularyValues.First().Value, getAttr.VocabularyValues.First().Value); Assert.AreEqual(attrObj.VocabularyValues.First().Content.LocaleCode, getAttr.VocabularyValues.First().Content.LocaleCode); Assert.AreEqual(attrObj.VocabularyValues.First().Content.StringValue, getAttr.VocabularyValues.First().Content.StringValue); Assert.AreEqual(attrObj.VocabularyValues.Last().Value, getAttr.VocabularyValues.Last().Value); Assert.AreEqual(attrObj.VocabularyValues.Last().Content.LocaleCode, getAttr.VocabularyValues.Last().Content.LocaleCode); Assert.AreEqual(attrObj.VocabularyValues.Last().Content.StringValue, getAttr.VocabularyValues.Last().Content.StringValue); }
public void AddAttributeTest3() { if (TestBaseTenant.MasterCatalogs.Count < 2) { Assert.Inconclusive("only one site group"); } else { var msgHandler2 = ServiceClientMessageFactory.GetTestClientMessage(TestBaseTenant.Id, TestBaseTenant.MasterCatalogs.Last().Id); var attr1 = Generator.GenerateAttribute(isProperty: true, isExtra: true); attr1.MasterCatalogId = TestBaseTenant.MasterCatalogs.Last().Id; var createdAttr = AttributeFactory.AddAttribute(msgHandler2, attr1); attributeFQN2.Add(createdAttr.AttributeFQN); // should not be in the first site group AttributeFactory.GetAttribute(ApiMsgHandler, createdAttr.AttributeFQN, expectedCode: HttpStatusCode.NotFound); // should be in the last site group AttributeFactory.GetAttribute(msgHandler2, createdAttr.AttributeFQN); } }
public void AddAttributeTest8() { var attrObj = Generator.GenerateAttribute(isExtra: true); attrObj.AttributeMetadata = Generator.GenerateAttributeMetadataItemList(); attrObj.AttributeMetadata.Clear(); var meta1 = Generator.GenerateAttributeMetadataItem(); var meta2 = Generator.GenerateAttributeMetadataItem(); attrObj.AttributeMetadata.Add(meta1); attrObj.AttributeMetadata.Add(meta2); var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attrObj); attributeFQN1.Add(createdAttr.AttributeFQN); var getAttr = AttributeFactory.GetAttribute(ApiMsgHandler, createdAttr.AttributeFQN); Assert.AreEqual(meta1.Key, getAttr.AttributeMetadata.Last().Key); Assert.AreEqual(meta1.Value, getAttr.AttributeMetadata.Last().Value); Assert.AreEqual(meta2.Key, getAttr.AttributeMetadata.First().Key); Assert.AreEqual(meta2.Value, getAttr.AttributeMetadata.First().Value); }
public void AddAttributeTest4() { var rules = AttributeTypeRuleFactory.GetAttributeTypeRules(ApiMsgHandler); //Attribute attrObj; foreach (var rule in rules.Items) { var attrObj = Generator.GenerateAttribute(rule); var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attrObj, expectedCode: HttpStatusCode.Created); attributeFQN1.Add(createdAttr.AttributeFQN); var getAttr = AttributeFactory.GetAttribute(ApiMsgHandler, createdAttr.AttributeFQN); Assert.AreEqual(rule.AttributeDataType, getAttr.DataType); Assert.AreEqual(rule.AttributeInputType, getAttr.InputType); Assert.AreEqual(rule.AttributeValueType, getAttr.ValueType); switch (rule.AttributeUsageType) { case "Property": Assert.IsTrue((bool)getAttr.IsProperty); Assert.IsFalse((bool)getAttr.IsExtra); Assert.IsFalse((bool)getAttr.IsOption); break; case "Extra": Assert.IsFalse((bool)getAttr.IsProperty); Assert.IsTrue((bool)getAttr.IsExtra); Assert.IsFalse((bool)getAttr.IsOption); break; case "Option": Assert.IsFalse((bool)getAttr.IsProperty); Assert.IsFalse((bool)getAttr.IsExtra); Assert.IsTrue((bool)getAttr.IsOption); break; } } }
public void GetAttributeTest2() { var getAttr = AttributeFactory.GetAttribute(ApiMsgHandler, Generator.RandomString(5, Generator.RandomCharacterGroup.AlphaOnly), expectedCode: HttpStatusCode.NotFound); }
public static T GetAttribute<T>(this Type type) { return AttributeFactory.GetAttribute<T>(type); }
public static T GetAttribute <T>(this PropertyInfo property) { return(AttributeFactory.GetAttribute <T>(property)); }
public static T GetAttribute <T>(this MethodInfo method) { return(AttributeFactory.GetAttribute <T>(method)); }