Exemplo n.º 1
0
        public void TestLineSegment_Unify_Reify_0()
        {
            /*
            * Input sequence:
            * 1: (AB) [LineSegment]  => LineSegment
            * 2: A(2,3)          => Point
            * 3: B(2,3)          => Point
            * Update: AB [Label] => LineSegment
            */
             var graph = new RelationGraph();

             var ptA = new Point("A", 2, 3);
             var ptASym = new PointSymbol(ptA);
             graph.AddNode(ptASym); //api call
             Assert.True(graph.Nodes.Count == 1);

             var query = new Query(ShapeType.LineSegment);
             var queryNode = graph.AddNode(query) as QueryNode;
             Assert.Null(queryNode);

             var ptB = new Point("B", 3, 4);
             var PtBSym = new PointSymbol(ptB);
             graph.AddNode(PtBSym); //api call
             Assert.True(graph.Nodes.Count == 3);

             queryNode = graph.RetrieveQueryNode(query);
             Assert.NotNull(queryNode);
        }
        public void TestLineSegment_Unify_Reify_0()
        {
            /*
             * Input sequence:
             * 1: (AB) [LineSegment]  => LineSegment
             * 2: A(2,3)          => Point
             * 3: B(2,3)          => Point
             * Update: AB [Label] => LineSegment
             */
            var graph = new RelationGraph();

            var ptA    = new Point("A", 2, 3);
            var ptASym = new PointSymbol(ptA);

            graph.AddNode(ptASym);  //api call
            Assert.True(graph.Nodes.Count == 1);

            var query     = new Query(ShapeType.LineSegment);
            var queryNode = graph.AddNode(query) as QueryNode;

            Assert.Null(queryNode);

            var ptB    = new Point("B", 3, 4);
            var PtBSym = new PointSymbol(ptB);

            graph.AddNode(PtBSym);  //api call
            Assert.True(graph.Nodes.Count == 3);

            queryNode = graph.RetrieveQueryNode(query);
            Assert.NotNull(queryNode);
        }
Exemplo n.º 3
0
        public void TestLine_Unify_Reify_2()
        {
            /* 
             * (2,x), (3,4)
             * line pass through two points
             */

            var graph = new RelationGraph();
            var x = new Var('x');
            var point = new Point(2, x);
            var ps = new PointSymbol(point);
            var point1 = new Point(3, 4);
            var ps1 = new PointSymbol(point1);
            graph.AddNode(ps);
            graph.AddNode(ps1);

            var query = new Query(ShapeType.Line);
            var queryNode = graph.AddNode(query) as QueryNode;
            Assert.NotNull(queryNode);
            Assert.True(queryNode.InternalNodes.Count == 1);
            Assert.True(query.Success);
            Assert.True(query.CachedEntities.Count == 1);
            var cachedLine = query.CachedEntities.ToList()[0] as LineSymbol;
            Assert.NotNull(cachedLine);
            Assert.True(cachedLine.CachedSymbols.Count == 0);

            var eqGoal = new EqGoal(x, 1); // x=2
            graph.AddNode(eqGoal);

            queryNode = graph.RetrieveQueryNode(query);
            Assert.NotNull(queryNode);
            Assert.True(queryNode.InternalNodes.Count == 1);
            Assert.True(query.Success);
            Assert.True(query.CachedEntities.Count == 1);
            cachedLine = query.CachedEntities.ToList()[0] as LineSymbol;
            Assert.NotNull(cachedLine);
         
            var eqGoal2 = new EqGoal(x, 2); // x=2
            graph.AddNode(eqGoal2);
            queryNode = graph.RetrieveQueryNode(query);
            Assert.NotNull(queryNode);
            Assert.True(queryNode.InternalNodes.Count == 1);
            Assert.True(query.Success);
            Assert.True(query.CachedEntities.Count == 2);
            cachedLine = query.CachedEntities.ToList()[0] as LineSymbol;
            Assert.NotNull(cachedLine);


/*            graph.DeleteNode(eqGoal2);
            queryNode = graph.RetrieveQueryNode(query);
            Assert.NotNull(queryNode);
            Assert.True(queryNode.InternalNodes.Count == 1);
            Assert.True(query.Success);
            Assert.True(query.CachedEntities.Count == 1);
            cachedLine = query.CachedEntities.ToList()[0] as LineSymbol;
            Assert.NotNull(cachedLine);
            Assert.True(cachedLine.CachedSymbols.Count == 1);
            Assert.True(graph.Nodes.Count == 4);

            graph.DeleteNode(eqGoal);
            queryNode = graph.RetrieveQueryNode(query);
            Assert.NotNull(queryNode);
            Assert.True(queryNode.InternalNodes.Count == 1);
            Assert.True(query.Success);
            Assert.True(query.CachedEntities.Count == 1);
            cachedLine = query.CachedEntities.ToList()[0] as LineSymbol;
            Assert.NotNull(cachedLine);
            Assert.True(cachedLine.CachedSymbols.Count == 0);
            Assert.True(graph.Nodes.Count == 3);*/

        }