public void Read_When_ConfigurationFilePath_With_Env_Variable_Containing_Double_Underscores_Returns_Dictionary_With_Value_Containing_Colon() { // Arrange var filePath = $"test-file-{Random.Int()}"; var testPropertyName = "test__Property"; var testPropertyNameTwo = "test__Property__Two"; var testPropertyValue = Random.Int().ToString(); var testPropertyValueTwo = Random.Int().ToString(); var expected = new { iis = new { env = new string[] { $"{testPropertyName}={testPropertyValue}", $"{testPropertyNameTwo}={testPropertyValueTwo}" } } }; File.WriteAllText(filePath, JsonConvert.SerializeObject(expected, Formatting.Indented)); var sut = new AmazonEBConfigurationProvider(configurationFilePath: filePath); // Act var result = sut.Read(); // Assert File.Delete(filePath); result.ShouldNotBeNull(); result.ShouldNotBeEmpty(); result[testPropertyName.Replace("__", ":")].ShouldBe(testPropertyValue); result[testPropertyNameTwo.Replace("__", ":")].ShouldBe(testPropertyValueTwo); }
public void Read_When_ConfigurationFilePath_DoesNotExist_Returns_Empty_Dictionary() { // Arrange var sut = new AmazonEBConfigurationProvider(configurationFilePath: "/file-that-does-not-exist"); // Act var result = sut.Read(); // Assert result.ShouldNotBeNull(); result.ShouldBeEmpty(); }
public void Read_When_CachedConfiguration_Set_Returns_CachedConfiguration() { // Arrange var expected = new Dictionary <string, string>(); var sut = new AmazonEBConfigurationProvider(); AmazonEBConfigurationProvider.CachedConfiguration = expected; // Act var result = sut.Read(); // Assert result.ShouldBe(expected); }
public void Read_When_ConfigurationFilePath_Without_Env_Variable_Returns_Empty_Dictionary() { // Arrange var filePath = $"test-file-{Random.Int()}"; File.WriteAllText(filePath, "{}"); var sut = new AmazonEBConfigurationProvider(configurationFilePath: filePath); // Act var result = sut.Read(); // Assert File.Delete(filePath); result.ShouldNotBeNull(); result.ShouldBeEmpty(); }