public void InitializeCreatesSectionGroupTest() { IConfigurationManager configurationManager = Substitute.For <IConfigurationManager>(); IConfiguration configuration = Substitute.For <IConfiguration>(); configurationManager.OpenConfiguration(ConfigurationUserLevel.None).ReturnsForAnyArgs(configuration); configuration.GetSectionGroup("userSettings").Returns((IConfigurationSectionGroup) => null); var testView = TestClientSettingsView.Create("Foo", SettingsLocation.Executable, configurationManager, null); configuration.Received().AddSectionGroup("userSettings"); }
public void RoundTripTest(string value) { // Ensure values round trip successfully IConfigurationSectionGroup sectionGroup = Substitute.For <IConfigurationSectionGroup>(); IConfiguration configuration = Substitute.For <IConfiguration>(); configuration.GetSectionGroup("userSettings").Returns(sectionGroup); IConfigurationManager configurationManager = Substitute.For <IConfigurationManager>(); configurationManager.OpenConfiguration(ConfigurationUserLevel.None).ReturnsForAnyArgs(configuration); var testView = TestClientSettingsView.Create("Foo", SettingsLocation.Executable, configurationManager, null); testView.SaveSetting("foo", value).Should().BeTrue(); testView.GetSetting("foo").Should().Be(value); }
public void InitializeCreatesClientSettingsSection() { // Ensure initialization creates a client settings section if it doesn't have one IConfigurationSectionGroup sectionGroup = Substitute.For <IConfigurationSectionGroup>(); IConfiguration configuration = Substitute.For <IConfiguration>(); configuration.GetSectionGroup("userSettings").Returns(sectionGroup); IConfigurationManager configurationManager = Substitute.For <IConfigurationManager>(); configurationManager.OpenConfiguration(ConfigurationUserLevel.None).ReturnsForAnyArgs(configuration); var testView = TestClientSettingsView.Create("Foo", SettingsLocation.Executable, configurationManager, null); configuration.DidNotReceiveWithAnyArgs().AddSectionGroup(""); sectionGroup.Received().Add("Foo", Arg.Any <ClientSettingsSection>()); }