Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void clientShouldUseHandlersToHandleComExceptions()
        public virtual void ClientShouldUseHandlersToHandleComExceptions()
        {
            // Given
            const string comExceptionMessage = "The ComException";

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: MadeUpCommunicationInterface communication = mock(MadeUpCommunicationInterface.class, (org.mockito.stubbing.Answer<Response<?>>) ignored ->
            MadeUpCommunicationInterface communication = mock(typeof(MadeUpCommunicationInterface), (Answer <Response <object> >)ignored =>
            {
                throw new ComException(comExceptionMessage);
            });

            ComExceptionHandler handler = mock(typeof(ComExceptionHandler));

            _life.add(_builder.server(communication));
            MadeUpClient client = _life.add(_builder.client());

            client.ComExceptionHandler = handler;

            _life.start();

            // When
            ComException exceptionThrownOnRequest = null;

            try
            {
                client.Multiply(1, 10);
            }
            catch (ComException e)
            {
                exceptionThrownOnRequest = e;
            }

            // Then
            assertNotNull(exceptionThrownOnRequest);
            assertEquals(comExceptionMessage, exceptionThrownOnRequest.Message);

            ArgumentCaptor <ComException> exceptionCaptor = ArgumentCaptor.forClass(typeof(ComException));

            verify(handler).handle(exceptionCaptor.capture());
            assertEquals(comExceptionMessage, exceptionCaptor.Value.Message);
            verifyNoMoreInteractions(handler);
        }
Example #2
0
 public virtual MadeUpServer Server(MadeUpCommunicationInterface target)
 {
     return(new MadeUpServer(target, PortConflict, InternalProtocolVersionConflict, ApplicationProtocolVersionConflict, VerifierConflict, ChunkSizeConflict));
 }