Ejemplo n.º 1
0
        public void wontLeakOnUsingOwnershipTransfer()
        {
            // See bugzilla #101.
            // Here we are testing that resources won't leak, even when an asynchronous exception is thrown after the
            // lockableBladeSpec is constructed, but _before_ the using has been entered.
            using (bladeDirectorDebugServices uut = new bladeDirectorDebugServices(WCFPath, new[] { "1.1.1.1" }))
            {
                uut.svcDebug._isBladeMine("127.0.0.1", "1.1.1.1", false);
                uut.svcDebug._isBladeMine("127.0.0.1", "1.1.1.1", false);
                uut.svcDebug._isBladeMine("127.0.0.1", "1.1.1.1", false);
                uut.setReceiveTimeout(TimeSpan.FromSeconds(4));

                // >:)
                uut.svcDebug.lockAndNeverRelease("1.1.1.1");

                uut.setReceiveTimeout(TimeSpan.FromSeconds(10));
                uut.reconnect();

                // But if we re-connect, locks should be untaken.
                uut.svcDebug._isBladeMine("127.0.0.1", "1.1.1.1", false);
            }
        }
Ejemplo n.º 2
0
        public void wontLeakOnConnectionErrors()
        {
            using (bladeDirectorDebugServices uut = new bladeDirectorDebugServices(WCFPath, new[] { "1.1.1.1" }))
            {
                uut.setReceiveTimeout(TimeSpan.FromSeconds(4));

                // This will cause an exception..
                bool didExcept = false;
                try
                {
                    uut.svcDebug.lockAndSleep("1.1.1.1");
                }
                catch (CommunicationException)
                {
                    didExcept = true;
                }
                Assert.IsTrue(didExcept);
                uut.setReceiveTimeout(TimeSpan.FromSeconds(10));
                uut.reconnect();

                // But if we re-connect, locks should be untaken.
                uut.svcDebug._isBladeMine("127.0.0.1", "1.1.1.1", false);
            }
        }