Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save reidperyam/8c9f81fc54aecc359133 to your computer and use it in GitHub Desktop.
Save reidperyam/8c9f81fc54aecc359133 to your computer and use it in GitHub Desktop.
New ConfigR acceptance test, RedefiningAnObjectDefinedInLoadedFile, to demonstrate obscure functionality
[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