public void AddingAConfigContextWithIncorrectPlaneNameThrowsException() { ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext = new ConfigContext("NotPlaneName", "ConfigContextName"); Assert.That(() => sut.UpsertConfigContext(configContext), Throws.ArgumentException); }
public void NewDescriptorIsStoredWhenSpecified() { var sut = new ConfigPlane(""); sut.PlaneDescriptor = new KeyValuePair <string, string>("MyPlaneDescriptorKey", "SomeValueThatIsIgnored"); Assert.That(sut.PlaneDescriptor.Key.Equals("MyPlaneDescriptorKey", StringComparison.InvariantCulture)); Assert.That(sut.PlaneDescriptor.Value.Equals(String.Empty, StringComparison.InvariantCulture)); }
public void GetConfig_ReturnsNullIfKeyNotFound() { ConfigPlane sut = new ConfigPlane("MyPlane"); sut.UpsertConfigValue("MyContext", "MyConfigKey", "MyConfigValue"); sut.SearchContext = "MyContext"; string configValue = sut.GetConfigValue("MyConfigUnkownKey"); Assert.IsNull(configValue); }
public void GetConfigKeyReport_ReturnsCorrectConfigContextame() { ConfigPlane sut = new ConfigPlane("PlaneName"); sut.SearchContext = "SomeContext"; sut.UpsertConfigValue("SomeContext", "MyKey", "MyValue"); var configKeyReport = sut.GetConfigKeyReport("MyKey"); Assert.That(configKeyReport.ConfigContextName == "SomeContext"); }
public void GetConfigKeyReport_ReturnsReportIfKeyFound() { ConfigPlane sut = new ConfigPlane("PlaneName"); sut.SearchContext = "SomeContext"; sut.UpsertConfigValue("SomeContext", "MyKey", "MyValue"); var configKeyReport = sut.GetConfigKeyReport("MyKey"); Assert.NotNull(configKeyReport); }
public void ChangingLevelNameAfterSetting_CausesException() { KeyValuePair <string, string> kvp = new KeyValuePair <string, string>("NewName", "Fred"); ConfigPlane sut = new ConfigPlane("FirstName"); Assert.That( () => sut.PlaneDescriptor = kvp, Throws.Exception ); }
public void GetConfigKeyReport_ReturnsCorrectValuesForADefaultConfigSource() { ConfigPlane sut = new ConfigPlane("PlaneName"); sut.SearchContext = "SomeContext"; sut.UpsertDefaultConfigValue("MyKey", "MyValue"); var configKeyReport = sut.GetConfigKeyReport("MyKey"); Assert.That(configKeyReport.ConfigSource == ConfigKeySource.Default); }
public void TryGetValue_ReturnsFalseIfKeyNotFound() { ConfigPlane sut = new ConfigPlane("MyPlane"); sut.UpsertConfigValue("MyContext", "MyConfigKey", "MyConfigValue"); sut.SearchContext = "MyContext"; string configValue; bool result = sut.TryGetConfigValue("MyConfigUnkownKey", out configValue); Assert.IsFalse(result); }
public void GetConfig_ReturnsValueIfKeyFound() { ConfigPlane sut = new ConfigPlane("MyPlane"); sut.UpsertConfigValue("MyContext", "MyConfigKey", "MyConfigValue"); sut.SearchContext = "MyContext"; string configValue = sut.GetConfigValue("MyConfigKey"); Assert.IsNotNull(configValue); Assert.AreEqual(configValue, "MyConfigValue"); }
public void GetValue_UsesDefaultIfNoConfigContextProvided() { ConfigPlane sut = new ConfigPlane("PlaneName"); sut.UpsertDefaultConfigValue("SomeKey", "SomeValue"); var configValue = sut.GetConfigValue("SomeKey"); Assert.IsNotNull(configValue); Assert.That(configValue.Equals("SomeValue", StringComparison.InvariantCulture)); }
public void AddingNewConfigContext_NewConfigContextStored() { ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext = new ConfigContext("PlaneName", "ConfigContextName"); sut.UpsertConfigContext(configContext); IConfigContext readConfigContext = sut.GetConfigContext("ConfigContextName"); Assert.IsNotNull(readConfigContext); Assert.That(readConfigContext.PlaneDescriptor.Key == "PlaneName"); Assert.That(readConfigContext.PlaneDescriptor.Value == "ConfigContextName"); }
public void TryGetValue_OutputsNullIfKeyNotFound() { ConfigPlane sut = new ConfigPlane("MyPlane"); sut.UpsertConfigValue("MyContext", "MyConfigKey", "MyConfigValue"); sut.SearchContext = "MyContext"; string configValue; sut.TryGetConfigValue("MyConfigUnkownKey", out configValue); Assert.IsNull(configValue); }
public void GetValue_AttemptsToGetValueFromChildIfNotFoundLocally() { var child = MockRepository.GenerateMock <IConfigPlane>(); ConfigPlane sut = new ConfigPlane("MyPlane"); sut.Child = child; sut.SearchContext = "MyContext"; sut.GetConfigValue("MyConfigUnkownKey"); child.AssertWasCalled(x => x.GetConfigValue(Arg <string> .Is.Equal("MyConfigUnkownKey")), options => options.Repeat.Once()); }
public void TryGetValue_OutputsValueIfKeyFound() { ConfigPlane sut = new ConfigPlane("MyPlane"); sut.UpsertConfigValue("MyContext", "MyConfigKey", "MyConfigValue"); sut.SearchContext = "MyContext"; string configValue; sut.TryGetConfigValue("MyConfigKey", out configValue); Assert.IsNotNull(configValue); Assert.AreEqual(configValue, "MyConfigValue"); }
public void GetConfigKeyReport_ReturnsNullForUnknownKey() { ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext1 = new ConfigContext("PlaneName", "ConfigContextName1"); configContext1.UpsertConfigValue("TestConfig", "configContext1Value"); sut.UpsertConfigContext(configContext1); sut.UpsertDefaultConfigValue("SomeKey", "SomeValue"); sut.SearchContext = "ConfigContextName1"; var configKeyReport = sut.GetConfigKeyReport("UnknownTestConfig"); Assert.IsNull(configKeyReport); }
public void UpsertingConfigValue_WhereNoConfigContextExists_OneIsCreatedAndConfigStoredOnTheNewConfigContext() { string configValue; ConfigPlane sut = new ConfigPlane("PlaneName"); sut.UpsertConfigValue("MyNewConfigContext", "MyKey", "MyValue"); configValue = sut.GetConfigValue("MyNewConfigContext", "MyKey"); Assert.IsNotNull(sut.GetConfigContext("MyNewConfigContext")); Assert.IsNotNull(configValue); Assert.That(configValue.Equals("MyValue", StringComparison.InvariantCulture)); }
public void SettingContextToAnUnusedContext_GetConfigValueWillReturnValueFromDefault() { ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext1 = new ConfigContext("PlaneName", "ConfigContextName1"); configContext1.UpsertConfigValue("SomeKey", "configContext1Value"); sut.UpsertConfigContext(configContext1); sut.UpsertDefaultConfigValue("SomeKey", "SomeValue"); sut.SearchContext = "Invalid"; var configValue = sut.GetConfigValue("SomeKey"); Assert.IsNotNull(configValue); Assert.That(configValue.Equals("SomeValue", StringComparison.InvariantCulture)); }
public void GetValue_UsesDefaultIfNotFoundOnConfigContext() { ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext1 = new ConfigContext("PlaneName", "ConfigContextName1"); configContext1.UpsertConfigValue("TestConfig", "configContext1Value"); sut.UpsertConfigContext(configContext1); sut.UpsertDefaultConfigValue("SomeKey", "SomeValue"); var configValue = sut.GetConfigValue("ConfigContextName1", "SomeKey"); Assert.IsNotNull(configValue); Assert.That(configValue.Equals("SomeValue", StringComparison.InvariantCulture)); }
public void GetConfigKeyReport_ReportsFromChildIfKeyNotFound() { ConfigPlane sut = new ConfigPlane("TopPlane"); ConfigPlane child = new ConfigPlane("ChildPlane"); child.SearchContext = "SomeContext"; child.UpsertConfigValue("SomeContext", "MyKey", "MyValue"); sut.Child = child; sut.SearchContext = "SomeSearchContext"; var configKeyReport = sut.GetConfigKeyReport("MyKey"); Assert.NotNull(configKeyReport); }
public void TryGetConfigContext_OutputsNullIfNotPresent() { IConfigContext readConfigContext; ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext1 = new ConfigContext("PlaneName", "ConfigContextName1"); configContext1.UpsertConfigValue("TestConfig", "configContext1Value"); sut.UpsertConfigContext(configContext1); ConfigContext configContext2 = new ConfigContext("PlaneName", "ConfigContextName2"); configContext2.UpsertConfigValue("TestConfig", "configContext2Value"); sut.UpsertConfigContext(configContext2); sut.TryGetConfigContext("UnknownConfigContextName", out readConfigContext); Assert.IsNull(readConfigContext); }
public void TryGetConfigContext_ReturnsTrueIfPresent() { IConfigContext readConfigContext; ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext1 = new ConfigContext("PlaneName", "ConfigContextName1"); configContext1.UpsertConfigValue("TestConfig", "configContext1Value"); sut.UpsertConfigContext(configContext1); ConfigContext configContext2 = new ConfigContext("PlaneName", "ConfigContextName2"); configContext2.UpsertConfigValue("TestConfig", "configContext2Value"); sut.UpsertConfigContext(configContext2); Assert.IsTrue(sut.TryGetConfigContext("ConfigContextName2", out readConfigContext)); Assert.IsNotNull(readConfigContext); }
public void TryGetConfigContext_OutputsValueIfPresent() { IConfigContext readConfigContext; ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext1 = new ConfigContext("PlaneName", "ConfigContextName1"); configContext1.UpsertConfigValue("TestConfig", "configContext1Value"); sut.UpsertConfigContext(configContext1); ConfigContext configContext2 = new ConfigContext("PlaneName", "ConfigContextName2"); configContext2.UpsertConfigValue("TestConfig", "configContext2Value"); sut.UpsertConfigContext(configContext2); Assert.IsTrue(sut.TryGetConfigContext("ConfigContextName2", out readConfigContext)); Assert.That(readConfigContext.PlaneDescriptor.Value.Equals("ConfigContextName2", StringComparison.InvariantCulture)); }
public void TryGetValue_PassesToChildIfKeyNotFound() { string configValue; var child = MockRepository.GenerateMock <IConfigPlane>(); ConfigPlane sut = new ConfigPlane("MyPlane"); sut.Child = child; sut.SearchContext = "MyContext"; sut.TryGetConfigValue("MyConfigUnkownKey", out configValue); child.AssertWasCalled(x => x.TryGetConfigValue(Arg <string> .Is.Equal("MyConfigUnkownKey"), out Arg <string> .Out("hello").Dummy ), options => options.Repeat.Once() ); }
public void GettingConfigContext_ReturnsNullIfNotPresent() { ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext1 = new ConfigContext("PlaneName", "ConfigContextName1"); configContext1.UpsertConfigValue("TestConfig", "configContext1Value"); sut.UpsertConfigContext(configContext1); ConfigContext configContext2 = new ConfigContext("PlaneName", "ConfigContextName2"); configContext2.UpsertConfigValue("TestConfig", "configContext2Value"); sut.UpsertConfigContext(configContext2); IConfigContext readConfigContext = sut.GetConfigContext("UnknowConfigContextName"); Assert.IsNull(readConfigContext); }
public void GetValue_UsesContextIfNoConfigContextNameprovided() { string configValue; ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext1 = new ConfigContext("PlaneName", "ConfigContextName1"); configContext1.UpsertConfigValue("TestConfig", "configContext1Value"); sut.UpsertConfigContext(configContext1); sut.UpsertDefaultConfigValue("SomeKey", "SomeValue"); sut.SearchContext = "ConfigContextName1"; configValue = sut.GetConfigValue("TestConfig"); Assert.IsNotNull(configValue); Assert.That(configValue.Equals("configContext1Value", StringComparison.InvariantCulture)); }
public void GetValue_UsesCorrectConfigContextForValue() { string configValue; ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext1 = new ConfigContext("PlaneName", "ConfigContextName1"); configContext1.UpsertConfigValue("TestConfig", "configContext1Value"); sut.UpsertConfigContext(configContext1); ConfigContext configContext2 = new ConfigContext("PlaneName", "ConfigContextName2"); configContext2.UpsertConfigValue("TestConfig", "configContext2Value"); sut.UpsertConfigContext(configContext2); configValue = sut.GetConfigValue("ConfigContextName1", "TestConfig"); Assert.IsNotNull(configValue); Assert.That(configValue.Equals("configContext1Value", StringComparison.InvariantCulture)); }
public void GettingConfigContext_ReturnsConfigContextIfPresent() { ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext1 = new ConfigContext("PlaneName", "ConfigContextName1"); configContext1.UpsertConfigValue("TestConfig", "configContext1Value"); sut.UpsertConfigContext(configContext1); ConfigContext configContext2 = new ConfigContext("PlaneName", "ConfigContextName2"); configContext2.UpsertConfigValue("TestConfig", "configContext2Value"); sut.UpsertConfigContext(configContext2); IConfigContext readConfigContext = sut.GetConfigContext("ConfigContextName2"); Assert.IsNotNull(readConfigContext); Assert.That(readConfigContext.PlaneDescriptor.Key == "PlaneName"); Assert.That(readConfigContext.PlaneDescriptor.Value == "ConfigContextName2"); }
public void AddingExistingConfigContext_NewConfigContextSaved() { ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext1 = new ConfigContext("PlaneName", "ConfigContextName"); configContext1.UpsertConfigValue("TestConfig", "configContext1Value"); sut.UpsertConfigContext(configContext1); ConfigContext configContext2 = new ConfigContext("PlaneName", "ConfigContextName"); configContext2.UpsertConfigValue("TestConfig", "configContext2Value"); sut.UpsertConfigContext(configContext2); IConfigContext readConfigContext = sut.GetConfigContext("ConfigContextName"); Assert.IsNotNull(readConfigContext); Assert.That(readConfigContext.PlaneDescriptor.Key == "PlaneName"); Assert.That(readConfigContext.PlaneDescriptor.Value == "ConfigContextName"); Assert.That(readConfigContext.GetConfigValue("TestConfig").Equals("configContext2Value", StringComparison.InvariantCulture)); }
public void TryGetValue_UsesDefaultValueIfNoValueOnConfigContext() { string configValue; ConfigPlane sut = new ConfigPlane("PlaneName"); ConfigContext configContext1 = new ConfigContext("PlaneName", "ConfigContextName1"); configContext1.UpsertConfigValue("TestConfig", "configContext1Value"); sut.UpsertConfigContext(configContext1); ConfigContext configContext2 = new ConfigContext("PlaneName", "ConfigContextName2"); configContext2.UpsertConfigValue("TestConfig", "configContext2Value"); sut.UpsertConfigContext(configContext2); sut.SearchContext = "ConfigContextName1"; sut.UpsertDefaultConfigValue("ConfigOnlyInDefault", "ADefaultValue"); Assert.IsTrue(sut.TryGetConfigValue("ConfigOnlyInDefault", out configValue)); Assert.IsNotNull(configValue); Assert.That(configValue.Equals("ADefaultValue", StringComparison.InvariantCulture)); }
public void UsingInvalidContext_CausesException() { ConfigPlane sut = new ConfigPlane("PlaneName"); Assert.That(() => sut.UpsertConfigValue("MyKey", "MyValue"), Throws.ArgumentException); }