public async Task WhenCloudSettingIsEmptyAppSettingIsReturned() { // Arrange var configurationService = new TestableConfigurationService(); configurationService.CloudSettingStub = null; configurationService.AppSettingStub = string.Empty; configurationService.ConnectionStringStub = "abc"; // Act string result = await configurationService.ReadSettingAsync("any"); // Assert Assert.Equal(configurationService.ConnectionStringStub, result); }
public async Task WhenCloudSettingIsNullStringNullIsReturned() { // Arrange var configurationService = new TestableConfigurationService(); configurationService.CloudSettingStub = "null"; configurationService.AppSettingStub = "bla"; configurationService.ConnectionStringStub = "abc"; // Act string result = await configurationService.ReadSettingAsync("any"); // Assert Assert.Null(result); }
public async Task WhenSettingIsNotEmptySecretInjectorIsRan() { // Arrange var secretInjectorMock = new Mock <ISecretInjector>(); secretInjectorMock.Setup(x => x.InjectAsync(It.IsAny <string>())) .Returns <string>(s => Task.FromResult(s + "parsed")); var configurationService = new TestableConfigurationService(secretInjectorMock.Object); configurationService.CloudSettingStub = "somevalue"; // Act string result = await configurationService.ReadSettingAsync("any"); // Assert Assert.Equal("somevalueparsed", result); }
public async Task GivenNotInjectedSettingNameSecretInjectorIsNotRan(string settingName) { // Arrange var secretInjectorMock = new Mock <ISecretInjector>(); secretInjectorMock.Setup(x => x.InjectAsync(It.IsAny <string>())) .Returns <string>(s => Task.FromResult(s + "parsed")); var configurationService = new TestableConfigurationService(secretInjectorMock.Object); configurationService.CloudSettingStub = "somevalue"; // Act string result = await configurationService.ReadSettingAsync(settingName); // Assert secretInjectorMock.Verify(x => x.InjectAsync(It.IsAny <string>()), Times.Never); Assert.Equal("somevalue", result); }