Last active
August 29, 2015 14:02
-
-
Save reidperyam/8c9f81fc54aecc359133 to your computer and use it in GitHub Desktop.
New ConfigR acceptance test, RedefiningAnObjectDefinedInLoadedFile, to demonstrate obscure functionality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Scenario] | |
public static void RedefiningAnObjectDefinedInLoadedFile(Foo result) | |
{ | |
"Given a config file containing a Foo with a Bar of 'baz'" | |
.Given(() => | |
{ | |
using (var writer = new StreamWriter("foo1.csx")) | |
{ | |
writer.WriteLine(@"#r ""ConfigR.Features.dll"""); | |
writer.WriteLine(@"using ConfigR.Features;"); | |
writer.WriteLine(@"Foo foo = new Foo { Bar = ""baz"" };"); | |
writer.WriteLine(@"Add(""foo"", foo);"); | |
writer.Flush(); | |
} | |
}) | |
.Teardown(() => File.Delete("foo1.csx")); | |
"And another config file containing a Foo with a Bar of 'bazzzzz' that loads the first config" | |
.Given(() => | |
{ | |
using (var writer = new StreamWriter("foo2.csx")) | |
{ | |
writer.WriteLine(@"#r ""ConfigR.Features.dll"""); | |
writer.WriteLine(@"#load ""foo1.csx"""); | |
writer.WriteLine(@"using ConfigR.Features;"); | |
writer.WriteLine(@"foo.Bar = ""bazzzzz"";"); | |
writer.Flush(); | |
} | |
}) | |
.Teardown(() => File.Delete("foo2.csx")); | |
"When I load the second file" | |
.And(() => Config.Global.LoadScriptFile("foo2.csx")); | |
"And I get the Foo" | |
.And(() => result = Config.Global.Get<Foo>("foo")); | |
"Then the Foo has a Bar of 'bazzzzz'" | |
.Then(() => result.Bar.Should().Be("bazzzzz")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment