public async void InvokeFromFileAsync_WithoutTypeParameter_IsThreadSafe() { // Arrange HttpNodeJSService testSubject = CreateHttpNodeJSService(projectPath: _projectPath); // Act const int numThreads = 5; var threads = new List <Thread>(); for (int i = 0; i < numThreads; i++) { var thread = new Thread(() => testSubject. InvokeFromFileAsync(DUMMY_EXPORTS_MULTIPLE_FUNCTIONS_MODULE_FILE, "incrementNumber").GetAwaiter().GetResult()); threads.Add(thread); thread.Start(); } foreach (Thread thread in threads) { thread.Join(); } // Assert int result = await testSubject.InvokeFromFileAsync <int>(DUMMY_EXPORTS_MULTIPLE_FUNCTIONS_MODULE_FILE, "getNumber").ConfigureAwait(false); Assert.Equal(numThreads, result); }
public async void InvokeFromFileAsync_WithoutTypeParameter_InvokesFromFile() { const string dummyArg = "success"; HttpNodeJSService testSubject = CreateHttpNodeJSService(projectPath: _projectPath); // Act await testSubject.InvokeFromFileAsync(DUMMY_EXPORTS_MULTIPLE_FUNCTIONS_MODULE_FILE, "setString", new[] { dummyArg }).ConfigureAwait(false); // Assert DummyResult result = await testSubject. InvokeFromFileAsync <DummyResult>(DUMMY_EXPORTS_MULTIPLE_FUNCTIONS_MODULE_FILE, "getString").ConfigureAwait(false); Assert.Equal(dummyArg, result.Result); }
public void InvokeFromFileAsync_WithTypeParameter_IsThreadSafe() { // Arrange const string dummyArg = "success"; HttpNodeJSService testSubject = CreateHttpNodeJSService(projectPath: _projectPath); // Act var results = new ConcurrentQueue <DummyResult>(); const int numThreads = 5; var threads = new List <Thread>(); for (int i = 0; i < numThreads; i++) { var thread = new Thread(() => results.Enqueue(testSubject. InvokeFromFileAsync <DummyResult>(DUMMY_RETURNS_ARG_MODULE_FILE, args: new[] { dummyArg }).GetAwaiter().GetResult())); threads.Add(thread); thread.Start(); } foreach (Thread thread in threads) { thread.Join(); } // Assert Assert.Equal(numThreads, results.Count); foreach (DummyResult result in results) { Assert.Equal(dummyArg, result.Result); } }
public void InvokeFromFileAsync_IsThreadSafe() { // Arrange const string dummyModule = "dummyModule.js"; const string dummyResultString = "success"; HttpNodeJSService testSubject = CreateHttpNodeJSService(); // Act var results = new ConcurrentQueue <DummyResult>(); const int numThreads = 5; var threads = new List <Thread>(); for (int i = 0; i < numThreads; i++) { var thread = new Thread(() => results.Enqueue(testSubject.InvokeFromFileAsync <DummyResult>(dummyModule, args: new[] { dummyResultString }).GetAwaiter().GetResult())); threads.Add(thread); thread.Start(); } foreach (Thread thread in threads) { thread.Join(); } // Assert Assert.Equal(numThreads, results.Count); foreach (DummyResult result in results) { Assert.Equal(dummyResultString, result.Result); } }
public async void InvokeFromFileAsync_WithTypeParameter_InvokesFromFile() { const string dummyArg = "success"; HttpNodeJSService testSubject = CreateHttpNodeJSService(projectPath: _projectPath); // Act DummyResult result = await testSubject. InvokeFromFileAsync <DummyResult>(DUMMY_RETURNS_ARG_MODULE_FILE, args : new[] { dummyArg }).ConfigureAwait(false); // Assert Assert.Equal(dummyArg, result.Result); }
public async void InvokeFromFileAsync_InvokesJavascript() { const string dummyResultString = "success"; HttpNodeJSService testSubject = CreateHttpNodeJSService(); // Act DummyResult result = await testSubject. InvokeFromFileAsync <DummyResult>("dummyModule.js", args : new[] { dummyResultString }).ConfigureAwait(false); // Assert Assert.Equal(dummyResultString, result.Result); }