File tree Expand file tree Collapse file tree 6 files changed +106
-0
lines changed
MsieJavaScriptEngine.Test.Auto
MsieJavaScriptEngine.Test.ChakraActiveScript
MsieJavaScriptEngine.Test.ChakraEdgeJsRt
MsieJavaScriptEngine.Test.ChakraIeJsRt
MsieJavaScriptEngine.Test.Classic
MsieJavaScriptEngine.Test.Common Expand file tree Collapse file tree 6 files changed +106
-0
lines changed Original file line number Diff line number Diff line change 1+ using NUnit . Framework ;
2+
3+ using MsieJavaScriptEngine . Test . Common ;
4+
5+ namespace MsieJavaScriptEngine . Test . Auto
6+ {
7+ [ TestFixture ]
8+ public class MultithreadingTests : MultithreadingTestsBase
9+ {
10+ protected override JsEngineMode EngineMode => JsEngineMode . Auto ;
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ using System ;
2+
3+ using NUnit . Framework ;
4+
5+ using MsieJavaScriptEngine . Test . Common ;
6+
7+ namespace MsieJavaScriptEngine . Test . ChakraActiveScript
8+ {
9+ [ TestFixture ]
10+ public class MultithreadingTests : MultithreadingTestsBase
11+ {
12+ protected override JsEngineMode EngineMode => JsEngineMode . ChakraActiveScript ;
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Text . RegularExpressions ;
3+
4+ using NUnit . Framework ;
5+
6+ using MsieJavaScriptEngine . Test . Common ;
7+
8+ namespace MsieJavaScriptEngine . Test . ChakraEdgeJsRt
9+ {
10+ [ TestFixture ]
11+ public class MultithreadingTests : MultithreadingTestsBase
12+ {
13+ protected override JsEngineMode EngineMode => JsEngineMode . ChakraEdgeJsRt ;
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ using System ;
2+
3+ using NUnit . Framework ;
4+
5+ using MsieJavaScriptEngine . Test . Common ;
6+
7+ namespace MsieJavaScriptEngine . Test . ChakraIeJsRt
8+ {
9+ [ TestFixture ]
10+ public class MultithreadingTests : MultithreadingTestsBase
11+ {
12+ protected override JsEngineMode EngineMode => JsEngineMode . ChakraIeJsRt ;
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ using System ;
2+
3+ using NUnit . Framework ;
4+
5+ using MsieJavaScriptEngine . Test . Common ;
6+
7+ namespace MsieJavaScriptEngine . Test . Classic
8+ {
9+ [ TestFixture ]
10+ public class MultithreadingTests : MultithreadingTestsBase
11+ {
12+ protected override JsEngineMode EngineMode => JsEngineMode . Classic ;
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ using System . Threading ;
2+
3+ using NUnit . Framework ;
4+
5+ namespace MsieJavaScriptEngine . Test . Common
6+ {
7+ [ TestFixture ]
8+ public abstract class MultithreadingTestsBase : TestsBase
9+ {
10+ [ Test ]
11+ public virtual void ExecutionOfCodeFromDifferentThreadsIsCorrect ( )
12+ {
13+ // Arrange
14+ const string variableName = "foo" ;
15+ string inputCode1 = string . Format ( "var {0} = 'bar';" , variableName ) ;
16+ string inputCode2 = string . Format ( "{0} = 'baz';" , variableName ) ;
17+ const string targetOutput = "baz" ;
18+
19+ // Act
20+ string output ;
21+
22+ using ( var jsEngine = CreateJsEngine ( ) )
23+ {
24+ jsEngine . Execute ( inputCode1 ) ;
25+
26+ var thread = new Thread ( ( ) => jsEngine . Execute ( inputCode2 ) ) ;
27+ thread . Start ( ) ;
28+ thread . Join ( ) ;
29+
30+ output = jsEngine . GetVariableValue < string > ( variableName ) ;
31+ }
32+
33+ // Assert
34+ Assert . AreEqual ( targetOutput , output ) ;
35+ }
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments