private static void Main(string[] args) { // Script args can be passed in so the script / script packs can access them. // For example the sample script, the logger script pack is used which depends on these args var scriptArgs = new string[] { "-loglevel", "INFO" }; var options = new ScriptCsCatalogOptions { ScriptArgs = scriptArgs, References = new[] { typeof(IGreeter) } }; // You can add script by script //var catalog = new ScriptCsCatalog(new[] { "Scripts/Test.csx" }, options); // Or an entire folder var catalog = new ScriptCsCatalog("Scripts", options); // Script Packs can be used, for a sample you just have to: // - run command "scriptcs -install" in the Scripts folder of the folder, not the one in bin/Debug // - uncomment the commented code in Test.csx // If you want to test it with the "script by script" constructor, you need to copy the scriptcs_packages.config file // in the bin/Debug folder and run the "scriptcs -install" command var container = new CompositionContainer(catalog); var greeter = container.GetExportedValue <IGreeter>(); greeter.Greet("Hello MEF!"); Console.ReadLine(); }
public void KeepScriptsSeparatedShouldBeFalse() { // act var options = new ScriptCsCatalogOptions(); // assert options.KeepScriptsSeparated.ShouldBeFalse(); }
public void ShouldNotOverridesEmptyScriptArgs() { // arrange var options = new ScriptCsCatalogOptions { ScriptArgs = new string[0] }; // act var result = options.OverridesNullByDefault(); // assert result.ScriptArgs.ShouldBeEmpty(); }
public void ShouldNotOverridesEmptyReferences() { // arrange var options = new ScriptCsCatalogOptions { References = new Type[0] }; // act var result = options.OverridesNullByDefault(); // assert result.References.ShouldBeEmpty(); }
public void ShouldNotOverridesValuedKeepScriptsSeparated() { // arrange var options = new ScriptCsCatalogOptions { KeepScriptsSeparated = true }; // act var result = options.OverridesNullByDefault(); // assert result.KeepScriptsSeparated.ShouldBeTrue(); }
public void ShouldNotOverridesValuedScriptArgs() { // arrange var options = new ScriptCsCatalogOptions { ScriptArgs = new[] { "arg" } }; // act var result = options.OverridesNullByDefault(); // assert result.ScriptArgs.Length.ShouldEqual(1); result.ScriptArgs[0].ShouldEqual("arg"); }
public void ShouldNotOverridesValuedReferences() { // arrange var options = new ScriptCsCatalogOptions { References = new[] { typeof(OverridesNullByDefaultMethod) } }; // act var result = options.OverridesNullByDefault(); // assert result.References.Length.ShouldEqual(1); result.References[0].ShouldEqual(typeof(OverridesNullByDefaultMethod)); }
public void ShouldOverridesNullFileSystem() { // arrange var options = new ScriptCsCatalogOptions { FileSystem = null }; // act var result = options.OverridesNullByDefault(); // assert result.FileSystem.ShouldNotBeNull(); result.FileSystem.ShouldBeType <FileSystem>(); }
public void ShouldNotOverridesValuedFileSystem() { // arrange var fileSystemMock = new Mock <IFileSystem>().Object; var options = new ScriptCsCatalogOptions { FileSystem = fileSystemMock }; // act var result = options.OverridesNullByDefault(); // assert result.FileSystem.ShouldNotBeNull(); result.FileSystem.ShouldEqual(fileSystemMock); }