public void ParseStaticExpression()
        {
            var action = CallAction.Let <TestActionObject>("v1", null, _ => TestActionObject.Method1());

            action.Should().SaveTo("v1");
            action.Should().CallStatic(typeof(TestActionObject), "Method1");
            action.Should().HaveNoParameters();
        }
        public void VariableParameter()
        {
            var action = CallAction.Let <TestActionObject>("v1", null, _ => TestActionObject.Duplicate((new Variable <int>("a")).Value));

            action.Should().SaveTo("v1")
            .And.CallStatic <TestActionObject>("Duplicate")
            .And.HaveParametersCount(1)
            .And.HaveVariableParameterN <int>(0, "a");
        }
        public void NullParameter()
        {
            var action = CallAction.Let <TestActionObject>("v1", null, _ => TestActionObject.Stringize(null));

            action.Should().SaveTo("v1")
            .And.CallStatic <TestActionObject>("Stringize")
            .And.HaveParametersCount(1)
            .And.HaveNullParameterN(0);
        }
        public void CalculateParameterFromConstants()
        {
            var action = CallAction.Let <TestActionObject>("v1", null, _ => TestActionObject.Duplicate(10 + 5));

            action.Should().SaveTo("v1")
            .And.CallStatic <TestActionObject>("Duplicate")
            .And.HaveParametersCount(1)
            .And.HaveParameterN(0, 15);
        }
        public void CalculateParameterFromExternals()
        {
            const int a      = 10;
            const int b      = 5;
            var       action = CallAction.Let <TestActionObject>("v1", null, _ => TestActionObject.Duplicate(a + b));

            action.Should().SaveTo("v1")
            .And.CallStatic <TestActionObject>("Duplicate")
            .And.HaveParametersCount(1)
            .And.HaveParameterN(0, 15);
        }
        public void ParseParameters()
        {
            var action = CallAction.Let <TestActionObject>("v1", null, _ => TestActionObject.Formula(10, 20, 5));

            action.Should().SaveTo("v1")
            .And.CallStatic <TestActionObject>("Formula")
            .And.HaveParametersCount(3)
            .And.HaveParameterN(0, 10)
            .And.HaveParameterN(1, 20)
            .And.HaveParameterN(2, 5);
        }
Esempio n. 7
0
        public void InstanceCallWithOtherType()
        {
            TestActionObject.Method1Called = false;
            Variables        variables = new Variables();
            TestActionObject tc        = new TestActionObject();

            variables["v1"] = tc;

            var action = CallAction.Let("v2", "v1", "Stringize", 10);

            action.Execute(variables);

            variables["v2"].Should().BeOfType <string>();
            variables["v2"].Should().Be("10");
        }
Esempio n. 8
0
        public void InstanceCall()
        {
            TestActionObject.Method1Called = false;
            Variables        variables = new Variables();
            TestActionObject tc        = new TestActionObject();

            variables["v1"] = tc;

            var action = CallAction.Let("v2", "v1", "Method2");

            action.Execute(variables);

            tc.Method2Called.Should().BeTrue();
            variables["v2"].Should().BeOfType <int>();
            variables["v2"].Should().Be(5);
        }