コード例 #1
0
        private void Setup()
        {
            var partFactory = PartFactoryTestObjects.GetAlwaysValidPartFactory();

            CommandFactory = CommandsTestObjects.GetProperAlwaysValidCommandFactory();
            var idGenerator         = new IdGenerator(4);
            var dataPackFactory     = new ReflectionBasedDataPackFactory();
            var orderFactory        = new OrderFactory(idGenerator, dataPackFactory);
            var replyFactory        = new ReplyFactory(idGenerator);
            var confirmationFactory = new ConfirmationFactory();

            Mock <IDataStreamSplitter>       splitter  = new Mock <IDataStreamSplitter>();
            Mock <ICommunicationDeviceAsync> comDevice = new Mock <ICommunicationDeviceAsync>();
            var translator = new CommandTranslator(new OrderCommandTranslator(partFactory, CommandFactory, orderFactory),
                                                   new ReplyCommandTranslator(partFactory, CommandFactory, replyFactory),
                                                   new ConfirmationCommandTranslator(partFactory, CommandFactory, confirmationFactory), new ErrorCommandTranslator());

            Translator = translator;

            Mock <IDeviceHandler> handler = new Mock <IDeviceHandler>();

            handler.Setup(h => h.SendAsync(It.IsAny <ICommand>())).ReturnsAsync(true);

            DeviceMoq = handler;
            ResponseAwaiterDispatch = ResponseAwaiterDispatchTestObjects.GetProperResponseAwaiterDispatch();
            ProtocolHandler         = new ProtocolHandlerTestWrapper(handler.Object, confirmationFactory, replyFactory, orderFactory, translator, ResponseAwaiterDispatch);
        }
コード例 #2
0
 public void Setup()
 {
     Dispatch           = ResponseAwaiterDispatchTestObjects.GetProperResponseAwaiterDispatch();
     NormalOrder        = ProtocolTestObjects.GetNormalOrder();
     NormalConfirmation = ProtocolTestObjects.GetNormalConfirmation();
     NormalReply        = ProtocolTestObjects.GetNormalReply();
 }
コード例 #3
0
        public void Will_throw_if_is_given_not_complete_list_of_needed_awaiters()
        {
            var exception = Record.Exception(() =>
                                             new ResponseAwaiterDispatch(ResponseAwaiterDispatchTestObjects.GetAwaitersDictionaryWithoutReply()));

            _output.AddMessageFrom(exception);

            Assert.IsType <ArgumentOutOfRangeException>(exception);
        }
コード例 #4
0
        public void Should_throw_when_given_unknown_type_of_response()
        {
            var exception = Record.Exception(() =>
                                             Dispatch.AddResponse(ResponseAwaiterDispatchTestObjects.GetResponseMessageOfUnknownType()));

            _output.AddMessageFrom(exception);

            Assert.IsType <ArgumentOutOfRangeException>(exception);
        }