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); }
public ProtocolHandler(IDeviceHandler deviceHandler, ConfirmationFactory confirmationFactory, ReplyFactory replyFactory, OrderFactory orderFactory, CommandTranslator commandTranslator, ResponseAwaiterDispatch awaiterDispatch) { _deviceHandler = deviceHandler; _confirmationFactory = confirmationFactory; _replyFactory = replyFactory; _orderFactory = orderFactory; _commandTranslator = commandTranslator; _awaiterDispatch = awaiterDispatch; _deviceHandler.CommandReceived += OnCommandReceived; }
public ProtocolHandlerTestWrapper(IDeviceHandler deviceHandler, ConfirmationFactory confirmationFactory, ReplyFactory replyFactory, OrderFactory orderFactory, CommandTranslator commandTranslator, ResponseAwaiterDispatch awaiterDispatch) : base(deviceHandler, confirmationFactory, replyFactory, orderFactory, commandTranslator, awaiterDispatch) { }