public void Execute_CallNpmFileWithInstallCommand_ExecutesJavaScriptFile() { // arrange TestHelper.DeleteDirectoryIfExists("nodetest"); TestHelper.CopyFile(@"TestData\package.json", @"nodetest\package.json"); var target = new NodeJs(); WorkflowInvokerTest invoker = TestHelper.CreateWorkflowInvoker(target); var nodeExe = new FileInfo("Node.exe".FindExePath()); var npmJavaScriptFile = Path.Combine(nodeExe.DirectoryName, @"node_modules\npm\bin\npm-cli.js"); // act var parameters = new Dictionary <string, object> { { "WorkingDirectory", "nodetest" }, { "JavaScriptFile", npmJavaScriptFile }, { "ApplicationParameters", "install" }, }; invoker.TestActivity(parameters); // assert Assert.IsTrue(Directory.Exists(@"nodetest\node_modules")); }
public UninstallCommand(GlobalContext globalContext, NodeJs nodeLocal) { _globalContext = globalContext; _nodeLocal = nodeLocal; }
void Awake() { spacebrewNewMsgs = new List <SpacebrewMessage>(); spacebrewMsgs = new List <SpacebrewMessage>(); //////// print("CLIENT - AWAKE"); //TODO: check values for pubilshers & subscribers message types! print("types: " + messageTypes.Count); for (int i = 0; i < messageTypes.Count; ++i) { print(messageTypes[i]); } //////// sbEvents = gameObject.GetComponentInParent <SpacebrewEvents>(); if (sbEvents == null) { throw new Exception("SpacebrewClient: SpacebrewEvent not found in parent object!"); } if (isServer && useDefaultPort) { serverPort = DEFAULT_SERVER_PORT; } if (!isServer && useConfigManager) { print("Getting server address and port from Server Configuration Manager"); // find a ServerManager IServerManager serverManager = null; var listServerManagers = FindObjectsOfType <MonoBehaviour>().OfType <IServerManager>(); if ((listServerManagers == null) || (listServerManagers.Count() == 0)) { throw new Exception("A SERVER MANAGER IMPLEMENTATION MUST EXIST IN THE SCENE IF THE SERVER ADDRESS IS NOT SPECFIED IN THE EDITOR!"); } serverManager = listServerManagers.First(); serverAddress = serverManager.GetServerAddress(); serverPort = serverManager.GetServerPort(); } //TODO: check that "serverAddress" & "serverPort" have valid format! //... string connectionString = SERVER_ADDRESS_STRING.Replace("<ADDRESS>", serverAddress).Replace("<PORT>", serverPort); print("Server address: " + connectionString); if (isAdmin) { sbAdmin = gameObject.GetComponentInParent <SpacebrewAdmin>(); if (sbAdmin == null) { throw new Exception("SpacebrewClient: SpacebrewAdmin not found in parent object! - Required if 'Is Admin' is set to 'true'"); } print("Admin client"); var config = new Config { clientName = clientName, description = descriptionText, publishers = new List <Publisher>(publishers), subscribers = new List <Subscriber>(subscribers), remoteAddress = "" }; sbAdmin.SetConfig(config); } if (isServer) { sbServer = gameObject.GetComponentInParent <NodeJs>(); if (sbServer == null) { throw new Exception("SpacebrewClient: NodeJs not found in parent object! - Required if 'Is Server' is set to 'true'"); } print("Starting Spacebrew server"); sbServer.Init(); sbServer.Run(); //wait? //... } conn = new WebSocket(connectionString); conn.OnOpen += (sender, e) => { print("Attempting to open socket"); }; if (isAdmin) { conn.OnMessage += (sender, e) => { //TODO: REMOVE THIS PRINT - DEBUG PURPOSE //print ("onMessage: " + e.Data); // parse the incoming json message from spacebrew var N = JSON.Parse(e.Data); JSONNode targetType = N["targetType"]; JSONNode message = N["message"]; if ((targetType == null) && (message != null)) { HandleMessage(message); } else { if (targetType.ToString() == "\"admin\"") { HandleAdminMessage(N); } else { JSONNode route = N[0]["route"]; if (route != null) { //TODO: REMOVE THIS PRINT - DEBUG PURPOSE print("remove-route message - disconnected client"); HandleRouteMessage(route); } else { //TODO: handle other messages? print("Not admin message - unhandled"); } } } }; } else { conn.OnMessage += (sender, e) => { //TODO: REMOVE THIS PRINT - DEBUG PURPOSE //print ("onMessage: " + e.Data); // parse the incoming json message from spacebrew var N = JSON.Parse(e.Data); JSONNode message = N["message"]; if (message != null) { HandleMessage(message); } //TODO: remove this commented code... (use?) // if (e.Type == Opcode.Text) { // // Do something with e.Data // print (e); // print (e.Data); // return; // } // // if (e.Type == Opcode.Binary) { // // Do something with e.RawData // return; // } }; } conn.OnError += (sender, e) => { print("THERE WAS AN ERROR CONNECTING"); print(e.Message); }; conn.OnClose += (sender, e) => { print("Connection closed"); }; print("Attemping to connect to " + connectionString); conn.Connect(); //addPublisher ("power", "boolean", "0"); //addSubscriber ("hits", "boolean"); // Special message to Spacebrew to act as admin interface if (isAdmin) { print("Sending admin request"); conn.Send(ADMIN_REQUEST_MESSAGE); } //TODO: check if still need to send this message when sending the previous admin one // Connect and send the configuration for the app to Spacebrew // conn.Send (makeConfig().ToString()); SendConfigMessage(); }
public ListCommand(NodeJs nodeJs) { _nodeJs = nodeJs; }
public InstallCommand(GlobalContext globalContext, NodeJsWebApi nodeWeb, NodeJs nodeLocal) { _globalContext = globalContext; _nodeWeb = nodeWeb; _nodeLocal = nodeLocal; }
public void TearDown() { _sut = null; _log = null; }
public void Setup() { _log = new Mock <ILog>(); _sut = new NodeJs(_log.Object, TestEnvironment.GetMockedSettings(), TestEnvironment.GetMockedAppSettings()); }