Exemple #1
0
        public void ProxyBuilderBuilds_ChannelAllowReceiveIsTrue()
        {
            var channel = new TestChannel();

            channel.ImmitateConnect();
            var proxyConnection = TntBuilder
                                  .UseContract <ITestContract>()
                                  .UseChannel(channel)
                                  .Build();

            Assert.IsTrue(channel.AllowReceive);
        }
        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());
        }
Exemple #3
0
        public void ProxyBuilder_ChannelConnectedBefore_SayCalled_DataSent()
        {
            var channel = new TestChannel();

            channel.ImmitateConnect();

            var proxyConnection = TntBuilder
                                  .UseContract <ITestContract>()
                                  .UseChannel(channel)
                                  .Build();

            byte[] sentMessage = null;
            proxyConnection.Channel.OnWrited += (s, msg) => sentMessage = msg;
            proxyConnection.Contract.Say();

            Assert.IsNotNull(sentMessage);
            Assert.IsNotEmpty(sentMessage);
        }