public void can_pull_setting_class_out_of_multiple_data_settings_with_no_conflict() { var host = new HostManifest("host1"); host.RegisterSettings(data1); host.RegisterSettings(data4); var directive = host.GetDirective <OneDirective>(); directive.Name.ShouldEqual("Max"); directive.Age.ShouldEqual(7); }
public void respects_ordering_of_setting_data() { var host1 = new HostManifest("h1"); host1.RegisterSettings(data4); host1.RegisterSettings(data5); host1.GetDirective <OneDirective>().Age.ShouldEqual(7); var host2 = new HostManifest("h2"); host2.RegisterSettings(data5); host2.RegisterSettings(data4); host2.GetDirective <OneDirective>().Age.ShouldEqual(8); }
public void does_not_set_a_property_that_is_not_explicitly_configured() { var host = new HostManifest("h1"); host.RegisterSettings(data4); // the default value for Name is "somebody" host.GetDirective <OneDirective>().Name.ShouldEqual("somebody"); }
public void get_all_unique_directive_names() { var host = new HostManifest("h1"); host.RegisterSettings(data1); host.UniqueDirectiveNames().ShouldHaveTheSameElementsAs("OneDirective"); host.RegisterSettings(data2); host.UniqueDirectiveNames().ShouldHaveTheSameElementsAs("OneDirective", "ThreeDirective"); host.RegisterSettings(data3); host.UniqueDirectiveNames().ShouldHaveTheSameElementsAs("OneDirective", "ThreeDirective", "TwoDirective"); host.RegisterSettings(data4); host.UniqueDirectiveNames().ShouldHaveTheSameElementsAs("OneDirective", "ThreeDirective", "TwoDirective"); host.RegisterSettings(data5); host.UniqueDirectiveNames().ShouldHaveTheSameElementsAs("OneDirective", "ThreeDirective", "TwoDirective"); }
public void can_pull_setting_class_out_of_request_data() { var host = new HostManifest("host1"); host.RegisterSettings(data3); var directive = host.GetDirective <TwoDirective>(); directive.City.ShouldEqual("Austin"); directive.IsDomestic.ShouldBeTrue(); }
public void append_host_respects_setting_order() { var host1 = new HostManifest("h1"); host1.RegisterSettings(data4); var host2 = new HostManifest("h2"); host2.RegisterSettings(data5); host1.Append(host2); host1.CreateDiagnosticReport().First(x => x.Key == "OneDirective.Age").Value.ShouldEqual("7"); }
public void append_host_respects_setting_order() { var host1 = new HostManifest("h1"); host1.RegisterSettings(data4); var host2 = new HostManifest("h2"); host2.RegisterSettings(data5); host1.Append(host2); host1.GetDirective<OneDirective>().Age.ShouldEqual(7); }
public void do_not_bind_complex_child_if_no_data_exists() { var host = new HostManifest("host1"); var data = new SettingsData() .With("ComplexDirective.One.Name", "Thurgood") .With("ComplexDirective.One.Age", "57"); host.RegisterSettings(data); var complex = host.GetDirective <ComplexDirective>(); complex.One.ShouldNotBeNull(); complex.Two.ShouldBeNull(); }
public static HostManifest ReadFrom(string fileName, EnvironmentSettings environment) { var parser = new SettingsParser(fileName, environment.Overrides.ToDictionary()); new FileSystem().ReadTextFile(fileName, parser.ParseText); var hostName = Path.GetFileNameWithoutExtension(fileName); var host = new HostManifest(hostName); var settings = parser.Settings; host.RegisterSettings(settings); host.RegisterBottles(parser.References); return host; }
public void append_host_respects_setting_order() { var host1 = new HostManifest("h1"); host1.RegisterSettings(data4); var host2 = new HostManifest("h2"); host2.RegisterSettings(data5); host1.Append(host2); host1.GetDirective <OneDirective>().Age.ShouldEqual(7); }
public static HostManifest ReadFrom(string fileName, EnvironmentSettings environment) { var parser = new SettingsParser(fileName, environment.Overrides.ToDictionary()); new FileSystem().ReadTextFile(fileName, parser.ParseText); var hostName = Path.GetFileNameWithoutExtension(fileName); var host = new HostManifest(hostName); var settings = parser.Settings; host.RegisterSettings(settings); host.RegisterBottles(parser.References); return(host); }
public void can_pull_complex_settings() { var host = new HostManifest("host1"); var data = new SettingsData() .With("ComplexDirective.One.Name", "Thurgood") .With("ComplexDirective.One.Age", "57") .With("ComplexDirective.Two.City", "Joplin"); host.RegisterSettings(data); var complex = host.GetDirective <ComplexDirective>(); complex.One.Name.ShouldEqual("Thurgood"); complex.One.Age.ShouldEqual(57); complex.Two.City.ShouldEqual("Joplin"); }
public static HostManifest ReadFrom(string fileName) { var parser = new SettingsParser(fileName); try { new FileSystem().ReadTextFile(fileName, parser.ParseText); } catch (Exception ex) { var message = "Failed trying to read " + fileName; throw new ApplicationException(message, ex); } var hostName = Path.GetFileNameWithoutExtension(fileName); var host = new HostManifest(hostName); var settings = parser.Settings; host.RegisterSettings(settings); host.RegisterBottles(parser.References); return host; }
public void can_pull_setting_class_out_of_request_data() { var host = new HostManifest("host1"); host.RegisterSettings(data3); var directive = host.GetDirective<TwoDirective>(); directive.City.ShouldEqual("Austin"); directive.IsDomestic.ShouldBeTrue(); }
public void does_not_set_a_property_that_is_not_explicitly_configured() { var host = new HostManifest("h1"); host.RegisterSettings(data4); // the default value for Name is "somebody" host.GetDirective<OneDirective>().Name.ShouldEqual("somebody"); }
public void do_not_bind_complex_child_if_no_data_exists() { var host = new HostManifest("host1"); var data = new SettingsData() .With("ComplexDirective.One.Name", "Thurgood") .With("ComplexDirective.One.Age", "57"); host.RegisterSettings(data); var complex = host.GetDirective<ComplexDirective>(); complex.One.ShouldNotBeNull(); complex.Two.ShouldBeNull(); }
public void respects_ordering_for_diagnostics_report() { var host1 = new HostManifest("h1"); host1.RegisterSettings(data4); //age 7 host1.RegisterSettings(data5); //age 8 var dia = host1.CreateDiagnosticReport(); dia.Single().Value.ShouldEqual("7"); var host2 = new HostManifest("h1"); host2.RegisterSettings(data5); //age 8 host2.RegisterSettings(data4); //age 7 var dia2 = host2.CreateDiagnosticReport(); dia2.Single().Value.ShouldEqual("8"); }
public void respects_ordering_of_setting_data() { var host1 = new HostManifest("h1"); host1.RegisterSettings(data4); host1.RegisterSettings(data5); host1.GetDirective<OneDirective>().Age.ShouldEqual(7); var host2 = new HostManifest("h2"); host2.RegisterSettings(data5); host2.RegisterSettings(data4); host2.GetDirective<OneDirective>().Age.ShouldEqual(8); }
public void can_pull_complex_settings() { var host = new HostManifest("host1"); var data = new SettingsData() .With("ComplexDirective.One.Name", "Thurgood") .With("ComplexDirective.One.Age", "57") .With("ComplexDirective.Two.City", "Joplin"); host.RegisterSettings(data); var complex = host.GetDirective<ComplexDirective>(); complex.One.Name.ShouldEqual("Thurgood"); complex.One.Age.ShouldEqual(57); complex.Two.City.ShouldEqual("Joplin"); }
public void can_pull_setting_class_out_of_multiple_data_settings_with_no_conflict() { var host = new HostManifest("host1"); host.RegisterSettings(data1); host.RegisterSettings(data4); var directive = host.GetDirective<OneDirective>(); directive.Name.ShouldEqual("Max"); directive.Age.ShouldEqual(7); }