示例#1
0
            public override void RunTestCase(Test.IRemoteObjectAdapterPrx adapter, Test.ITestIntfPrx proxy)
            {
                Ice.Connection con = proxy.GetCachedConnection();

                try
                {
                    con.SetACM(-19, null, null);
                    test(false);
                }
                catch (ArgumentException)
                {
                }

                Ice.ACM acm = con.GetACM();
                test(acm.Timeout == 15);
                test(acm.Close == Ice.ACMClose.CloseOnIdleForceful);
                test(acm.Heartbeat == Ice.ACMHeartbeat.HeartbeatOff);

                con.SetACM(null, null, null);
                acm = con.GetACM();
                test(acm.Timeout == 15);
                test(acm.Close == Ice.ACMClose.CloseOnIdleForceful);
                test(acm.Heartbeat == Ice.ACMHeartbeat.HeartbeatOff);

                con.SetACM(1, Ice.ACMClose.CloseOnInvocationAndIdle, Ice.ACMHeartbeat.HeartbeatAlways);
                acm = con.GetACM();
                test(acm.Timeout == 1);
                test(acm.Close == Ice.ACMClose.CloseOnInvocationAndIdle);
                test(acm.Heartbeat == Ice.ACMHeartbeat.HeartbeatAlways);

                proxy.startHeartbeatCount();
                proxy.waitForHeartbeatCount(2);

                var t1 = new TaskCompletionSource <object>();

                con.SetCloseCallback(_ => { t1.SetResult(null); });

                con.Close(ConnectionClose.Gracefully);
                test(t1.Task.Result == null);

                try
                {
                    con.ThrowException();
                    test(false);
                }
                catch (Ice.ConnectionManuallyClosedException)
                {
                }

                var t2 = new TaskCompletionSource <object>();

                con.SetCloseCallback(_ => { t2.SetResult(null); });
                test(t2.Task.Result == null);

                con.SetHeartbeatCallback(_ => { test(false); });
            }