public static void ReferencingAnAssemblyFromTheApplicationFolder(string path, Foo foo) { dynamic config = null; "Given a remote config file which references a local assembly" .f(c => { var code = $@"#r ""ConfigR.Tests.Support.SampleDependency.dll"" using ConfigR.Tests.Support.SampleDependency; Config.Foo = new Foo {{ Bar = ""baz"" }}; "; var remoteAssemblyPath = Path.Combine(Path.GetTempPath(), "ConfigR.Tests.Support.SampleDependency.dll"); if (File.Exists(remoteAssemblyPath)) { File.Delete(remoteAssemblyPath); } ConfigFile.Create(code, path = Path.Combine(Path.GetTempPath(), Path.GetTempFileName())).Using(c); }); "When I load the config file" .f(async() => config = await new Config().UseRoslynCSharpLoader(path).LoadDynamic()); "And I get Foo" .f(() => foo = config.Foo <Foo>()); "Then Foo has a Bar of 'baz'" .f(() => foo.Bar.Should().Be("baz")); }
public static void ReferencingAnAssemblyFromTheScriptFolder(string path1, string path2, Foo foo) { dynamic config = null; "Given a remote assembly" .f(c => File.Copy( "ConfigR.Tests.Support.SampleDependency.dll", path1 = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetTempFileName(), "dll")), true)); "And a remote config file in the same folder, which references the assembly" .f(c => { var code = $@"#r ""{Path.GetFileName(path1)}"" using ConfigR.Tests.Support.SampleDependency; Config.Foo = new Foo {{ Bar = ""baz"" }}; "; ConfigFile.Create(code, path2 = Path.Combine(Path.GetTempPath(), Path.GetTempFileName())).Using(c); }); "When I load the config file" .f(async() => config = await new Config().UseRoslynCSharpLoader(path2).LoadDynamic()); "And I get Foo" .f(() => foo = config.Foo <Foo>()); "Then Foo has a Bar of 'baz'" .f(() => foo.Bar.Should().Be("baz")); }