Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogAWarningIfThereIsNoDecoderForTheMessageType() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogAWarningIfThereIsNoDecoderForTheMessageType()
        {
            // given
            RequestDecoderDispatcher <State> dispatcher    = new RequestDecoderDispatcher <State>(protocol, _logProvider);
            ChannelInboundHandler            delegateOne   = mock(typeof(ChannelInboundHandler));
            ChannelInboundHandler            delegateThree = mock(typeof(ChannelInboundHandler));

            dispatcher.Register(State.One, delegateOne);
            dispatcher.Register(State.Three, delegateThree);

            // when
            dispatcher.ChannelRead(mock(typeof(ChannelHandlerContext)), new object());

            // then
            AssertableLogProvider.LogMatcher matcher = inLog(typeof(RequestDecoderDispatcher)).warn("Unregistered handler for protocol %s", protocol);

            _logProvider.assertExactly(matcher);
            verifyZeroInteractions(delegateOne, delegateThree);
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDispatchToRegisteredDecoder() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDispatchToRegisteredDecoder()
        {
            // given
            RequestDecoderDispatcher <State> dispatcher    = new RequestDecoderDispatcher <State>(protocol, _logProvider);
            ChannelInboundHandler            delegateOne   = mock(typeof(ChannelInboundHandler));
            ChannelInboundHandler            delegateTwo   = mock(typeof(ChannelInboundHandler));
            ChannelInboundHandler            delegateThree = mock(typeof(ChannelInboundHandler));

            dispatcher.Register(State.One, delegateOne);
            dispatcher.Register(State.Two, delegateTwo);
            dispatcher.Register(State.Three, delegateThree);

            ChannelHandlerContext ctx = mock(typeof(ChannelHandlerContext));
            object msg = new object();

            // when
            dispatcher.ChannelRead(ctx, msg);

            // then
            verify(delegateTwo).channelRead(ctx, msg);
            verifyNoMoreInteractions(delegateTwo);
            verifyZeroInteractions(delegateOne, delegateThree);
        }