Skip to content

Commit

Permalink
Added test for using engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Swann committed Jan 7, 2015
1 parent 307655f commit 839ae4a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScriptSubject.cs" />
<Compile Include="WhenUsingGetEngine.cs" />
<Content Include="TestDiffNameRequire.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down
27 changes: 27 additions & 0 deletions src/ClearScript.Manager.Test/WhenUsingGetEngine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using NUnit.Framework;
using Should;

namespace ClearScript.Manager.Test
{
[TestFixture]
public class WhenUsingEngine
{
[Test]
public void Script_Engine_Is_Retrieved()
{
ManagerPool.InitializeCurrentPool(new ManualManagerSettings { RuntimeMaxCount = 2 });

using (var scope = new ManagerScope())
{
var engine = scope.RuntimeManager.GetEngine();

engine.ShouldNotBeNull();

engine.Execute("var i = 200;");

Assert.AreEqual(200, engine.Script.i);
}

}
}
}
6 changes: 6 additions & 0 deletions src/ClearScript.Manager/RuntimeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ public interface IRuntimeManager : IDisposable
/// <returns>Bool indicating that cached script was located.</returns>
bool TryGetCached(string scriptId, out CachedV8Script script);

/// <summary>
/// Retrieves the script engine for the current runtime manager.
/// </summary>
/// <returns></returns>
V8ScriptEngine GetEngine();

/// <summary>
/// Cleans up resources in the current runtime.
/// </summary>
Expand Down

0 comments on commit 839ae4a

Please sign in to comment.