Esempio n. 1
0
        It_can_GetMultiValuedAttrAsComplexObjects_when_the_backing_field_is_null()
        {
            var subObjectID1 = Guid.NewGuid().ToString("D");
            var subObjectID2 = Guid.NewGuid().ToString("D");
            var subObjectID3 = Guid.NewGuid().ToString("D");

            List <IdmResource> resources = null;

            var it = new IdmResource
            {
                Attributes =
                    new List <IdmAttribute> {
                    new IdmAttribute {
                        Name = "MultiValuedReferenceIDs", Values = new List <string> {
                            subObjectID1, subObjectID2, subObjectID3
                        }
                    }
                }
            };

            // ReSharper disable once ExpressionIsAlwaysNull
            var result = it.GetMultiValuedAttr("MultiValuedReferenceIDs", resources);

            Assert.AreEqual(subObjectID1, result[0].ObjectID);
            Assert.AreEqual(subObjectID2, result[1].ObjectID);
            Assert.AreEqual(subObjectID3, result[2].ObjectID);
        }
Esempio n. 2
0
        It_can_GetMultiValuedAttrAsComplexObjects_when_only_some_of_the_items_are_in_the_backing_field()
        {
            var subObjectID1 = Guid.NewGuid().ToString("D");
            var subObjectID2 = Guid.NewGuid().ToString("D");
            var subObjectID3 = Guid.NewGuid().ToString("D");

            var resources = new List <IdmResource>
            {
                new IdmResource
                {
                    CreatedTime    = DateTime.Now,
                    Description    = "Test resource",
                    DisplayName    = "sub resource 1",
                    ExpirationTime = DateTime.Now + TimeSpan.FromDays(1),
                    MVObjectID     = Guid.NewGuid().ToString("D"),
                    ObjectID       = subObjectID1,
                    ObjectType     = "Resource",
                    ResourceTime   = DateTime.Now
                },
                new IdmResource
                {
                    CreatedTime    = DateTime.Now,
                    Description    = "Test resource",
                    DisplayName    = "sub resource 2",
                    ExpirationTime = DateTime.Now + TimeSpan.FromDays(1),
                    MVObjectID     = Guid.NewGuid().ToString("D"),
                    ObjectID       = subObjectID2,
                    ObjectType     = "Resource",
                    ResourceTime   = DateTime.Now
                }
            };

            var it = new IdmResource
            {
                Attributes =
                    new List <IdmAttribute> {
                    new IdmAttribute {
                        Name = "MultiValuedReferenceIDs", Values = new List <string> {
                            subObjectID1, subObjectID2, subObjectID3
                        }
                    }
                }
            };

            var result = it.GetMultiValuedAttr("MultiValuedReferenceIDs", resources);

            Assert.AreEqual("sub resource 1", result[0].DisplayName);
            Assert.AreEqual("sub resource 2", result[1].DisplayName);
            Assert.AreEqual(subObjectID3, result[2].ObjectID);
        }
Esempio n. 3
0
        public void It_can_GetMultiValuedAttrAsComplexObjects_when_the_backing_field_is_null()
        {
            var subObjectID1 = Guid.NewGuid().ToString("D");
            var subObjectID2 = Guid.NewGuid().ToString("D");
            var subObjectID3 = Guid.NewGuid().ToString("D");

            List<IdmResource> resources = null;

            var it = new IdmResource
            {
                Attributes =
                    new List<IdmAttribute> { new IdmAttribute { Name = "MultiValuedReferenceIDs", Values = new List<string> { subObjectID1, subObjectID2, subObjectID3 } } }
            };

            // ReSharper disable once ExpressionIsAlwaysNull
            var result = it.GetMultiValuedAttr("MultiValuedReferenceIDs", resources);

            Assert.AreEqual(subObjectID1, result[0].ObjectID);
            Assert.AreEqual(subObjectID2, result[1].ObjectID);
            Assert.AreEqual(subObjectID3, result[2].ObjectID);
        }
Esempio n. 4
0
        public void It_can_GetMultiValuedAttrAsComplexObjects_when_the_attribute_has_values_and_matches_backing_field()
        {
            var subObjectID1 = Guid.NewGuid().ToString("D");
            var subObjectID2 = Guid.NewGuid().ToString("D");

            var resources = new List<IdmResource>
            {
                new IdmResource
                {
                    CreatedTime = DateTime.Now,
                    Description = "Test resource",
                    DisplayName = "sub resource 1",
                    ExpirationTime = DateTime.Now + TimeSpan.FromDays(1),
                    MVObjectID = Guid.NewGuid().ToString("D"),
                    ObjectID = subObjectID1,
                    ObjectType = "Resource",
                    ResourceTime = DateTime.Now
                },
                new IdmResource
                {
                    CreatedTime = DateTime.Now,
                    Description = "Test resource",
                    DisplayName = "sub resource 2",
                    ExpirationTime = DateTime.Now + TimeSpan.FromDays(1),
                    MVObjectID = Guid.NewGuid().ToString("D"),
                    ObjectID = subObjectID2,
                    ObjectType = "Resource",
                    ResourceTime = DateTime.Now
                }

            };

            var it = new IdmResource
            {
                Attributes =
                    new List<IdmAttribute> { new IdmAttribute { Name = "MultiValuedReferenceIDs", Values = new List<string> { subObjectID1, subObjectID2 } } }
            };

            var result = it.GetMultiValuedAttr("MultiValuedReferenceIDs", resources);

            Assert.AreEqual("sub resource 1", result[0].DisplayName);
            Assert.AreEqual("sub resource 2", result[1].DisplayName);
        }