コード例 #1
0
        public void UpdateAttributeTest3()
        {
            var attrObj     = Generator.GenerateAttribute(isProperty: true);
            var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attrObj);

            attributeFQN1.Add(createdAttr.AttributeFQN);
            var  rules = AttributeTypeRuleFactory.GetAttributeTypeRules(ApiMsgHandler);
            bool found = false;

            foreach (var rule in rules.Items)
            {
                if (rule.AttributeUsageType.ToLower().Equals("property") &&
                    rule.AttributeDataType.ToLower().Equals(createdAttr.DataType.ToLower()) &&
                    rule.AttributeInputType.ToLower().Equals(createdAttr.InputType.ToLower()) &&
                    rule.AttributeValueType.ToLower().Equals(createdAttr.ValueType.ToLower()))
                {
                    continue;
                }
                found = true;
                createdAttr.DataType  = rule.AttributeDataType;
                createdAttr.InputType = rule.AttributeInputType;
                createdAttr.ValueType = rule.AttributeValueType;
                break;
            }
            if (!found)
            {
                Assert.Inconclusive("could find another rule");
            }
            var updateAttr = AttributeFactory.UpdateAttribute(ApiMsgHandler, createdAttr, createdAttr.AttributeFQN, expectedCode: HttpStatusCode.Conflict);
        }
コード例 #2
0
        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;
                }
            }
        }