public static void RetreivingAnObjectFromANestedFile(Foo result) { "Given a config file containing a Foo with a Bar of 'baz'" .Given(() => { using (var writer = new StreamWriter("foo.csx")) { writer.WriteLine(@"#r ""ConfigR.Features.dll"""); writer.WriteLine(@"using ConfigR.Features;"); writer.WriteLine(@"Add(""foo"", new NestedConfigurationFeature.Foo { Bar = ""baz"" });"); writer.Flush(); } }) .Teardown(() => File.Delete("foo.csx")); "And another config file which loads the first config file" .And(() => { using (var writer = new StreamWriter("bar.csx")) { writer.WriteLine(@"LoadScriptFile(""foo.csx"");"); writer.Flush(); } }) .Teardown(() => File.Delete("bar.csx")); "When I load the second config file" .When(() => Config.Global.LoadScriptFile("bar.csx")); "And I get the Foo" .And(() => result = Config.Global.Get<Foo>("foo")); "Then the Foo has a Bar of 'baz'" .Then(() => result.Bar.Should().Be("baz")); }
public static void RetreivingAnObject(Foo result) { "Given a local config file containing a Foo with a Bar of 'baz'" .Given(() => { using (var writer = new StreamWriter(LocalScriptFileConfig.Path)) { writer.WriteLine(@"#r ""ConfigR.Features.dll"""); writer.WriteLine(@"using ConfigR.Features;"); writer.WriteLine(@"Add(""foo"", new LocalConfigurationFeature.Foo { Bar = ""baz"" });"); writer.Flush(); } }) .Teardown(() => File.Delete(LocalScriptFileConfig.Path)); "When I get the Foo" .When(() => result = Config.Global.Get<Foo>("foo")); "Then the Foo has a Bar of 'baz'" .Then(() => result.Bar.Should().Be("baz")); }
public static void UsingStatementsFollowingLoadingOfAScriptContainingCode(Foo result) { "Given a config file containing a Foo with a Bar of 'baz'" .Given(() => { using (var writer = new StreamWriter("foo.csx")) { writer.WriteLine(@"#r ""ConfigR.Features.dll"""); writer.WriteLine(@"using ConfigR.Features;"); writer.WriteLine(@"Add(""foo"", new Foo { Bar = ""baz"" });"); writer.Flush(); } }) .Teardown(() => File.Delete("foo.csx")); "And another config file which loads the first config file as a script and then has using statements" .And(() => { using (var writer = new StreamWriter("bar.csx")) { writer.WriteLine(@"#r ""ConfigR.Features.dll"""); writer.WriteLine(@"#load ""foo.csx"""); writer.WriteLine(@"using ConfigR.Features;"); writer.Flush(); } }) .Teardown(() => File.Delete("bar.csx")); "When I load the second config file" .When(() => Config.Global.LoadScriptFile("bar.csx")); "And I get the Foo" .And(() => result = Config.Global.Get<Foo>("foo")); "Then the Foo has a Bar of 'baz'" .Then(() => result.Bar.Should().Be("baz")); }
public static void RetrievingAnObject(Foo result) { "Given a config file containing a Foo with a Bar of 'baz'" .f(() => { using (var writer = new StreamWriter("foo.csx")) { writer.WriteLine(@"#r ""ConfigR.Features.dll"""); writer.WriteLine(@"using ConfigR.Features;"); writer.WriteLine(@"Add(""foo"", new Foo { Bar = ""baz"" });"); writer.Flush(); } }) .Teardown(() => File.Delete("foo.csx")); "When I load the file" .f(() => Config.Global.LoadScriptFile("foo.csx")); "And I get the Foo" .f(() => result = Config.Global.Get<Foo>("foo")); "Then the Foo has a Bar of 'baz'" .f(() => result.Bar.Should().Be("baz")); }