Exemplo n.º 1
0
        public void When_BuildNode_Expect_Reference(Node node, double expected)
        {
            var builder = new ComplexBuilder();
            var act     = builder.Build(node);

            Assert.AreEqual(expected, act.Real, 1e-20);
            Assert.AreEqual(0.0, act.Imaginary, 1e-20);
        }
Exemplo n.º 2
0
        public void When_BuildNodeFunctions_Expect_Reference(Node node, Complex expected)
        {
            var builder = new ComplexBuilder();

            builder.RegisterDefaultFunctions();
            var act = builder.Build(node);

            Assert.AreEqual(expected.Real, act.Real, 1e-20);
            Assert.AreEqual(expected.Imaginary, act.Imaginary, 1e-20);
        }
Exemplo n.º 3
0
        public void When_BuildVariable_Expect_Reference()
        {
            var builder  = new ComplexBuilder();
            var variable = new GetSetVariable <Complex>("a", Units.Volt);

            builder.VariableFound += (sender, args) =>
            {
                if (!args.Created && args.Node.Name == "a")
                {
                    args.Result = variable.Value;
                }
            };
            variable.Value = 2.0;
            var act = builder.Build(Node.Add(Node.Variable("a"), 3.0));

            Assert.AreEqual(5.0, act.Real, 1e-20);
            Assert.AreEqual(0.0, act.Imaginary, 1e-20);
        }