Пример #1
0
        public void Can_access_child_property()
        {
            var data = new DataGraph {
                Readonly = { Id = 42, Name = "Everything" }
            };
            var freezable = Freezer.AsFreezable(data);

            AssertSameValue(data, freezable);
        }
Пример #2
0
        public void Frozen_DtoWithValueList_throws_on_remove()
        {
            var dto = Freezer.AsFreezable(new DtoWithValueList()
            {
                Values = new[] { 1, 2, 3 }
            });

            Freezer.Freeze(dto);
            dto.Values.Remove(2);
        }
Пример #3
0
        public void Can_freeze_and_access_DtoWithValueEnumerable()
        {
            var dto = Freezer.AsFreezable(new DtoWithValueEnumerable()
            {
                Values = new[] { 1, 2, 3 }
            });

            Freezer.Freeze(dto);
            Assert.AreEqual(1, dto.Values.First());
        }
Пример #4
0
        public void Frozen_DtoWithValueCollection_throws_on_remove()
        {
            var dto = Freezer.AsFreezable(new DtoWithValueCollection()
            {
                Values = new List <int>(new[] { 1, 2, 3 })
            });

            Freezer.Freeze(dto);
            dto.Values.Remove(2);
        }
        public void Can_call_methods_on_wrapped_instance()
        {
            var data = new FreezableData()
            {
                Id = 42, Name = "Everything"
            };
            var data2 = Freezer.AsFreezable(data);

            Assert.IsTrue(data2.IsA <Freezer.IFreezableWrapper>());
            AssertSameValue(data, data2);
        }
        public void Can_detect_wrapped_instances()
        {
            var data = new FreezableData()
            {
                Id = 42, Name = "Everything"
            };

            Assert.IsFalse(Freezer.IsFreezable(data));
            var data2 = Freezer.AsFreezable(data);

            Assert.IsTrue(Freezer.IsFreezable(data2));
        }
Пример #7
0
        public void Can_freeze_and_access_DtoWithObjectList()
        {
            var dto = Freezer.AsFreezable(new DtoWithObjectList()
            {
                Id       = 1,
                Children = new[] { new DtoWithObjectList()
                                   {
                                       Id = 2, Children = new[] { new DtoWithObjectList() }
                                   } }
            });

            Freezer.Freeze(dto);
            Assert.AreEqual(2, dto.Children[0].Id);
        }
Пример #8
0
        public void Frozen_DtoWithObjectEnumerable_throws_on_mod_item()
        {
            var dto = Freezer.AsFreezable(new DtoWithObjectEnumerable()
            {
                Id       = 1,
                Children = new[] { new DtoWithObjectEnumerable()
                                   {
                                       Id = 2, Children = new[] { new DtoWithObjectEnumerable() }
                                   } }
            });

            Freezer.Freeze(dto);
            var c = dto.Children.First();

            c.Id = 5;
        }
Пример #9
0
        public void Frozen_DtoWithObjectCollection_throws_on_remove()
        {
            var dto = Freezer.AsFreezable(new DtoWithObjectCollection()
            {
                Id       = 1,
                Children = new[] { new DtoWithObjectCollection()
                                   {
                                       Id = 2, Children = new[] { new DtoWithObjectCollection() }
                                   } }
            });

            Freezer.Freeze(dto);
            var c = dto.Children.First();

            dto.Children.Remove(c);
        }
Пример #10
0
        public void Frozen_DtoWithObjectList_throws_on_add()
        {
            var dto = Freezer.AsFreezable(new DtoWithObjectList()
            {
                Id       = 1,
                Children = new[] { new DtoWithObjectList()
                                   {
                                       Id = 2, Children = new[] { new DtoWithObjectList() }
                                   } }
            });

            Freezer.Freeze(dto);
            dto.Children.Add(new DtoWithObjectList()
            {
                Id = 10
            });
        }
 private FreezableData CreateData()
 {
     return(Freezer.AsFreezable(new FreezableData {
         Id = 42, Name = "Everything"
     }));
 }
Пример #12
0
 private DataGraph CreateData()
 {
     return(Freezer.AsFreezable(new DataGraph {
         Readonly = { Id = 42, Name = "Everything" }
     }));
 }