public void ReturnsANewAssemblyAfterReloading() { var script = new TestScriptType { ScriptCompilerServiceProxy = new ScriptCompilerService(new CSharpScriptCompiler()), ScriptMetadataServiceProxy = new Mock<IScriptMetadataService>().Object, SourcePath = "test", Script = "namespace Tests { public class MyClass { }}" }; var originalAssembly = script.Assembly; script.Reload(); Assert.AreNotEqual(originalAssembly, script.Assembly); }
public void OnlyCompilesTheScriptOnTheFirstCall() { var scriptCompiler = new Mock<IScriptCompiler>(); scriptCompiler.Setup(m => m.Compile(It.IsAny<string>(), It.IsAny<string>())).Returns(new ScriptCompilerResults(true, Enumerable.Empty<string>(), GetType().Assembly.Location)); if (Directory.Exists("Scripts")) { Directory.Delete("Scripts", true); Directory.CreateDirectory("Scripts"); } var script = new TestScriptType { ScriptCompilerServiceProxy = new ScriptCompilerService(scriptCompiler.Object), ScriptMetadataServiceProxy = new Mock<IScriptMetadataService>().Object, SourcePath = "test", Script = "namespace Tests { public class MyClass { }}" }; script.Instantiate(); script.Instantiate(); scriptCompiler.Verify(m => m.Compile(It.IsAny<string>(), It.IsAny<string>()), Times.Once); }
public void SetUp() { _compilerService = new Mock<IScriptCompilerService>(); _metadataService = new Mock<IScriptMetadataService>(); _script = new TestScriptType { ScriptCompilerServiceProxy = _compilerService.Object, ScriptMetadataServiceProxy = _metadataService.Object, SourcePath = "test" }; }