public void SetUp() { _mockFolder = new Mock <IFolder>(); _config = new Configuration(new List <string>(), "Test", responder: true); _mockContainer = new Mock <DSLinkContainer>(new Configuration(new List <string>(), "Test")); _mockConnector = new Mock <Connector>( _mockContainer.Object.Config, _mockContainer.Object.Logger ); _mockContainer.SetupGet(c => c.Connector).Returns(_mockConnector.Object); _responder = new DSLinkResponder(_mockContainer.Object); _mockContainer.SetupGet(c => c.Responder).Returns(_responder); _responder.Init(); _responder.SuperRoot.CreateChild("testValue") .SetType(DSLink.Nodes.ValueType.Number) .SetValue(123) .BuildNode(); _responder.SuperRoot.CreateChild("testNodeConfigs") .SetConfig("testString", new Value("string")) .SetConfig("testNumber", new Value(123)) .BuildNode(); }
public DSLinkContainer(Configuration config) { _config = config; _config._processOptions(); _logger = new ConsoleLogger("DSLink", config.LogLevel); _logger = (BaseLogger)Activator.CreateInstance(_config.LoggerType, "DSLink", _config.LogLevel); _reconnectOnFailure = true; _connector = new WebSocketConnector(_config, _logger); if (Config.Responder) { _responder = new DSLinkResponder(this); _responder.Init(); } if (Config.Requester) { _requester = new DSLinkRequester(this); _requester.Init(); } // Connector events _connector.OnMessage += OnStringRead; _connector.OnBinaryMessage += OnBinaryRead; _connector.OnWrite += OnStringWrite; _connector.OnBinaryWrite += OnBinaryWrite; _connector.OnOpen += OnOpen; _connector.OnClose += OnClose; // Overridable events for DSLink writers _connector.OnOpen += OnConnectionOpen; _connector.OnClose += OnConnectionClosed; }
public DSLinkContainer(Configuration config) { _config = config; InitConnector(); if (Config.Responder) { _responder = new DSLinkResponder(this); _responder.Init(); } if (Config.Requester) { _requester = new DSLinkRequester(this); _requester.Init(); } }