Ejemplo n.º 1
0
        public void ConvertFromString(int i, float f, double d, bool isTrue, string text, double2 d2, double3 d3, double4 d4, double4x4 d4x4, float2 f2, float3 f3, float4 f4, float4x4 f4x4)
        {
            ConverterClass source   = new ConverterClass();
            ConverterClass expected = new ConverterClass();
            Node           root     = new Node(source);
            Node           node     = new Node(expected);
            Circuit        circuit  = new Circuit();

            circuit.AddNode(root);
            circuit.AddNode(node);
            circuit.AddRoot(root);

            source.text = text;

            root.Attach("text", node, "i");
            root.Attach("text", node, "f");
            root.Attach("text", node, "d");
            root.Attach("text", node, "text");

            circuit.Execute();

            Assert.True(expected.i == i, "Error when parsing to int: Should be " + i + " but is " + expected.i + ".");
            Assert.True(expected.f == f, "Error when parsing to float: Should be " + f + " but is " + expected.f + ".");
            Assert.True(expected.d == d, "Error when parsing to double: Should be " + d + " but is " + expected.d + ".");
            Assert.True(expected.text == text, "Error when parsing to string: Should be " + text + " but is " + expected.text + ".");
        }
Ejemplo n.º 2
0
        public void NestedProperties()
        {
            var src     = new CNodeOb();
            var srcNode = new Node(src);

            var dst     = new CNodeOb();
            var dstNode = new Node(dst);

            var circuit = new Circuit();

            circuit.AddRoot(srcNode);
            circuit.AddNode(dstNode);

            // Nested -> Simple field
            src.Outer.Inner.Text = "Some Text";
            srcNode.Attach("Outer.Inner.Text", dstNode, "Txt");

            // Simple Field -> Nested
            src.Num = 42;
            srcNode.Attach("Num", dstNode, "Outer.Inner.Number");

            circuit.Execute();

            Assert.Equal("Some Text", dst.Txt);
            Assert.Equal(42, dst.Outer.Inner.Number);
        }
Ejemplo n.º 3
0
        public void ConvertFromFloat4x4(int i, float f, double d, bool isTrue, string text, double2 d2, double3 d3, double4 d4, double4x4 d4x4, float2 f2, float3 f3, float4 f4, float4x4 f4x4)
        {
            text = f4x4.ToString();
            d4   = d4x4.Row0;
            f4   = f4x4.Row0;

            ConverterClass source   = new ConverterClass();
            ConverterClass expected = new ConverterClass();
            Node           root     = new Node(source);
            Node           node     = new Node(expected);
            Circuit        circuit  = new Circuit();

            circuit.AddNode(root);
            circuit.AddNode(node);
            circuit.AddRoot(root);

            source.f4x4 = f4x4;

            root.Attach("f4x4", node, "i");
            root.Attach("f4x4", node, "f");
            root.Attach("f4x4", node, "d");
            root.Attach("f4x4", node, "isTrue");
            root.Attach("f4x4", node, "text");
            root.Attach("f4x4", node, "d2");
            root.Attach("f4x4", node, "d3");
            root.Attach("f4x4", node, "d4");
            root.Attach("f4x4", node, "d4x4");
            root.Attach("f4x4", node, "f2");
            root.Attach("f4x4", node, "f3");
            root.Attach("f4x4", node, "f4");
            root.Attach("f4x4", node, "f4x4");

            circuit.Execute();

            Assert.True(expected.i == i, "Error when parsing to int: Should be " + i + " but is " + expected.i + ".");
            Assert.True(expected.f == f, "Error when parsing to float: Should be " + f + " but is " + expected.f + ".");
            Assert.True(expected.d == d, "Error when parsing to double: Should be " + d + " but is " + expected.d + ".");
            Assert.True(expected.isTrue == isTrue, "Error when parsing to bool: Should be " + isTrue + " but is " + expected.isTrue + ".");
            Assert.True(expected.text == text, "Error when parsing to string: Should be " + text + " but is " + expected.text + ".");
            Assert.True(expected.d2 == d2, "Error when parsing to double2: Should be " + d2 + " but is " + expected.d2 + ".");
            Assert.True(expected.d3 == d3, "Error when parsing to double3: Should be " + d3 + " but is " + expected.d3 + ".");
            Assert.True(expected.d4 == d4, "Error when parsing to double4: Should be " + d4 + " but is " + expected.d4 + ".");
            Assert.True(expected.d4x4 == d4x4, "Error when parsing to double4x4: Should be " + d4x4 + " but is " + expected.d4x4 + ".");
            Assert.True(expected.f2 == f2, "Error when parsing to float2: Should be " + f2 + " but is " + expected.f2 + ".");
            Assert.True(expected.f3 == f3, "Error when parsing to float3: Should be " + f3 + " but is " + expected.f3 + ".");
            Assert.True(expected.f4 == f4, "Error when parsing to float4: Should be " + f4 + " but is " + expected.f4 + ".");
            Assert.True(expected.f4x4 == f4x4, "Error when parsing to float4x4: Should be " + f4x4 + " but is " + expected.f4x4 + ".");
        }
Ejemplo n.º 4
0
        public void ConvertFromStringToFloat4x4()
        {
            ConverterClass source   = new ConverterClass();
            ConverterClass expected = new ConverterClass();
            Node           root     = new Node(source);
            Node           node     = new Node(expected);
            Circuit        circuit  = new Circuit();

            circuit.AddNode(root);
            circuit.AddNode(node);
            circuit.AddRoot(root);

            source.text = "(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)";
            root.Attach("text", node, "f4x4");
            circuit.Execute();

            Assert.True(expected.f4x4 == new float4x4(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), "Error when parsing to float4x4: Should be " + source.text + " but is " + expected.f4x4 + ".");
        }
Ejemplo n.º 5
0
        public void ConvertFromStringToDouble2()
        {
            ConverterClass source   = new ConverterClass();
            ConverterClass expected = new ConverterClass();
            Node           root     = new Node(source);
            Node           node     = new Node(expected);
            Circuit        circuit  = new Circuit();

            circuit.AddNode(root);
            circuit.AddNode(node);
            circuit.AddRoot(root);

            source.text = "(1, 1)";
            root.Attach("text", node, "d2");
            circuit.Execute();

            Assert.True(expected.d2 == new double2(1, 1), "Error when parsing to double2: Should be " + source.text + " but is " + expected.d2 + ".");
        }
Ejemplo n.º 6
0
        public void NestedProperties()
        {
            NestedClass obj1    = new NestedClass(new SimpleStruct(1, 1));
            NestedClass obj2    = new NestedClass(new SimpleStruct(0, 0));
            Circuit     circuit = new Circuit();
            Node        node1   = new Node(obj1);
            Node        node2   = new Node(obj2);

            circuit.AddNode(node1);
            circuit.AddRoot(node1);
            circuit.AddNode(node2);

            node1.Attach("str.x", node2, "str.y");

            circuit.Execute();

            Assert.True(obj2.str.y == obj1.str.x, "Node2.str.y is " + obj2.str.y + " but should be " + obj1.str.x + ".");
        }
Ejemplo n.º 7
0
        public void PerformCalculationOnExecute()
        {
            CalculationClass obj1    = new CalculationClass(1, 1);
            SimpleClass      obj2    = new SimpleClass(0, 0);
            Circuit          circuit = new Circuit();
            Node             node1   = new Node(obj1);
            Node             node2   = new Node(obj2);

            circuit.AddNode(node1);
            circuit.AddRoot(node1);
            circuit.AddNode(node2);

            node1.Attach("x", node2, "y");

            circuit.Execute();

            Assert.True(obj2.y == 2, "Obj2.y is " + obj2.y + " but should be " + obj1.x + ".");
            Assert.True(obj1.x == 2, "Obj1.x is " + obj1.x + " but should be 2.");
        }
Ejemplo n.º 8
0
        public void CreateTwoNodesAndChangeSimpleValue()
        {
            SimpleClass obj1 = new SimpleClass(0, 0);
            SimpleClass obj2 = new SimpleClass(1, 1);

            Circuit circuit = new Circuit();
            Node    node1   = new Node(obj1);
            Node    node2   = new Node(obj2);

            circuit.AddNode(node1);
            circuit.AddRoot(node1);
            circuit.AddNode(node2);

            node1.Attach("x", node2, "x");

            circuit.Execute();

            Assert.True(obj2.x == obj1.x, "Node2.x is " + obj2.x + " but it should be " + obj1.x + ".");
        }
Ejemplo n.º 9
0
        public void ConvertFromStringToBool()
        {
            ConverterClass source   = new ConverterClass();
            ConverterClass expected = new ConverterClass();
            Node           root     = new Node(source);
            Node           node     = new Node(expected);
            Circuit        circuit  = new Circuit();

            circuit.AddNode(root);
            circuit.AddNode(node);
            circuit.AddRoot(root);

            source.text = "true";
            root.Attach("text", node, "isTrue");
            circuit.Execute();

            Assert.True(expected.isTrue, "Error when parsing to bool: Should be true but is " + expected.isTrue + ".");

            source.text = "false";
            circuit.Execute();

            Assert.False(expected.isTrue, "Error when parsing to bool: Should be false but is " + expected.isTrue + ".");
        }