コード例 #1
0
            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);
            }
コード例 #2
0
            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);
            }
コード例 #3
0
            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);
            }
コード例 #4
0
            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);
            }