public void Disconnected_duringOriginAsk_throws()
        {
            var channelPair = TntTestHelper.CreateChannelPair();

            var originConnection = TntBuilder
                                   .UseContract <ITestContract, TestContractMock>()
                                   .UseReceiveDispatcher <NotThreadDispatcher>()
                                   .UseChannel(channelPair.ChannelB)
                                   .Build();

            var proxyConnection = TntBuilder
                                  .UseContract <ITestContract>()
                                  .UseReceiveDispatcher <NotThreadDispatcher>()
                                  .UseContractInitalization((c, _) =>
            {
                c.OnAsk += () =>
                {
                    channelPair.Disconnect();
                    try {
                        //call say method to notify channel about disconnection (tcp channel immitation)
                        originConnection.Contract.Say();
                    } catch (ConnectionIsLostException) { /*suppressTheException*/ }
                    return(0);
                };
            })
                                  .UseChannel(channelPair.CahnnelA)
                                  .Build();

            channelPair.ConnectAndStartReceiving();
            TestTools.AssertThrowsAndNotBlocks <ConnectionIsLostException>(() => originConnection.Contract.OnAsk());
        }
Пример #2
0
 public void ProxyConnectionIsLost_AskCallThrows()
 {
     using (var tcpPair = new TcpConnectionPair())
     {
         tcpPair.Disconnect();
         TestTools.AssertThrowsAndNotBlocks <ConnectionIsLostException>(
             () => tcpPair.ProxyConnection.Contract.Ask());
     }
 }
Пример #3
0
        public void ProxyConnectionIsNotEstablishedYet_AskCallThrows()
        {
            var proxyConnection = TntBuilder
                                  .UseContract <ITestContract>()
                                  .UseReceiveDispatcher <NotThreadDispatcher>()
                                  .UseChannel(() => new TcpChannel())
                                  .Build();

            TestTools.AssertThrowsAndNotBlocks <ConnectionIsNotEstablishedYet>(() => proxyConnection.Contract.Ask());
        }
Пример #4
0
 public void Proxy_AskMissingCord_Throws()
 {
     using (var tcpPair = new TcpConnectionPair <ITestContract, IEmptyContract, EmptyContract>())
     {
         Assert.Multiple(() =>
         {
             TestTools.AssertThrowsAndNotBlocks <RemoteContractImplementationException>(
                 () => tcpPair.ProxyConnection.Contract.Ask());
             tcpPair.AssertPairIsConnected();
         });
     }
 }
Пример #5
0
 public void Proxy_AskWithException_Throws()
 {
     using (var tcpPair = new TcpConnectionPair <IExceptionalContract, IExceptionalContract, ExceptionalContract>())
     {
         Assert.Multiple(() =>
         {
             TestTools.AssertThrowsAndNotBlocks <RemoteUnhandledException>(
                 () => tcpPair.ProxyConnection.Contract.Ask());
             tcpPair.AssertPairIsConnected();
         });
     }
 }
        public void ProxyConnectionIsLost_SayCallThrows()
        {
            var channel         = new TestChannel();
            var proxyConnection = TntBuilder
                                  .UseContract <ITestContract>()
                                  .UseReceiveDispatcher <NotThreadDispatcher>()
                                  .UseChannel(channel)
                                  .Build();

            channel.ImmitateConnect();
            channel.ImmitateDisconnect();
            TestTools.AssertThrowsAndNotBlocks <ConnectionIsLostException>(() => proxyConnection.Contract.Say());
        }
Пример #7
0
 public void Origin_AskExceptioanlCallback_Throws()
 {
     using (var tcpPair = new TcpConnectionPair <ITestContract, ITestContract, TestContractMock>())
     {
         Assert.Multiple(() =>
         {
             tcpPair.ProxyContract.OnAsk += () => { throw new InvalidOperationException(); };
             TestTools.AssertThrowsAndNotBlocks <RemoteUnhandledException>(
                 () => tcpPair.OriginContract.OnAsk());
             tcpPair.AssertPairIsConnected();
         });
     }
 }
Пример #8
0
        public void Disconnected_duringOriginAsk_throws()
        {
            using (var tcpPair = new TcpConnectionPair <ITestContract, ITestContract, TestContractMock>())
            {
                tcpPair.ProxyConnection.Contract.OnAsk += () =>
                {
                    tcpPair.Disconnect();
                    return(0);
                };

                TestTools.AssertThrowsAndNotBlocks <ConnectionIsLostException>(
                    () => tcpPair.OriginContract.OnAsk());
            }
        }
        public void Proxy_AskWithException_Throws()
        {
            var channelPair     = TntTestHelper.CreateChannelPair();
            var proxyConnection = TntBuilder
                                  .UseContract <IExceptionalContract>()
                                  .UseReceiveDispatcher <NotThreadDispatcher>()
                                  .UseChannel(channelPair.CahnnelA)
                                  .Build();

            var originConnection = TntBuilder
                                   .UseContract <IExceptionalContract, ExceptionalContract>()
                                   .UseReceiveDispatcher <NotThreadDispatcher>()
                                   .UseChannel(channelPair.ChannelB)
                                   .Build();

            channelPair.ConnectAndStartReceiving();
            TestTools.AssertThrowsAndNotBlocks <RemoteUnhandledException>(() => proxyConnection.Contract.Ask());
        }
Пример #10
0
        public void Proxy_AskMissingCord_Throws()
        {
            var channelPair     = TntTestHelper.CreateChannelPair();
            var proxyConnection = TntBuilder
                                  .UseContract <ITestContract>()
                                  .UseReceiveDispatcher <NotThreadDispatcher>()
                                  .UseChannel(channelPair.CahnnelA)
                                  .Build();

            var originConnection = TntBuilder
                                   .UseContract <IEmptyContract, EmptyContract>()
                                   .UseReceiveDispatcher <NotThreadDispatcher>()
                                   .UseChannel(channelPair.ChannelB)
                                   .Build();

            channelPair.ConnectAndStartReceiving();

            TestTools.AssertThrowsAndNotBlocks <RemoteContractImplementationException>(() => proxyConnection.Contract.Ask());
        }
Пример #11
0
        public void Origin_AskExceptioanlCallback_Throws()
        {
            var channelPair = TntTestHelper.CreateChannelPair();

            var proxyConnection = TntBuilder
                                  .UseContract <ITestContract>()
                                  .UseReceiveDispatcher <NotThreadDispatcher>()
                                  .UseContractInitalization((c, _) =>
            {
                c.OnAsk += () => { throw new InvalidOperationException(); };
            })
                                  .UseChannel(channelPair.CahnnelA)
                                  .Build();

            var originConnection = TntBuilder
                                   .UseContract <ITestContract, TestContractMock>()
                                   .UseReceiveDispatcher <NotThreadDispatcher>()
                                   .UseChannel(channelPair.ChannelB)
                                   .Build();

            channelPair.ConnectAndStartReceiving();
            TestTools.AssertThrowsAndNotBlocks <RemoteUnhandledException>(() => originConnection.Contract.OnAsk());
        }