public void TcpExtendesWithDisposedServiceProtocolTest()
        {
            KsiService service         = GetTcpKsiService();
            ulong      aggregationTime = 1455478441;

            IAsyncResult ar1 = service.BeginExtend(aggregationTime, null, null);
            IAsyncResult ar2 = service.BeginExtend(aggregationTime, null, null);

            service.EndExtend(ar1);

            TcpKsiExtendingServiceProtocol tcp = GetTcpProtocol(service);

            Assert.IsNotNull(GetExtendingSocket(tcp), "Socket should not be null");
            tcp.Dispose();

            Assert.IsNull(GetExtendingSocket(tcp), "Socket should be null");

            KsiServiceProtocolException ex = Assert.Throws <KsiServiceProtocolException>(delegate
            {
                service.EndExtend(ar2);
            });

            Assert.That(ex.Message.StartsWith("TCP KSI service protocol is disposed."), "Unexpected exception message: " + ex.Message);

            ex = Assert.Throws <KsiServiceProtocolException>(delegate
            {
                service.BeginExtend(aggregationTime, null, null);
            });

            Assert.That(ex.Message.StartsWith("TCP KSI service protocol is disposed."), "Unexpected exception message: " + ex.Message);
        }
        private static Socket GetExtendingSocket(TcpKsiExtendingServiceProtocol tcp)
        {
            string    fieldName  = "_socket";
            FieldInfo memberInfo = typeof(TcpKsiServiceProtocolBase).GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);

            if (memberInfo != null)
            {
                return((Socket)memberInfo.GetValue(tcp));
            }
            throw new Exception("Could not get field info: " + fieldName);
        }