public void Can_access_child_property() { var data = new DataGraph { Readonly = { Id = 42, Name = "Everything" } }; var freezable = Freezer.AsFreezable(data); AssertSameValue(data, freezable); }
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); }
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()); }
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)); }
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); }
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; }
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); }
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" })); }
private DataGraph CreateData() { return(Freezer.AsFreezable(new DataGraph { Readonly = { Id = 42, Name = "Everything" } })); }