コード例 #1
0
        public void GetVariable_ShouldNotWaitDeinitializatedHimself()
        {
            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.NextTick(100, 0, 0);
                    using (RunAsync(() => conn0.GetVariable(TestVariableName0)))
                    {
                        //conn0.GetLastTick() 100
                        //conn1.GetLastTick() 0
                        //conn0 should wait conn1
                        WaitForStatusWaiting(conn0);

                        //conn0 deinitializated
                        //conn0 getvalue shouldn't wait
                        conn0.DeinitializeTestAPI();
                        WaitForStatus(conn0, InstanceStatus.Deinitialized);
                    }
                }
        }
コード例 #2
0
        public void InitializeTestAPI_DoNotWaitDeinitializedInstances()
        {
            const int instancesCount = 4;

            using (var conn0 = new ConnectImpl())
                using (var conn1 = new ConnectImpl())
                    using (var conn2 = new ConnectImpl())
                        using (var conn3 = new ConnectImpl())
                        {
                            using (RunAsync(() => conn0.InitializeTestAPI(0, instancesCount, 0, null)))
                                using (RunAsync(() => conn1.InitializeTestAPI(1, instancesCount, 0, null)))
                                    using (RunAsync(() => conn2.InitializeTestAPI(2, instancesCount, 0, null)))
                                    {
                                        WaitForStatusWaiting(conn0);
                                        Assert.That(conn0.InstanceStatus, Is.Not.EqualTo(InstanceStatus.Initialized));

                                        WaitForStatusWaiting(conn1);
                                        Assert.That(conn1.InstanceStatus, Is.Not.EqualTo(InstanceStatus.Initialized));

                                        WaitForStatusWaiting(conn2);
                                        Assert.That(conn2.InstanceStatus, Is.Not.EqualTo(InstanceStatus.Initialized));

                                        using (RunAsync(() =>
                                        {
                                            conn3.InitializeTestAPI(3, instancesCount, 0, null);
                                            conn3.DeinitializeTestAPI();
                                        }))
                                        {
                                            WaitForStartInitialization(conn3);
                                            Assert.That(conn3.IsInstanceWaiting, Is.False);
                                        }
                                    }
                            Assert.That(conn0.InstanceStatus, Is.EqualTo(InstanceStatus.Initialized));
                            Assert.That(conn1.InstanceStatus, Is.EqualTo(InstanceStatus.Initialized));
                            Assert.That(conn2.InstanceStatus, Is.EqualTo(InstanceStatus.Initialized));
                            Assert.That(conn3.InstanceStatus, Is.EqualTo(InstanceStatus.Deinitialized));
                        }
        }
コード例 #3
0
        public void InitializeTestAPI_DoNotWaitDeinitializedInstances()
        {
            const int instancesCount = 4;

            using (var conn0 = new ConnectImpl())
            using (var conn1 = new ConnectImpl())
            using (var conn2 = new ConnectImpl())
            using (var conn3 = new ConnectImpl())
            {
                using (RunAsync(() => conn0.InitializeTestAPI(0, instancesCount, 0, null)))
                using (RunAsync(() => conn1.InitializeTestAPI(1, instancesCount, 0, null)))
                using (RunAsync(() => conn2.InitializeTestAPI(2, instancesCount, 0, null)))
                {
                    WaitForStatusWaiting(conn0);
                    Assert.That(conn0.InstanceStatus, Is.Not.EqualTo(InstanceStatus.Initialized));

                    WaitForStatusWaiting(conn1);
                    Assert.That(conn1.InstanceStatus, Is.Not.EqualTo(InstanceStatus.Initialized));

                    WaitForStatusWaiting(conn2);
                    Assert.That(conn2.InstanceStatus, Is.Not.EqualTo(InstanceStatus.Initialized));

                    using (RunAsync(() =>
                        {
                            conn3.InitializeTestAPI(3, instancesCount, 0, null);
                            conn3.DeinitializeTestAPI();
                        }))
                    {
                        WaitForStartInitialization(conn3);
                        Assert.That(conn3.IsInstanceWaiting, Is.False);
                    }
                }
                Assert.That(conn0.InstanceStatus, Is.EqualTo(InstanceStatus.Initialized));
                Assert.That(conn1.InstanceStatus, Is.EqualTo(InstanceStatus.Initialized));
                Assert.That(conn2.InstanceStatus, Is.EqualTo(InstanceStatus.Initialized));
                Assert.That(conn3.InstanceStatus, Is.EqualTo(InstanceStatus.Deinitialized));
            }
        }
コード例 #4
0
        public void GetVariable_ShouldNotWaitDeinitializatedInstances()
        {
            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.NextTick(100, 0, 0);
                using (RunAsync(() => conn0.GetVariable(TestVariableName0)))
                {
                    //conn0.GetLastTick() 100
                    //conn1.GetLastTick() 0
                    //conn0 should wait conn1
                    WaitForStatusWaiting(conn0);

                    //conn1 deinitializated
                    //conn0 shouldn't wait
                    conn1.DeinitializeTestAPI();
                    WaitForStatus(conn0, InstanceStatus.Initialized);
                }
            }
        }