コード例 #1
0
        public void GetVariable_CanSummValuesOfVariable()
        {
            const int instancesCount = 2;

            using (var conn0 = new ConnectImpl())
            using (var conn1 = new ConnectImpl())
            {
                using (RunAsync(() => conn0.InitializeTestAPI(0, instancesCount, 0, null)))
                using (RunAsync(() => conn1.InitializeTestAPI(1, instancesCount, 0, null)))
                {
                }

                conn0.DeclareVariable(TestVariableName0, VariableOperations.Sum);

                conn0.NextTick(100, 0, 0);
                conn1.NextTick(100, 0, 0);
                conn0.SetVariable(TestVariableName0, 10);
                conn0.NextTick(101, 0, 0);
                conn1.NextTick(101, 0, 0);
                conn1.SetVariable(TestVariableName0, 12);
                conn0.NextTick(102, 0, 0);
                conn1.NextTick(102, 0, 0);

                Assert.That(conn0.GetVariable(TestVariableName0), Is.EqualTo(22));
                Assert.That(conn1.GetVariable(TestVariableName0), Is.EqualTo(22));
            }
        }
コード例 #2
0
        public void GetVariable_CanSummValuesOfVariable()
        {
            const int instancesCount = 2;

            using (var conn0 = new ConnectImpl())
                using (var conn1 = new ConnectImpl())
                {
                    using (RunAsync(() => conn0.InitializeTestAPI(0, instancesCount, 0, null)))
                        using (RunAsync(() => conn1.InitializeTestAPI(1, instancesCount, 0, null)))
                        {
                        }

                    conn0.DeclareVariable(TestVariableName0, VariableOperations.Sum);

                    conn0.NextTick(100, 0, 0);
                    conn1.NextTick(100, 0, 0);
                    conn0.SetVariable(TestVariableName0, 10);
                    conn0.NextTick(101, 0, 0);
                    conn1.NextTick(101, 0, 0);
                    conn1.SetVariable(TestVariableName0, 12);
                    conn0.NextTick(102, 0, 0);
                    conn1.NextTick(102, 0, 0);

                    Assert.That(conn0.GetVariable(TestVariableName0), Is.EqualTo(22));
                    Assert.That(conn1.GetVariable(TestVariableName0), Is.EqualTo(22));
                }
        }