Exemplo n.º 1
0
 public void ConveyourDispatcher_NetworkDeadlockNotHappens()
 {
     using (var tcpPair = new TcpConnectionPair())
     {
         tcpPair.OriginContract.OnAsk += tcpPair.OriginContract.Ask;
         var task = TestTools.AssertNotBlocks(tcpPair.OriginContract.OnAsk);
         Assert.AreEqual(TestContractMock.AskReturns, task.Result);
     }
 }
Exemplo n.º 2
0
 public void Origin_SayMissingCord_NotThrows()
 {
     using (var tcpPair = new TcpConnectionPair <IEmptyContract, ITestContract, TestContractMock>())
     {
         Assert.Multiple(() =>
         {
             TestTools.AssertNotBlocks(
                 () => tcpPair.OriginContract.OnSay());
             tcpPair.AssertPairIsConnected();
         });
     }
 }
Exemplo n.º 3
0
 public void Proxy_SayMissingCord_NotThrows()
 {
     using (var tcpPair = new TcpConnectionPair <ITestContract, IEmptyContract, EmptyContract>())
     {
         Assert.Multiple(() =>
         {
             TestTools.AssertNotBlocks(
                 () => tcpPair.ProxyConnection.Contract.Say());
             tcpPair.AssertPairIsConnected();
         });
     }
 }
Exemplo n.º 4
0
 public void Origin_AsksNotImplemented_returnsDefault()
 {
     using (var tcpPair = new TcpConnectionPair <ITestContract, ITestContract, TestContractMock>())
     {
         Assert.Multiple(() =>
         {
             var answer = TestTools.AssertNotBlocks(tcpPair.OriginContract.OnAsk).Result;
             Assert.AreEqual(default(int), answer);
             tcpPair.AssertPairIsConnected();
         });
     }
 }
Exemplo n.º 5
0
 public void Proxy_SayWithException_CallNotThrows()
 {
     using (var tcpPair = new TcpConnectionPair <IExceptionalContract, IExceptionalContract, ExceptionalContract>())
     {
         Assert.Multiple(() =>
         {
             TestTools.AssertNotBlocks(
                 () => tcpPair.ProxyConnection.Contract.Say());
             tcpPair.AssertPairIsConnected();
         });
     }
 }
Exemplo n.º 6
0
 public void Origin_SayExceptioanlCallback_NotThrows()
 {
     using (var tcpPair = new TcpConnectionPair <ITestContract, ITestContract, TestContractMock>())
     {
         tcpPair.ProxyContract.OnSay += () => { throw new InvalidOperationException(); };
         Assert.Multiple(() =>
         {
             TestTools.AssertNotBlocks(
                 () => tcpPair.OriginContract.OnSay());
             tcpPair.AssertPairIsConnected();
         });
     }
 }
        public void Proxy_SayMissingCord_NotThrows()
        {
            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.AssertNotBlocks(proxyConnection.Contract.Say);
        }
        public void Origin_AsksNotImplemented_returnsDefault()
        {
            var channelPair = TntTestHelper.CreateChannelPair();

            var proxyConnection = TntBuilder
                                  .UseContract <ITestContract>()
                                  .UseReceiveDispatcher <NotThreadDispatcher>()
                                  .UseChannel(channelPair.CahnnelA)
                                  .Build();

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

            channelPair.ConnectAndStartReceiving();

            var answer = TestTools.AssertNotBlocks(originConnection.Contract.OnAsk).Result;

            Assert.AreEqual(default(int), answer);
        }
Exemplo n.º 9
0
        public void ConveyourDispatcher_NetworkDeadlockNotHappens()
        {
            var channelPair     = TntTestHelper.CreateChannelPair();
            var proxyConnection = TntBuilder
                                  .UseContract <ITestContract>()
                                  //On income ask request, calling rpc ask.
                                  //It can provoke an networkDeadlock
                                  .UseContractInitalization((c, _) => c.OnAsk += c.Ask)
                                  .UseChannel(channelPair.CahnnelA)
                                  .Build();

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

            channelPair.ConnectAndStartReceiving();

            var task = TestTools.AssertNotBlocks(originConnection.Contract.OnAsk);

            Assert.AreEqual(TestContractMock.AskReturns, task.Result);
        }
        public void Origin_SayExceptioanlCallback_NotThrows()
        {
            var channelPair = TntTestHelper.CreateChannelPair();

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

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

            channelPair.ConnectAndStartReceiving();
            TestTools.AssertNotBlocks(originConnection.Contract.OnSay);
        }