Beispiel #1
0
 public void Test7()
 {
     Func <int> func  = () => 2;
     var        paths = KnowledgeGraph
                        .StartFrom(123)
                        .VisitNode(_ => _.return_if(_.count("prop") > func() + Environment.ProcessorCount)).ToList();
 }
Beispiel #2
0
 public void Test12()
 {
     Func <string> string_func = () => "hey";
     var           paths       = KnowledgeGraph
                                 .StartFrom(123)
                                 .VisitNode(_ => _.return_if(_.GetField <string>(string_func()).Length > 3)).ToList();
 }
Beispiel #3
0
        public void Test14()
        {
            var dt = _get_datetime();

            var paths = KnowledgeGraph
                        .StartFrom(123)
                        .VisitNode(_ => _.return_if(_.GetField <DateTime>("prop") < dt)).ToList();
        }
Beispiel #4
0
        public void Test16()
        {
            FanoutSearch.Action a = FanoutSearch.Action.Continue, b = FanoutSearch.Action.Return;

            var paths = KnowledgeGraph.StartFrom(1).VisitNode(_ => a & b);

            paths.ToList();
        }
Beispiel #5
0
        public void Test3()
        {
            CustomClass closure_custom_var = new CustomClass();

            closure_custom_var.val = new CustomClass.NestedStruct()
            {
                val = true
            };
            var paths = KnowledgeGraph.StartFrom(123).FollowEdge("123").VisitNode(_ => _.return_if(closure_custom_var.val.val)).ToList();
        }
Beispiel #6
0
 public void Test5()
 {
     Func <int> func  = () => 2;
     var        paths = KnowledgeGraph
                        .StartFrom(123)
                        .FollowEdge("people_person_profession")
                        .FollowEdge("people_profession_people_with_this_profession")
                        .VisitNode(_ => _.return_if(_.count("prop") > func()), select: new List <string> {
         "type_object_name"
     }).ToList();
 }
Beispiel #7
0
        public void Test20()
        {
            try
            {
                KnowledgeGraph.StartFrom(0).VisitNode(_ => _.Do(() => _.SetField("foo", "bar")) & Action.Return).ToList();
            }
            catch (FanoutSearchQueryException ex)
            {
                Assert.True(ex.Message.Contains("Syntax error") && ex.Message.Contains("SetField"));
                return;
            }

            throw new Exception();
        }
Beispiel #8
0
        public void Test6()
        {
            Func <int, bool> func = cnt => cnt > 3;

            try
            {
                var paths = KnowledgeGraph.StartFrom(123).VisitNode(_ => _.return_if(func(_.count("prop")))).ToList();
            }
            catch
            {
                Console.WriteLine("Test6 throws expected exception.");
                /* Expected to throw exception due to entangled lambda expressions and non-evaluable parts. */
            }
        }
Beispiel #9
0
        IEnumerable <PathDescriptor> DoQuery(long origin, string property, int property_count_lowerbound)
        {
            Func <int> func = () => property_count_lowerbound;

            return(KnowledgeGraph
                   .StartFrom(origin)
                   .FollowEdge("people_person_profession")
                   .FollowEdge("people_profession_people_with_this_profession")
                   //.VisitNode(_ => _.return_if(_.count(property) > func()), select: new List<string> { "type_object_name" });
                   .VisitNode(_ => _.return_if(_.count(property) > property_count_lowerbound), select: new List <string> {
                "type_object_name"
            }));
            //.VisitNode(_ => _.return_if(_.count(property) > Environment.ProcessorCount), select: new List<string> { "type_object_name" });
        }
Beispiel #10
0
        public void Test18()
        {
            try
            {
                KnowledgeGraph.StartFrom(0).VisitNode(_ => _.Do(() => Console.WriteLine("Hey")) & Action.Return).ToList();
            }
            catch (FanoutSearchQueryException ex)
            {
                Assert.True(ex.Message.Contains("Referencing a type not allowed") && ex.Message.Contains("Console"));
                return;
            }

            throw new Exception();
        }
Beispiel #11
0
        public void Test19()
        {
            try
            {
                KnowledgeGraph.StartFrom(0).VisitNode(_ => _.Do(() => Global.LocalStorage.ResetStorage()) & Action.Return).ToList();
            }
            catch (FanoutSearchQueryException ex)
            {
                Assert.True(ex.Message.Contains("Referencing a type not allowed") && ex.Message.Contains("LocalMemoryStorage"));
                return;
            }

            throw new Exception();
        }
Beispiel #12
0
        public void Test17()
        {
            // long range traverse capability test
            var path = KnowledgeGraph.StartFrom(0);

            for (int hop = 1; hop <= 20; ++hop)
            {
                path = path.VisitNode(FanoutSearch.Action.Continue);
            }

            path = path.VisitNode(FanoutSearch.Action.Return);

            path.ToList();
        }
Beispiel #13
0
        public void Test15()
        {
            Global.LocalStorage.SaveMyCell(1, edges: new List <long> {
                2
            }, f1: 10);
            Global.LocalStorage.SaveMyCell(2, edges: new List <long> {
                1
            }, f1: 10);
            // conversion from float to decimal throws InvalidCastException.
            var paths = KnowledgeGraph
                        .StartFrom(1)
                        .VisitNode(_ => _.return_if(_.GetField <List <decimal> >("f1").Any(x => x > 0.1m))).ToList();

            Assert.True(paths.Count == 0);
        }
Beispiel #14
0
 public void Test4()
 {
     var paths = KnowledgeGraph.StartFrom(123).VisitNode(_ => _.return_if(_.CellId == 123)).ToList();
 }
Beispiel #15
0
 public void Test8()
 {
     var paths = KnowledgeGraph
                 .StartFrom(123)
                 .VisitNode(_ => _.Let(_.count("prop"), (i) => FanoutSearch.Action.Return)).ToList();
 }
Beispiel #16
0
 public void Test1()
 {
     bool closure_var = true;
     var  paths       = KnowledgeGraph.StartFrom(123).FollowEdge("123").VisitNode(_ => _.return_if(closure_var)).ToList();
 }
Beispiel #17
0
 public void Test9()
 {
     var paths = KnowledgeGraph
                 .StartFrom(123)
                 .VisitNode(_ => _.return_if(_.count("prop") > "123".Length)).ToList();
 }
Beispiel #18
0
 public void Test10()
 {
     var paths = KnowledgeGraph
                 .StartFrom(123)
                 .VisitNode(_ => _.return_if(_.GetField <string>("prop").Length > "123".Length)).ToList();
 }
Beispiel #19
0
 public void Test13()
 {
     var paths = KnowledgeGraph
                 .StartFrom(123)
                 .VisitNode(_ => _.return_if(_.GetField <List <string> >("prop").Any(str => str.Length > 3))).ToList();
 }