public static CommandFactory GetProperAlwaysValidCommandFactory() { var partFactory = PartFactoryTestObjects.GetAlwaysValidPartFactory(); var comfacadap = new CommandFactoryAutoFacAdapter((id, hostid, target, order, data, Timestamp) => new Command(id, hostid, target, order, data, TimestampFactory.Timestamp)); return(new CommandFactory(DefaultProtocolValues.Separator, partFactory, comfacadap)); }
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); }