public void ConfigurationProvider_GetImdbBaseUrl_WhenImdbBaseUrlSettingsExistsAndEndsWithForwardSlah_ShouldReturnValueEndingInForwardSlash() { // Arrange var expectedImdbBaseUrlValue = "http://goingtonowhere.com/"; var configurationRoot = AddAppSettingInConfigFile(ImdbBaseUrlKey, expectedImdbBaseUrlValue); var configurationProviderUnderTest = new ConfigurationProvider(configurationRoot); // Act var actualImdnBaseUrl = configurationProviderUnderTest.GetImdbBaseUrl(); // Assert Assert.AreEqual(expectedImdbBaseUrlValue, actualImdnBaseUrl, $"We we expecting the actualImdnBaseUrl to be '{expectedImdbBaseUrlValue}', but found that is it '{actualImdnBaseUrl}' instead"); }
public void ConfigurationProvider_GetImdbBaseUrl_WhenAppSettingsSectionIsMissing_ShouldThrow() { var configurationRoot = GetConfigurationRoot("SomeIrrelevantConfigSectionName", ImdbBaseUrlKey, "irrelevantValue"); var configurationProviderUnderTest = new ConfigurationProvider(configurationRoot); try { // Act configurationProviderUnderTest.GetImdbBaseUrl(); Assert.Fail("We were expecting an exception of type: ConfigurationSettingKeyNotFoundException to be thrown, but no exception was thrown"); } catch (ConfigurationSettingKeyNotFoundException e) { // Assert AssertEx.AssertExceptionMessageContains(new[] { "AppSettings section itself is missing", "does not contain the key", ImdbBaseUrlKey }, e); } }
public void ConfigurationProvider_GetImdbBaseUrl_WhenImdbBaseUrlKeyAndValueAreNonExistant_ShouldThrow() { // Arrange var configurationRoot = AddAppSettingInConfigFile(null, null); var configurationProviderUnderTest = new ConfigurationProvider(configurationRoot); try { // Act configurationProviderUnderTest.GetImdbBaseUrl(); Assert.Fail("We were expecting an exception of type: ConfigurationSettingKeyNotFoundException to be thrown, but no exception was thrown"); } catch (ConfigurationSettingKeyNotFoundException e) { // Assert AssertEx.AssertExceptionMessageContains(new[] { "does not contain the key", ImdbBaseUrlKey }, e); } }
public void ConfigurationProvider_GetImdbBaseUrl_WhenImdbBaseUrlKeyExistsButValueIsEmpty_ShouldThrow() { // Arrange var emptyImdbBaseUrlValue = string.Empty; var configurationRoot = AddAppSettingInConfigFile(ImdbBaseUrlKey, emptyImdbBaseUrlValue); var configurationProviderUnderTest = new ConfigurationProvider(configurationRoot); try { // Act configurationProviderUnderTest.GetImdbBaseUrl(); Assert.Fail("We were expecting an exception of type: ConfigurationSettingMissingException to be thrown, but no exception was thrown"); } catch (ConfigurationSettingMissingException e) { // Assert AssertEx.AssertExceptionMessageContains(new[] { "does not contain a value", "key", ImdbBaseUrlKey }, e); } }