/// <summary> /// Contains the Service, ServiceTemplate, and Fields /// </summary> public EntityGraph<Entity> EntityGraph() { var graphShape = new EntityGraphShape().Edge<Service, ServiceTemplate>(service => service.ServiceTemplate) .Edge<ServiceTemplate, Field>(st => st.Fields); return new EntityGraph<Entity>(this, graphShape); }
public void CopyWithSelfReferenceTest() { var testClass = new SelfReferenceTestClass(); testClass.SelfReference = testClass; Assert.IsTrue(testClass == testClass.SelfReference); var shape = new EntityGraphShape().Edge <SelfReferenceTestClass, SelfReferenceTestClass>(c => c.SelfReference); var copy = testClass.Copy(shape); Assert.IsTrue(copy == copy.SelfReference); Assert.IsTrue(copy.EntityGraph(shape).IsCopyOf(testClass.EntityGraph(shape))); }
public void CopyToTest2() { var shape = new EntityGraphShape().Edge <G, GH>(x => x.GHSet); var g = new G(); g.GHSet.Add(new GH()); var result = shape.CopyTo <Entity, object>(g, new AssemblyTypeMapper <Test.E>()); Assert.IsTrue(result != null); Assert.IsTrue(result is Test.G); Assert.IsTrue(((Test.G)result).GHSet.Count() == g.GHSet.Count()); }
public void CopyToTest1() { var shape = new EntityGraphShape().Edge <G, GH>(x => x.GHSet); var g = new Test.G { GHSet = new List <Test.GH> { new Test.GH() } }; var result = shape.CopyTo <object, Entity>(g, new AssemblyTypeMapper <H>()); Assert.IsTrue(result != null); Assert.IsTrue(result is G); Assert.IsTrue(((G)result).GHSet.Count() == g.GHSet.Count()); }
public void InvalidPathExpressionTest2() { bool isValidExpression = true; try { var shape = new EntityGraphShape() .Edge <A, B>(A => A.BSet.First()); } catch (Exception) { isValidExpression = false; } Assert.IsFalse(isValidExpression); }
public void CopyNotEqualGraphShapeTests() { var shape = new EntityGraphShape() .Edge <A, B>(A => A.B) .Edge <A, D>(A => A.DSet) .Edge <A, B>(A => A.BSet); var copy1 = a.Copy(shape); var copy2 = a.Copy(EntityGraphs.CircularGraphFull); var gr1 = copy1.EntityGraph(EntityGraphs.CircularGraphFull); var gr2 = copy2.EntityGraph(EntityGraphs.CircularGraphFull); Assert.IsFalse(gr1.IsCopyOf(gr2)); }
public void CopyEqualGraphShapeTests() { var shape = new EntityGraphShape() .Edge <A, B>(A => A.B) .Edge <B, C>(B => B.C) .Edge <C, D>(C => C.D) .Edge <A, B>(A => A.BSet); var copy1 = a.Copy(shape); var copy2 = a.Copy(EntityGraphs.CircularGraphFull); var gr1 = copy1.EntityGraph(EntityGraphs.CircularGraphFull); var gr2 = copy2.EntityGraph(EntityGraphs.CircularGraphFull); Assert.IsTrue(gr1.IsCopyOf(gr2)); }
public void SimpleGraphShapeTests() { var newB = new B { name = "NewB" }; a.BSet.Add(newB); var shape = new EntityGraphShape() .Edge <A, B>(A => A.B) .Edge <A, B>(A => A.BSet); var gr = a.EntityGraph(shape); Assert.IsTrue(gr.Contains(a)); Assert.IsTrue(gr.Contains(b)); Assert.IsTrue(gr.Contains(newB)); }
public void EntitiyGraphShapeUnionTest() { var shape1 = new EntityGraphShape() .Edge <A, D>(A => A.DSet) .Edge <A, B>(A => A.B); var shape2 = new EntityGraphShape() .Edge <A, D>(A => A.DSet) .Edge <A, B>(A => A.B) .Edge <C, D>(C => C.D); var shape3 = shape1.Union(shape2); Assert.IsTrue(shape1.All(edge => shape3.Contains(edge))); Assert.IsTrue(shape2.All(edge => shape2.Contains(edge))); Assert.IsFalse(shape3.Any(edge => shape1.Contains(edge) == false && shape2.Contains(edge) == false)); Assert.IsTrue(shape3.Count() == 3); }
public void FactoryTest() { A a1 = new A(); A a2 = new A(); var shape1 = new EntityGraphShape(); var shape2 = new EntityGraphShape(); var gr1 = EntityGraphFactory.Get(a1, shape1); var gr2 = EntityGraphFactory.Get(a1, shape2); var gr3 = EntityGraphFactory.Get(a2, shape1); var gr4 = EntityGraphFactory.Get(a2, shape2); var gr5 = EntityGraphFactory.Get(a1, shape1); Assert.IsTrue(gr1 == gr5); Assert.IsFalse(gr1 == gr2); Assert.IsFalse(gr1 == gr3); Assert.IsFalse(gr1 == gr4); Assert.IsFalse(gr2 == gr3); Assert.IsFalse(gr2 == gr4); Assert.IsFalse(gr3 == gr4); }
public EntityGraphShapeOverlay(Graph source, EntityGraphShape shape) : base(source) { EntityGraphShape = shape; }