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); }
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")); }
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); }
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); }
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); }
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 }); } }
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); }
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]); }
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 }); }
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]); }