public void FullEntityGraphShapeTestCollectionAssociations() { A a = new A { B = new B() }; a.B.Cs = new List <C>() { new C() }; var shape = new FullEntityGraphShape(); var outedges = shape.OutEdges(a.B); Assert.IsTrue(outedges.Count() == 2); var collection = outedges.Single(x => x.Name == "Cs"); Assert.IsTrue(collection == typeof(B).GetProperty("Cs")); var graph = new EntityGraph <object>(a, shape); Assert.IsTrue(graph.Count() == 3); }
public void FullEntityGraphShapeTestMultiAssociations() { B b = new B(); var shape = new FullEntityGraphShape(); var outedges = shape.OutEdges(b); Assert.IsTrue(outedges.Count() == 2); }
public void CopyToArrayPropertyTest() { var shape = new FullEntityGraphShape(); var i = new I { X = new [] { 1.1, 2.2, 3.3 }, AString = "Hello" }; var result = shape.CopyTo <Entity, object>(i, new AssemblyTypeMapper <Test.I>()); Assert.IsTrue(result != null); Assert.IsTrue(result is Test.I); Assert.IsTrue(((Test.I)result).X.Count() == i.X.Count()); }
public void PartialSaveTest() { EntityGraphTestsDomainContext context = new EntityGraphTestsDomainContext(); var a = new A { Id = 1 }; var b = new B { Id = 1 }; context.As.Attach(a); context.Bs.Attach(b); context.Bs.Attach(new B { Id = 2, AId = 1 }); context.Bs.Attach(new B { Id = 3, AId = 1 }); a.name = "Modified Task 1"; EntityGraphTestsDomainContext tempContext = new EntityGraphTestsDomainContext(); var shape = new FullEntityGraphShape(); var graph = new EntityGraph(a, shape); Assert.IsTrue(context.HasChanges); Assert.IsTrue(graph.HasChanges); Assert.IsTrue(graph.IsChanged); var clone = graph.Clone(tempContext); Assert.IsTrue(tempContext.HasChanges); Assert.IsTrue(clone.HasChanges); Assert.IsTrue(clone.IsChanged); clone.AcceptChanges(); graph.Synchronize(clone); Assert.IsFalse(context.HasChanges); Assert.IsFalse(graph.HasChanges); Assert.IsFalse(graph.IsChanged); Assert.IsFalse(tempContext.HasChanges); Assert.IsFalse(clone.HasChanges); Assert.IsFalse(clone.IsChanged); }
public void FullEntityGraphShapeTestSingleAssociations() { A a = new A { B = new B() }; var shape = new FullEntityGraphShape(); var outedges = shape.OutEdges(a); Assert.IsTrue(outedges.Count() == 1); Assert.IsTrue(outedges.Single() == typeof(A).GetProperty("B")); var graph = new EntityGraph <object>(a, shape); Assert.IsTrue(graph.Count() == 2); }
public void FullEntityGraphShapeTestCycle() { A a = new A { B = new B() }; a.B.Cs = new List <C>() { new C { A = a } }; var shape = new FullEntityGraphShape(); var graph = new EntityGraph <object>(a, shape); Assert.IsTrue(graph.Count() == 3); }
public void CloneIntoDoesNotYieldKeyAlreadyExistsException() { EntityGraphTestsDomainContext context = new EntityGraphTestsDomainContext(); var a = new A { Id = 1 }; context.As.Attach(a); context.Bs.Attach(new B { Id = 1, AId = 1 }); context.Bs.Attach(new B { Id = 2, AId = 1 }); a.name = "Modified Task 1"; EntityGraphTestsDomainContext tempContext = new EntityGraphTestsDomainContext(); var shape = new FullEntityGraphShape(); // Clone should not raise an exception when instances of B are attached to tmpContext a.Clone(tempContext, shape); }