Skip to content

Commit 839ae4a

Browse files
author
Eric Swann
committed
Added test for using engine.
1 parent 307655f commit 839ae4a

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/ClearScript.Manager.Test/ClearScript.Manager.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<ItemGroup>
5252
<Compile Include="Properties\AssemblyInfo.cs" />
5353
<Compile Include="ScriptSubject.cs" />
54+
<Compile Include="WhenUsingGetEngine.cs" />
5455
<Content Include="TestDiffNameRequire.js">
5556
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
5657
</Content>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using NUnit.Framework;
2+
using Should;
3+
4+
namespace ClearScript.Manager.Test
5+
{
6+
[TestFixture]
7+
public class WhenUsingEngine
8+
{
9+
[Test]
10+
public void Script_Engine_Is_Retrieved()
11+
{
12+
ManagerPool.InitializeCurrentPool(new ManualManagerSettings { RuntimeMaxCount = 2 });
13+
14+
using (var scope = new ManagerScope())
15+
{
16+
var engine = scope.RuntimeManager.GetEngine();
17+
18+
engine.ShouldNotBeNull();
19+
20+
engine.Execute("var i = 200;");
21+
22+
Assert.AreEqual(200, engine.Script.i);
23+
}
24+
25+
}
26+
}
27+
}

src/ClearScript.Manager/RuntimeManager.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ public interface IRuntimeManager : IDisposable
9999
/// <returns>Bool indicating that cached script was located.</returns>
100100
bool TryGetCached(string scriptId, out CachedV8Script script);
101101

102+
/// <summary>
103+
/// Retrieves the script engine for the current runtime manager.
104+
/// </summary>
105+
/// <returns></returns>
106+
V8ScriptEngine GetEngine();
107+
102108
/// <summary>
103109
/// Cleans up resources in the current runtime.
104110
/// </summary>

0 commit comments

Comments
 (0)