public void TestPoint_Unify_Reify_0() { var graph = new RelationGraph(); //true positive var x = new Var('x'); var y = new Var('y'); var point = new Point(x, y); var ps = new PointSymbol(point); graph.AddNode(ps); Assert.True(graph.Nodes.Count == 1); /* * * Current Status: * * (x,y) * * next input: * * x=1 */ var eqGoal = new EqGoal(x, 1); // x=1 graph.AddNode(eqGoal); Assert.True(graph.Nodes.Count == 2); List <ShapeSymbol> shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); var pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.True(pt.Equals(ps)); Assert.True(pt.CachedGoals.Count == 1); Assert.True(pt.CachedSymbols.Count == 1); var gPointSymbol = pt.CachedSymbols.ToList()[0] as PointSymbol; Assert.NotNull(gPointSymbol); var gPoint = gPointSymbol.Shape as Point; Assert.NotNull(gPoint); Assert.False(gPoint.Concrete); Assert.True(1.0.Equals(gPoint.XCoordinate)); Assert.True(y.Equals(gPoint.YCoordinate)); /****** * current status: * (1,y) * * next input: * x = 2 ****/ #region Block 2 var eqGoal1 = new EqGoal(x, 2); // x=2 graph.AddNode(eqGoal1); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.True(pt.Equals(ps)); Assert.True(pt.CachedGoals.Count == 2); Assert.True(pt.CachedSymbols.Count == 2); Assert.False(point.Concrete); #endregion /****** * current status: * (1,y) * (2,y) * * next input: * y = 1 ****/ #region Block 3 var eqGoal2 = new EqGoal(y, 1); // y = 1 graph.AddNode(eqGoal2); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.False(point.Concrete); Assert.True(ps.CachedGoals.Count == 3); Assert.True(ps.CachedSymbols.Count == 2); foreach (var ss in ps.CachedSymbols) { Assert.True(ss.Shape.Concrete); } var goals = graph.RetrieveGoals(); Assert.True(goals.Count == 3); #endregion /****** * current status: * (1,1) * (2,1) * * next input: * y = 2 ****/ #region Block 4 var eqGoal3 = new EqGoal(y, 2); // y = 2 graph.AddNode(eqGoal3); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); ps = shapes[0] as PointSymbol; Assert.NotNull(ps); Assert.False(ps.Shape.Concrete); Assert.True(ps.CachedGoals.Count == 4); Assert.True(ps.CachedSymbols.Count == 4); foreach (var css in ps.CachedSymbols) { Assert.True(css.Shape.Concrete); } #endregion /* * current status: * (1,1), (2,1), (1,2), (2,2) * * next input: * delete y = 2 * */ #region Block 5 graph.DeleteNode(eqGoal3); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.False(pt.Shape.Concrete); Assert.True(pt.CachedGoals.Count == 3); Assert.True(pt.CachedSymbols.Count == 2); foreach (var ss in pt.CachedSymbols) { Assert.True(ss.Shape.Concrete); } goals = graph.RetrieveGoals(); Assert.True(goals.Count == 3); #endregion /* * current status: * (1,1), (2,1) * * next input: * delete y = 1 * */ #region Block 6 graph.DeleteNode(eqGoal2); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.False(pt.Shape.Concrete); Assert.True(pt.CachedGoals.Count == 3); Assert.True(pt.CachedSymbols.Count == 2); #endregion /* foreach (var shape in pt.CachedSymbols) * { * Assert.False(shape.Shape.Concrete); * } * goals = graph.RetrieveGoals(); * Assert.True(goals.Count == 2); * * * ///////////////////////////////////////////// * * graph.DeleteNode(ps); * shapes = graph.RetrieveShapeSymbols(); * Assert.True(shapes.Count == 0);*/ }
public void TestPoint_Unify_Reify_0() { var graph = new RelationGraph(); //true positive var x = new Var('x'); var y = new Var('y'); var point = new Point(x, y); var ps = new PointSymbol(point); graph.AddNode(ps); Assert.True(graph.Nodes.Count == 1); /* * * Current Status: * * (x,y) * * next input: * * x=1 */ var eqGoal = new EqGoal(x, 1); // x=1 graph.AddNode(eqGoal); Assert.True(graph.Nodes.Count == 2); List<ShapeSymbol> shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); var pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.True(pt.Equals(ps)); Assert.True(pt.CachedGoals.Count == 1); Assert.True(pt.CachedSymbols.Count == 1); var gPointSymbol = pt.CachedSymbols.ToList()[0] as PointSymbol; Assert.NotNull(gPointSymbol); var gPoint = gPointSymbol.Shape as Point; Assert.NotNull(gPoint); Assert.False(gPoint.Concrete); Assert.True(1.0.Equals(gPoint.XCoordinate)); Assert.True(y.Equals(gPoint.YCoordinate)); /****** * current status: * (1,y) * * next input: * x = 2 ****/ #region Block 2 var eqGoal1 = new EqGoal(x, 2); // x=2 graph.AddNode(eqGoal1); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.True(pt.Equals(ps)); Assert.True(pt.CachedGoals.Count == 2); Assert.True(pt.CachedSymbols.Count == 2); Assert.False(point.Concrete); #endregion /****** * current status: * (1,y) * (2,y) * * next input: * y = 1 ****/ #region Block 3 var eqGoal2 = new EqGoal(y, 1); // y = 1 graph.AddNode(eqGoal2); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.False(point.Concrete); Assert.True(ps.CachedGoals.Count == 3); Assert.True(ps.CachedSymbols.Count == 2); foreach (var ss in ps.CachedSymbols) { Assert.True(ss.Shape.Concrete); } var goals = graph.RetrieveGoals(); Assert.True(goals.Count == 3); #endregion /****** * current status: * (1,1) * (2,1) * * next input: * y = 2 ****/ #region Block 4 var eqGoal3 = new EqGoal(y, 2); // y = 2 graph.AddNode(eqGoal3); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); ps = shapes[0] as PointSymbol; Assert.NotNull(ps); Assert.False(ps.Shape.Concrete); Assert.True(ps.CachedGoals.Count == 4); Assert.True(ps.CachedSymbols.Count == 4); foreach (var css in ps.CachedSymbols) { Assert.True(css.Shape.Concrete); } #endregion /* * current status: * (1,1), (2,1), (1,2), (2,2) * * next input: * delete y = 2 * */ #region Block 5 graph.DeleteNode(eqGoal3); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.False(pt.Shape.Concrete); Assert.True(pt.CachedGoals.Count == 3); Assert.True(pt.CachedSymbols.Count == 2); foreach (var ss in pt.CachedSymbols) { Assert.True(ss.Shape.Concrete); } goals = graph.RetrieveGoals(); Assert.True(goals.Count == 3); #endregion /* * current status: * (1,1), (2,1) * * next input: * delete y = 1 * */ #region Block 6 graph.DeleteNode(eqGoal2); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.False(pt.Shape.Concrete); Assert.True(pt.CachedGoals.Count == 3); Assert.True(pt.CachedSymbols.Count == 2); #endregion /* foreach (var shape in pt.CachedSymbols) { Assert.False(shape.Shape.Concrete); } goals = graph.RetrieveGoals(); Assert.True(goals.Count == 2); ///////////////////////////////////////////// graph.DeleteNode(ps); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 0);*/ }