public void Test() { var counter = 0; var baseVertex = new TypeVertex(typeof(IBase), counter++); var a = new TypeVertex(typeof(IA), counter++); var propBaseA1 = typeof(IBase).GetProperty("A1"); var propBaseA2 = typeof(IBase).GetProperty("A2"); var basea1 = new PropertyEdge(baseVertex, propBaseA1, a); var basea2 = new PropertyEdge(baseVertex, propBaseA2, a); var expectedGraph = GetGraphArray(baseVertex, a); //// IBase -> [{IBase.A1, IA}, {IBase.A2, IA}] //// ~> [IA] //// //// IA -> [] //// ~> [IBase] expectedGraph[baseVertex.Index].Children.AddRange(new[] { basea1, basea2 }); expectedGraph[baseVertex.Index].Casts.AddLast(new CastEdge(baseVertex, a)); expectedGraph[a.Index].Parents.AddRange(new[] { basea1, basea2 }); expectedGraph[a.Index].Casts.AddLast(new CastEdge(a, baseVertex)); var typeGraph = BuildTypeGraph <IBase>(); Assert.True(IsEqual(expectedGraph, typeGraph.Vertices)); }
public void Test() { var counter = 0; var baseVertex = new TypeVertex(typeof(IBase), counter++); var a = new TypeVertex(typeof(IA), counter++); var b = new TypeVertex(typeof(IB), counter++); var c = new TypeVertex(typeof(IC), counter++); var d = new TypeVertex(typeof(ID), counter++); var propAC = typeof(IA).GetProperty("C"); var propCD = typeof(IC).GetProperty("D"); var ac = new PropertyEdge(a, propAC, c); var cd = new PropertyEdge(c, propCD, d); var expectedGraph = GetGraphArray(baseVertex, a, b, c, d); //// IBase -> [] //// ~> [IA, IB, IC, ID] //// //// IA -> [{IA.C, IC}] //// ~> [IBase] //// //// IB -> [] //// ~> [IBase, IC] //// //// IC -> [{IC.D, ID}] //// ~> [IBase, IB] //// //// ID -> [] //// ~> [IBase] expectedGraph[baseVertex.Index].Casts.AddRange(new[] { new CastEdge(baseVertex, a), new CastEdge(baseVertex, b), new CastEdge(baseVertex, c), new CastEdge(baseVertex, d) }); expectedGraph[a.Index].Children.AddLast(ac); expectedGraph[a.Index].Casts.AddLast(new CastEdge(a, baseVertex)); expectedGraph[b.Index].Casts.AddLast(new CastEdge(b, baseVertex)); expectedGraph[b.Index].Casts.AddLast(new CastEdge(b, c)); expectedGraph[c.Index].Parents.AddLast(ac); expectedGraph[c.Index].Children.AddLast(cd); expectedGraph[c.Index].Casts.AddLast(new CastEdge(c, baseVertex)); expectedGraph[c.Index].Casts.AddLast(new CastEdge(c, b)); expectedGraph[d.Index].Parents.AddLast(cd); expectedGraph[d.Index].Casts.AddLast(new CastEdge(d, baseVertex)); var typeGraph = BuildTypeGraph <IBase>(); Assert.True(IsEqual(expectedGraph, typeGraph.Vertices)); }
public void Test() { var counter = 0; var baseVertex = new TypeVertex(typeof(IBase), counter++); var a = new TypeVertex(typeof(IA), counter++); var b = new TypeVertex(typeof(IB), counter++); var c = new TypeVertex(typeof(IC), counter++); var propAB = typeof(IA).GetProperty("B"); var propBC = typeof(IB).GetProperty("C"); var propCA = typeof(IC).GetProperty("A"); var ab = new PropertyEdge(a, propAB, b); var bc = new PropertyEdge(b, propBC, c); var ca = new PropertyEdge(c, propCA, a); var expectedGraph = GetGraphArray(baseVertex, a, b, c); //// IBase -> [] //// ~> [IA, IB, IC] //// //// IA -> [{IA.B, IB}] //// ~> [IBase] //// //// IB -> [{IB.C, IC}] //// ~> [IBase] //// //// IC -> [{IC.A, IA}] //// ~> [IBase] expectedGraph[baseVertex.Index].Casts.AddRange(new[] { new CastEdge(baseVertex, a), new CastEdge(baseVertex, b), new CastEdge(baseVertex, c) }); expectedGraph[a.Index].Parents.AddLast(ca); expectedGraph[a.Index].Children.AddLast(ab); expectedGraph[a.Index].Casts.AddLast(new CastEdge(a, baseVertex)); expectedGraph[b.Index].Parents.AddLast(ab); expectedGraph[b.Index].Children.AddLast(bc); expectedGraph[b.Index].Casts.AddLast(new CastEdge(b, baseVertex)); expectedGraph[c.Index].Parents.AddLast(bc); expectedGraph[c.Index].Children.AddLast(ca); expectedGraph[c.Index].Casts.AddLast(new CastEdge(c, baseVertex)); var typeGraph = BuildTypeGraph <IBase>(); Assert.True(IsEqual(expectedGraph, typeGraph.Vertices)); }