forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSharpModuleTests.cs
More file actions
70 lines (63 loc) · 2.57 KB
/
CSharpModuleTests.cs
File metadata and controls
70 lines (63 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using Moq;
using ScriptCs.Contracts;
using ScriptCs.Engine.Roslyn;
using Should;
using Xunit;
namespace ScriptCs.Tests
{
public class CSharpModuleTests
{
public class TheInitializeMethod
{
private readonly Mock<IModuleConfiguration> _configMock = new Mock<IModuleConfiguration>();
private readonly IModuleConfiguration _config;
private readonly RoslynModule _module = new RoslynModule();
private readonly IDictionary<Type, object> _overrides = new Dictionary<Type, object>();
public TheInitializeMethod()
{
_configMock.SetupGet(c => c.Debug).Returns(false);
_configMock.SetupGet(c => c.IsRepl).Returns(false);
_configMock.SetupGet(c => c.Cache).Returns(false);
_configMock.SetupGet(c => c.Overrides).Returns(_overrides);
_config = _configMock.Object;
}
[Fact]
public void ShouldNotOverrideTheEngineIfOneIsRegistered()
{
var engine = new Mock<IScriptEngine>();
_overrides[typeof (IScriptEngine)] = engine.Object;
_module.Initialize(_config);
_overrides[typeof(IScriptEngine)].ShouldEqual(engine.Object);
}
[Fact]
public void ShouldRegisterThePersistantScriptEngineWhenCacheIsEnabled()
{
_configMock.SetupGet(c => c.Cache).Returns(true);
_module.Initialize(_config);
_overrides[typeof(IScriptEngine)].ShouldEqual(typeof(CSharpPersistentEngine));
}
[Fact]
public void ShouldRegisterTheScriptEngineWhenCacheIsDisabled()
{
_module.Initialize(_config);
_overrides[typeof(IScriptEngine)].ShouldEqual(typeof(CSharpScriptEngine));
}
[Fact]
public void ShouldRegisterTheInMemoryEngineWhenDebugIsEnabled()
{
_configMock.Setup(c => c.Debug).Returns(true);
_module.Initialize(_config);
_overrides[typeof(IScriptEngine)].ShouldEqual(typeof(CSharpScriptInMemoryEngine));
}
[Fact]
public void ShouldRegisterTheReplEngineWhenReplIsEnabled()
{
_configMock.Setup(c => c.IsRepl).Returns(true);
_module.Initialize(_config);
_overrides[typeof(IScriptEngine)].ShouldEqual(typeof(CSharpReplEngine));
}
}
}
}