Ejemplo n.º 1
0
        public void ModelFuncExpressionVisitor_Property()
        {
            Expression <Func <Route, bool> > test = r => r.Entry != null && r.Entry.Signal == Signal.GO;

            var visitor = new ModelFuncExpressionVisitor();
            var visited = visitor.Visit(test.Body);

            Assert.AreEqual(0, visitor.ExtractParameters.Count);
            ParameterAssertions.AssertOnlyParameters(visited, test.Parameters[0]);
        }
Ejemplo n.º 2
0
        public void ModelFuncExpressionVisitor_NonModelProperty()
        {
            Expression <Func <Route, int> > test = r => r.AbsoluteUri.AbsoluteUri.Length;

            var visitor = new ModelFuncExpressionVisitor();
            var visited = visitor.Visit(test.Body);

            Assert.AreEqual(0, visitor.ExtractParameters.Count);
            ParameterAssertions.AssertOnlyParameters(visited, test.Parameters[0]);
        }
Ejemplo n.º 3
0
        public void ModelFuncExpressionVisitor_ModelMethod()
        {
            Expression<Func<Route, bool>> test = r => GetEntry(r) != null && GetEntry(r).Signal == Signal.GO;

            var visitor = new ModelFuncExpressionVisitor();
            var visited = visitor.Visit(test.Body);

            Assert.AreSame(test.Body, visited);
            Assert.AreEqual(0, visitor.ExtractParameters.Count);
            ParameterAssertions.AssertOnlyParameters(visited, test.Parameters[0]);
        }
Ejemplo n.º 4
0
        public void ModelFuncExpressionVisitor_ModelMethod()
        {
            Expression <Func <Route, bool> > test = r => GetEntry(r) != null && GetEntry(r).Signal == Signal.GO;

            var visitor = new ModelFuncExpressionVisitor();
            var visited = visitor.Visit(test.Body);

            Assert.AreSame(test.Body, visited);
            Assert.AreEqual(0, visitor.ExtractParameters.Count);
            ParameterAssertions.AssertOnlyParameters(visited, test.Parameters[0]);
        }
Ejemplo n.º 5
0
        public void ModelFuncExpressionVisitor_KeepParameterWhenNeeded()
        {
            Expression<Func<TestTuple, bool>> test = t => t.Route.Entry != null && t.Route.Entry.Signal == Signal.GO && t.Severity > 0;

            var visitor = new ModelFuncExpressionVisitor();
            var visited = visitor.Visit(test.Body);

            Assert.AreNotSame(test.Body, visited);
            Assert.AreEqual(1, visitor.ExtractParameters.Count);
            ParameterAssertions.AssertOnlyParameters(visited, test.Parameters[0], visitor.ExtractParameters.Single().Parameter);

            Assert.AreEqual("t.Route", visitor.ExtractParameters.Single().Value.ToString());
        }
Ejemplo n.º 6
0
        public void ModelFuncExpressionVisitor_InnerStruct()
        {
            Expression<Func<TestTuple2, bool>> test = t => t.Inner.Route.Entry != null && t.Inner.Route.Entry.Signal == Signal.GO;

            var visitor = new ModelFuncExpressionVisitor();
            var visited = visitor.Visit(test.Body);

            Assert.AreNotSame(test.Body, visited);
            Assert.AreEqual(1, visitor.ExtractParameters.Count);
            ParameterAssertions.AssertOnlyParameters(visited, visitor.ExtractParameters.Single().Parameter);

            Assert.AreEqual("t.Inner.Route", visitor.ExtractParameters.Single().Value.ToString());
        }
Ejemplo n.º 7
0
        public void ModelFuncExpressionVisitor_KeepParameterWhenNeeded()
        {
            Expression <Func <TestTuple, bool> > test = t => t.Route.Entry != null && t.Route.Entry.Signal == Signal.GO && t.Severity > 0;

            var visitor = new ModelFuncExpressionVisitor();
            var visited = visitor.Visit(test.Body);

            Assert.AreNotSame(test.Body, visited);
            Assert.AreEqual(1, visitor.ExtractParameters.Count);
            ParameterAssertions.AssertOnlyParameters(visited, test.Parameters[0], visitor.ExtractParameters.Single().Parameter);

            Assert.AreEqual("t.Route", visitor.ExtractParameters.Single().Value.ToString());
        }
Ejemplo n.º 8
0
        public void ModelFuncExpressionVisitor_InnerStruct()
        {
            Expression <Func <TestTuple2, bool> > test = t => t.Inner.Route.Entry != null && t.Inner.Route.Entry.Signal == Signal.GO;

            var visitor = new ModelFuncExpressionVisitor();
            var visited = visitor.Visit(test.Body);

            Assert.AreNotSame(test.Body, visited);
            Assert.AreEqual(1, visitor.ExtractParameters.Count);
            ParameterAssertions.AssertOnlyParameters(visited, visitor.ExtractParameters.Single().Parameter);

            Assert.AreEqual("t.Inner.Route", visitor.ExtractParameters.Single().Value.ToString());
        }
Ejemplo n.º 9
0
        public void ModelFuncExpressionVisitor_ModelNonModelMethod()
        {
            Expression <Func <TestTuple, bool> > test = t => GetEntry(GetRoute(t)) != null && GetEntry(GetRoute(t)).Signal == Signal.GO;

            var visitor = new ModelFuncExpressionVisitor();
            var visited = visitor.Visit(test.Body);

            Assert.AreNotSame(visited, test.Body);
            Assert.AreEqual(1, visitor.ExtractParameters.Count);
            ParameterAssertions.AssertOnlyParameters(visited, visitor.ExtractParameters.Single().Parameter);

            Assert.AreEqual("GetRoute(t)", visitor.ExtractParameters.Single().Value.ToString());
        }
Ejemplo n.º 10
0
        public void ModelFuncExpressionVisitor_ModelNonModelMethod()
        {
            Expression<Func<TestTuple, bool>> test = t => GetEntry(GetRoute(t)) != null && GetEntry(GetRoute(t)).Signal == Signal.GO;

            var visitor = new ModelFuncExpressionVisitor();
            var visited = visitor.Visit(test.Body);

            Assert.AreNotSame(visited, test.Body);
            Assert.AreEqual(1, visitor.ExtractParameters.Count);
            ParameterAssertions.AssertOnlyParameters(visited, visitor.ExtractParameters.Single().Parameter);

            Assert.AreEqual("GetRoute(t)", visitor.ExtractParameters.Single().Value.ToString());
        }
Ejemplo n.º 11
0
        public void ModelFuncExpressionVisitor_Property()
        {
            Expression<Func<Route, bool>> test = r => r.Entry != null && r.Entry.Signal == Signal.GO;

            var visitor = new ModelFuncExpressionVisitor();
            var visited = visitor.Visit(test.Body);

            Assert.AreEqual(0, visitor.ExtractParameters.Count);
            ParameterAssertions.AssertOnlyParameters(visited, test.Parameters[0]);
        }
Ejemplo n.º 12
0
        public void ModelFuncExpressionVisitor_NonModelProperty()
        {
            Expression<Func<Route, int>> test = r => r.AbsoluteUri.AbsoluteUri.Length;

            var visitor = new ModelFuncExpressionVisitor();
            var visited = visitor.Visit(test.Body);

            Assert.AreEqual(0, visitor.ExtractParameters.Count);
            ParameterAssertions.AssertOnlyParameters(visited, test.Parameters[0]);
        }