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 void Setup() { Dispatch = ResponseAwaiterDispatchTestObjects.GetProperResponseAwaiterDispatch(); NormalOrder = ProtocolTestObjects.GetNormalOrder(); NormalConfirmation = ProtocolTestObjects.GetNormalConfirmation(); NormalReply = ProtocolTestObjects.GetNormalReply(); }
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); }
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); }