public void OutputEndpointProduceToOutputWithNoResult() { IOutputEndpoint output1 = new OutputEndpoint(); IOutputEndpoint output2 = new OutputEndpoint(output1); output2.Produce(1); }
public void ContinuousSendSignals() { IInputEndpoint input = new InputEndpoint(); Int32 receivedSignal = 0; input.Receive += (sender, signal) => { receivedSignal = signal; }; IOutputEndpoint output = new OutputEndpoint(input); output.Produce(1); Assert.AreEqual(receivedSignal, 1); output.Produce(0); Assert.AreEqual(receivedSignal, 0); output.Produce(0); Assert.AreEqual(receivedSignal, 0); output.Produce(1); Assert.AreEqual(receivedSignal, 1); output.Produce(0); Assert.AreEqual(receivedSignal, 0); }
public void NeutralEndpointProduceToOutputWithNoResult() { IOutputEndpoint output = new OutputEndpoint(); INeutralEndpoint neutral = new NeutralEndpoint(output); neutral.Produce(1); }
public void SendSignal() { IInputEndpoint input = new InputEndpoint(); Int32 inputSignal = 0; input.Receive += (sender, signal) => { inputSignal = signal; }; IOutputEndpoint output1 = new OutputEndpoint(); IOutputEndpoint output2 = new OutputEndpoint(); INeutralEndpoint netrual = new NeutralEndpoint(); Int32 netrualSignal = 0; netrual.Receive += (sender, signal) => { netrualSignal = signal; }; Nexus nexus = new Nexus(6, input, output1, output2, netrual); output1.Produce(1); Assert.AreEqual(inputSignal, 1); Assert.AreEqual(netrualSignal, 1); output2.Produce(0); Assert.AreEqual(inputSignal, 1); Assert.AreEqual(netrualSignal, 1); output1.Produce(0); Assert.AreEqual(inputSignal, 0); Assert.AreEqual(netrualSignal, 0); netrual.Produce(1); Assert.AreEqual(inputSignal, 1); Assert.AreEqual(netrualSignal, 0); }
public void ChargeTheOutputThenConnectInputOrNuetral() { IInputEndpoint input = new InputEndpoint(); Int32 receivedSignal = 0; input.Receive += (sender, signal) => { receivedSignal = signal; }; INeutralEndpoint neutral = new NeutralEndpoint(); Int32 neutralReceivedSignal = 0; neutral.Receive += (sender, signal) => { neutralReceivedSignal = signal; }; IOutputEndpoint output = new OutputEndpoint(); output.Produce(1); Assert.AreEqual(receivedSignal, 0); Assert.AreEqual(neutralReceivedSignal, 0); output.ConnectTo(input); Assert.AreEqual(receivedSignal, 1); Assert.AreEqual(neutralReceivedSignal, 0); output.ConnectTo(neutral); Assert.AreEqual(receivedSignal, 0); Assert.AreEqual(neutralReceivedSignal, 1); }
public void inputConnectToTheSameOutputMoreThanOneTime() { IInputEndpoint input = new InputEndpoint(); Int32 callTimes = 0; input.Receive += (sender, signal) => { callTimes++; }; IOutputEndpoint output = new OutputEndpoint(); input.ConnectTo(output); Assert.AreEqual(callTimes, 1); input.ConnectTo(output); Assert.AreEqual(callTimes, 1); output.ConnectTo(input); Assert.AreEqual(callTimes, 1); output.ConnectTo(input); Assert.AreEqual(callTimes, 1); input.ConnectTo(output); Assert.AreEqual(callTimes, 1); output.ConnectTo(input); Assert.AreEqual(callTimes, 1); }
public void ChangeEndpointMidwayWithPrechargedSignal() { IInputEndpoint input1 = new InputEndpoint(); Int32 receivedSignal1 = 0; input1.Receive += (sender, signal) => { receivedSignal1 = signal; }; IInputEndpoint input2 = new InputEndpoint(); Int32 receivedSignal2 = 0; input2.Receive += (sender, signal) => { receivedSignal2 = signal; }; IOutputEndpoint output = new OutputEndpoint(input1); output.Produce(1); Assert.AreEqual(receivedSignal1, 1); Assert.AreEqual(receivedSignal2, 0); output.ConnectTo(input2); Assert.AreEqual(receivedSignal1, 0); Assert.AreEqual(receivedSignal2, 1); }
public void CreateNew() { IInputEndpoint input = new InputEndpoint(); IOutputEndpoint output = new OutputEndpoint(); Wire wire = new Wire(input, output); Assert.IsNotNull(wire); }
public void CreateNewOutputPointWithConnectPoint() { IOutputEndpoint output1 = new OutputEndpoint(); IOutputEndpoint output2 = new OutputEndpoint(output1); Assert.IsNotNull(output1.ConnectedPoint); Assert.IsNotNull(output2.ConnectedPoint); Assert.AreSame(output1.ConnectedPoint, output2); Assert.AreSame(output2.ConnectedPoint, output1); }
public void CreateNewEndpoint() { IInputEndpoint input = new InputEndpoint(); IOutputEndpoint output = new OutputEndpoint(); INeutralEndpoint neutral = new NeutralEndpoint(); Assert.IsNotNull(input); Assert.IsNotNull(output); Assert.IsNotNull(neutral); }
public void CreateNewWithInsufficientConnectionPoints() { IInputEndpoint input = new InputEndpoint(); IOutputEndpoint output = new OutputEndpoint(); INeutralEndpoint netrual = new NeutralEndpoint(); Nexus nexus = new Nexus(6, input, output, netrual); Assert.IsNotNull(nexus); }
public void CreateNewWithExcessiveConnectionPoints() { IInputEndpoint input1 = new InputEndpoint(); IInputEndpoint input2 = new InputEndpoint(); IOutputEndpoint output1 = new OutputEndpoint(); IOutputEndpoint output2 = new OutputEndpoint(); INeutralEndpoint netrual1 = new NeutralEndpoint(); INeutralEndpoint netrual2 = new NeutralEndpoint(); Nexus nexus = new Nexus(3, input1, input2, output1, output2, netrual1, netrual2); Assert.IsNotNull(nexus); }
public void CreateNew() { IInputEndpoint input1 = new InputEndpoint(); IInputEndpoint input2 = new InputEndpoint(); IOutputEndpoint output1 = new OutputEndpoint(); IOutputEndpoint output2 = new OutputEndpoint(); INeutralEndpoint netrual1 = new NeutralEndpoint(); INeutralEndpoint netrual2 = new NeutralEndpoint(); Nexus nexus = new Nexus(6, input1, input2, output1, output2, netrual1, netrual2); Assert.IsNotNull(nexus); }
public void OutputEndpointProduceToNeutral() { INeutralEndpoint neutral = new NeutralEndpoint(); Int32 receivedSignal = 0; neutral.Receive += (sender, signal) => { receivedSignal = signal; }; IOutputEndpoint output = new OutputEndpoint(neutral); output.Produce(1); Assert.AreEqual(receivedSignal, 1); }
public void DisconnectInputWithConnectionNoCharge() { IInputEndpoint input = new InputEndpoint(); Int32 callTimes = 0; input.Receive += (sender, signal) => { callTimes++; }; IOutputEndpoint output = new OutputEndpoint(input); input.DisconnectEndpoint(); Assert.AreEqual(callTimes, 1); }
public void DisconnectEndpointWithPrechargedSignal() { IInputEndpoint input = new InputEndpoint(); Int32 receivedSignal = 0; input.Receive += (sender, signal) => { receivedSignal = signal; }; IOutputEndpoint output = new OutputEndpoint(input); output.Produce(1); Assert.AreEqual(receivedSignal, 1); output.DisconnectEndpoint(); Assert.AreEqual(receivedSignal, 0); }
public void DisconnectInputWithConnectionPrecharged() { IInputEndpoint input = new InputEndpoint(); Int32 callTimes = 0; input.Receive += (sender, signal) => { callTimes++; }; IOutputEndpoint output = new OutputEndpoint(); output.Produce(1); output.ConnectTo(input); input.DisconnectEndpoint(); Assert.AreEqual(callTimes, 2); }
public void ToggleOneInpuSigalWhileOtherInputIs0() { IInputEndpoint input = new InputEndpoint(); Int32 inputSignal = 0; input.Receive += (sender, signal) => { inputSignal = signal; }; IOutputEndpoint output1 = new OutputEndpoint(); IOutputEndpoint output2 = new OutputEndpoint(); Nexus nexus = new Nexus(3, input, output1, output2); output1.Produce(1); Assert.AreEqual(inputSignal, 1); output1.Produce(0); Assert.AreEqual(inputSignal, 0); output1.Produce(1); Assert.AreEqual(inputSignal, 1); output1.Produce(0); Assert.AreEqual(inputSignal, 0); }
public void SendSignal() { IInputEndpoint input = new InputEndpoint(); Int32 receivedSignal = 0; IEndpoint senderPoint = null; input.Receive += (sdr, signal) => { senderPoint = sdr; receivedSignal = signal; }; IOutputEndpoint output = new OutputEndpoint(); Wire wire = new Wire(input, output); output.Produce(1); Assert.AreEqual(receivedSignal, 1); output.Produce(0); Assert.AreEqual(receivedSignal, 0); }
public void ToggleInpuSigalWhilePrechargedBeforeCreating() { IInputEndpoint input1 = new InputEndpoint(); IInputEndpoint input2 = new InputEndpoint(); Int32 inputSignal1 = 0; input1.Receive += (sender, signal) => { inputSignal1 = signal; }; Int32 inputSignal2 = 0; input1.Receive += (sender, signal) => { inputSignal2 = signal; }; IOutputEndpoint output = new OutputEndpoint(); output.Produce(1); Nexus nexus = new Nexus(3, output, input1, input2); Assert.AreEqual(inputSignal1, 1); Assert.AreEqual(inputSignal2, 1); output.Produce(0); Assert.AreEqual(inputSignal1, 0); Assert.AreEqual(inputSignal2, 0); output.Produce(0); Assert.AreEqual(inputSignal1, 0); Assert.AreEqual(inputSignal2, 0); output.Produce(1); Assert.AreEqual(inputSignal1, 1); Assert.AreEqual(inputSignal2, 1); output.Produce(1); Assert.AreEqual(inputSignal1, 1); Assert.AreEqual(inputSignal2, 1); output.Produce(0); Assert.AreEqual(inputSignal1, 0); Assert.AreEqual(inputSignal2, 0); }
public void ConnectPostCreating() { IInputEndpoint input1 = new InputEndpoint(); Int32 inputSignal1 = 0; input1.Receive += (sender, signal) => { inputSignal1 = signal; }; IInputEndpoint input2 = new InputEndpoint(); Int32 inputSignal2 = 0; input2.Receive += (sender, signal) => { inputSignal2 = signal; }; IOutputEndpoint output = new OutputEndpoint(); INeutralEndpoint netrual = new NeutralEndpoint(); Nexus nexus = new Nexus(6, input1, output, netrual); output.Produce(1); Assert.AreEqual(inputSignal1, 1); Assert.AreEqual(inputSignal2, 0); nexus.ConnectAt(input2, 3); Assert.AreEqual(inputSignal1, 1); Assert.AreEqual(inputSignal2, 1); }
public void CreateDifferentPointWithConnectPoint() { IInputEndpoint input1 = new InputEndpoint(); IOutputEndpoint output1 = new OutputEndpoint(); INeutralEndpoint nuetral1 = new NeutralEndpoint(); IInputEndpoint input2 = new InputEndpoint(output1); IOutputEndpoint output2 = new OutputEndpoint(nuetral1); INeutralEndpoint neutral2 = new NeutralEndpoint(input1); Assert.IsNotNull(input1.ConnectedPoint); Assert.IsNotNull(input2.ConnectedPoint); Assert.IsNotNull(output1.ConnectedPoint); Assert.IsNotNull(output2.ConnectedPoint); Assert.IsNotNull(nuetral1.ConnectedPoint); Assert.IsNotNull(neutral2.ConnectedPoint); Assert.AreSame(input1.ConnectedPoint, neutral2); Assert.AreSame(neutral2.ConnectedPoint, input1); Assert.AreSame(output1.ConnectedPoint, input2); Assert.AreSame(input2.ConnectedPoint, output1); Assert.AreSame(nuetral1.ConnectedPoint, output2); Assert.AreSame(output2.ConnectedPoint, nuetral1); }
public void OutputProduceInvalidSignal255() { IOutputEndpoint output = new OutputEndpoint(); output.Produce(255); }
public void OutputEndpointConnectToSelf() { IOutputEndpoint point = new OutputEndpoint(); point.ConnectTo(point); }
public static CommandEndpoint GetEndpoint(string path, string[] enabledLanguages) { _path = path; var reader = new ConfigReader(_path); _interpreters = new Interpreters(_path); ProcessExtensions.GetInterpreter = (file) => { var interpreters = _interpreters .GetInterpreterFor(Path.GetExtension(file)); return(interpreters); }; _cache = new TypeCache(); _outputEndpoint = new OutputEndpoint(_path); Logger.Write("Event endpoint serving on port: {0}", _outputEndpoint.Port); var responseDispatcher = new ResponseDispatcher( _path, false, "language-output ", (p, m) => _outputEndpoint.Send(p, m), (m) => _endpoint.Handle(m), (m) => {} ); responseDispatcher.OnlyCommands(); _pluginLocator = new PluginLocator( enabledLanguages, new ProfileLocator(_path), (msg) => { responseDispatcher.Handle(false, msg); } ); initPlugins(_pluginLocator); _eventEndpoint = new EventEndpoint(_path, _pluginLocator, _outputEndpoint); _eventEndpoint.Start(); Logger.Write("Event endpoint listening on port: {0}", _eventEndpoint.Port); Logger.Write("Creating plugin file tracker"); _tracker = new PluginFileTracker(); Logger.Write("Starting plugin file tracker"); var ignoreDirSetting = reader.Get("oi.ignore.directories"); var ignoreDirectories = new string[] {}; if (ignoreDirSetting != null) { ignoreDirectories = ignoreDirSetting .Split(new[] { ',' }) .Select(x => { if (Path.IsPathRooted(x)) { return(x); } return(Path.Combine(_path, x)); }) .ToArray(); } _tracker.Start( _path, _cache, _cache, _pluginLocator, _eventEndpoint, ignoreDirectories); Logger.Write("Plugin file tracker started"); _endpoint = new CommandEndpoint(_path, _cache, _eventEndpoint); _endpoint.AddHandler(messageHandler); _handlers.AddRange(new IHandler[] { new GetProjectsHandler(_endpoint, _cache), new GetFilesHandler(_endpoint, _cache), new GetCodeRefsHandler(_endpoint, _cache), new GetSignatureRefsHandler(_endpoint, _cache), new GoToDefinitionHandler(_endpoint, _cache, _pluginLocator), new FindTypeHandler(_endpoint, _cache), new SnippetEditHandler(_endpoint, _cache, _path), new SnippetDeleteHandler(_cache, _path), new GetRScriptStateHandler(_endpoint, _eventEndpoint), new CompleteSnippetHandler(_cache, _path, _endpoint), new WriteOutputHandler(_eventEndpoint), // Make sure this handler is the last one since the command can be file extension or language name new LanguageCommandHandler(_endpoint, _cache, _pluginLocator) }); Logger.Write("Command endpoint started"); return(_endpoint); }
public void UnconnectedOutputEndpointProduceWithoutException() { IOutputEndpoint output = new OutputEndpoint(); output.Produce(1); }