Пример #1
0
        It_can_GetAttributeAsComplexObject_when_the_attribute_has_a_refId_value_and_the_backing_field_ObjetID_matches_the_value_in_the_attribute()
        {
            var freshCreatorObjectID = Guid.NewGuid().ToString("D");

            var creator = new IdmResource
            {
                CreatedTime    = DateTime.Now,
                Description    = "Test creator",
                DisplayName    = "Joe User",
                ExpirationTime = DateTime.Now + TimeSpan.FromDays(1),
                MVObjectID     = Guid.NewGuid().ToString("D"),
                ObjectID       = freshCreatorObjectID,
                ObjectType     = "Person",
                ResourceTime   = DateTime.Now
            };

            var it = new IdmResource {
                Attributes = new List <IdmAttribute> {
                    new IdmAttribute {
                        Name = "Creator", Value = freshCreatorObjectID
                    }
                }
            };

            var result = it.GetAttr("Creator", creator);

            Assert.AreEqual(freshCreatorObjectID, it.Creator.ObjectID);
            Assert.AreEqual("Joe User", result.DisplayName);
        }
Пример #2
0
        public void It_should_return_null_for_empty_attributes()
        {
            var it = new IdmResource();

            Assert.IsNull(it.GetAttr("foo"));
            Assert.IsNull(it.GetAttrValue("foo"));
            Assert.IsNull(it.GetAttrValues("foo"));
        }
Пример #3
0
        public void It_can_SettAttrValue_nullable_null_value_and_come_back_as_null_as_either_Value_or_ToInt()
        {
            var it = new IdmResource();

            it.SetAttrValue("foo", null);

            var result1 = it.GetAttrValue("foo");
            var result2 = it.GetAttr("foo").ToInteger();
            var result3 = it.GetAttr("foo").ToDateTime();
            var result4 = it.GetAttr("foo").ToBinary();
            var result5 = it.GetAttr("foo").ToBool();

            Assert.IsNull(result1);
            Assert.IsNull(result2);
            Assert.IsNull(result3);
            Assert.IsNull(result4);
            Assert.IsNull(result5);
        }
Пример #4
0
        public void It_can_GetAttributeAsComplexObject_when_the_attribute_has_a_refId_value_and_the_backing_field_is_null()
        {
            var creatorObjectID = Guid.NewGuid().ToString("D");
            IdmResource subResource = null;

            var it = new IdmResource { Attributes = new List<IdmAttribute> { new IdmAttribute { Name = "Creator", Value = creatorObjectID } } };

            // ReSharper disable once ExpressionIsAlwaysNull
            it.GetAttr("Creator", subResource);

            Assert.AreEqual(creatorObjectID, it.Creator.ObjectID);
        }
Пример #5
0
        It_can_GetAttributeAsComplexObject_when_the_attribute_has_a_refId_value_and_the_backing_field_is_null()
        {
            var         creatorObjectID = Guid.NewGuid().ToString("D");
            IdmResource subResource     = null;

            var it = new IdmResource {
                Attributes = new List <IdmAttribute> {
                    new IdmAttribute {
                        Name = "Creator", Value = creatorObjectID
                    }
                }
            };

            // ReSharper disable once ExpressionIsAlwaysNull
            it.GetAttr("Creator", subResource);

            Assert.AreEqual(creatorObjectID, it.Creator.ObjectID);
        }
Пример #6
0
        private static void BuildAttribute(XmlNode attribute, IdmResource resource)
        {
            string name = attribute.LocalName;
            string val  = attribute.InnerText;

            if (val.StartsWith("urn:uuid:"))
            {
                val = val.Substring(9);
            }

            var attr = resource.GetAttr(name);

            if (attr != null)
            {
                attr.Values.Add(val);
            }
            else
            {
                resource.Attributes.Add(new IdmAttribute {
                    Name = name, Value = val
                });
            }
        }
Пример #7
0
        public void It_can_GetAttributeAsComplexObject_when_the_attribute_has_a_refId_value_and_the_backing_field_ObjetID_matches_the_value_in_the_attribute()
        {
            var freshCreatorObjectID = Guid.NewGuid().ToString("D");

            var creator = new IdmResource
            {
                CreatedTime = DateTime.Now,
                Description = "Test creator",
                DisplayName = "Joe User",
                ExpirationTime = DateTime.Now + TimeSpan.FromDays(1),
                MVObjectID = Guid.NewGuid().ToString("D"),
                ObjectID = freshCreatorObjectID,
                ObjectType = "Person",
                ResourceTime = DateTime.Now
            };

            var it = new IdmResource { Attributes = new List<IdmAttribute> { new IdmAttribute { Name = "Creator", Value = freshCreatorObjectID } } };

            var result = it.GetAttr("Creator", creator);

            Assert.AreEqual(freshCreatorObjectID, it.Creator.ObjectID);
            Assert.AreEqual("Joe User", result.DisplayName);
        }
Пример #8
0
        public void It_can_GettAttr_that_then_allows_modification_of_the_attr()
        {
            var it = new IdmResource
            {
                Attributes =
                    new List <IdmAttribute> {
                    new IdmAttribute {
                        Name = "foo", Values = new List <string> {
                            "foo", "bar"
                        }
                    }
                }
            };

            var attr = it.GetAttr("foo");

            attr.Values.Add("bat");

            var result = it.GetAttrValues("foo");

            Assert.AreEqual("foo", result[0]);
            Assert.AreEqual("bar", result[1]);
            Assert.AreEqual("bat", result[2]);
        }
Пример #9
0
        private static void BuildAttribute(XmlNode attribute, IdmResource resource)
        {
            string name = attribute.LocalName;
            string val = attribute.InnerText;

            if (val.StartsWith("urn:uuid:"))
                val = val.Substring(9);

            var attr = resource.GetAttr(name);
            if (attr != null)
                attr.Values.Add(val);
            else
                resource.Attributes.Add(new IdmAttribute { Name = name, Value = val });
        }
Пример #10
0
        public void It_should_return_null_for_empty_attributes()
        {
            var it = new IdmResource();

            Assert.IsNull(it.GetAttr("foo"));
            Assert.IsNull(it.GetAttrValue("foo"));
            Assert.IsNull(it.GetAttrValues("foo"));
        }
Пример #11
0
        public void It_can_SettAttrValue_nullable_null_value_and_come_back_as_null_as_either_Value_or_ToInt()
        {
            var it = new IdmResource();

            it.SetAttrValue("foo", null);

            var result1 = it.GetAttrValue("foo");
            var result2 = it.GetAttr("foo").ToInteger();
            var result3 = it.GetAttr("foo").ToDateTime();
            var result4 = it.GetAttr("foo").ToBinary();
            var result5 = it.GetAttr("foo").ToBool();

            Assert.IsNull(result1);
            Assert.IsNull(result2);
            Assert.IsNull(result3);
            Assert.IsNull(result4);
            Assert.IsNull(result5);
        }
Пример #12
0
        public void It_can_GettAttr_that_then_allows_modification_of_the_attr()
        {
            var it = new IdmResource
            {
                Attributes =
                    new List<IdmAttribute> { new IdmAttribute { Name = "foo", Values = new List<string> { "foo", "bar" } } }
            };

            var attr = it.GetAttr("foo");

            attr.Values.Add("bat");

            var result = it.GetAttrValues("foo");

            Assert.AreEqual("foo", result[0]);
            Assert.AreEqual("bar", result[1]);
            Assert.AreEqual("bat", result[2]);
        }