Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowErrorWithRemoteAddressWhenClosed() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowErrorWithRemoteAddressWhenClosed()
        {
            Channel          channel   = mock(typeof(Channel));
            ByteBufAllocator allocator = mock(typeof(ByteBufAllocator));

            when(allocator.buffer(anyInt())).thenReturn(Unpooled.buffer());
            when(channel.alloc()).thenReturn(allocator);
            SocketAddress remoteAddress       = mock(typeof(SocketAddress));
            string        remoteAddressString = "client.server.com:7687";

            when(remoteAddress.ToString()).thenReturn(remoteAddressString);
            when(channel.remoteAddress()).thenReturn(remoteAddress);

            ChunkedOutput output = new ChunkedOutput(channel, DEFAULT_TEST_BUFFER_SIZE, DEFAULT_TEST_BUFFER_SIZE, NO_THROTTLE);

            output.Dispose();

            try
            {
                output.WriteInt(42);
                fail("Exception expected");
            }
            catch (PackOutputClosedException e)
            {
                assertThat(e.Message, containsString(remoteAddressString));
            }
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteAndFlushInt() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWriteAndFlushInt()
        {
            @out.BeginMessage();
            @out.WriteInt(424242);
            @out.MessageSucceeded();
            @out.Flush();

            ByteBuf outboundMessage = PeekSingleOutboundMessage();

            AssertByteBufEqual(outboundMessage, ChunkContaining(424242) + MessageBoundary());
        }