コード例 #1
0
        public void DoesntGetNonExistingEnvironmentVariable()
        {
            var    sut = new InMemorySettingsSource(settings);
            string value;
            var    found = sut.TryGetRawSetting("ThisKeyDoesNotExist", out value);

            Assert.False(found, "Strangely, a non existing key was found");
        }
コード例 #2
0
        public void GetsExistingEnvironmentVariable()
        {
            var    sut = new InMemorySettingsSource(settings);
            string value;
            var    found = sut.TryGetRawSetting("SomeKey", out value);

            Assert.True(found, "SomeKey was not found");
            Assert.Equal("Some value", value);
        }
コード例 #3
0
        public MultipleSettingsSourceTests()
        {
            Environment.SetEnvironmentVariable("EnvironmentKey", "Environment value");
            Environment.SetEnvironmentVariable("CommonKey", "Environment value for common key");
            var environmentSettingsSource = new EnvironmentSettingsSource();

            var inMemorySettingsSource = new InMemorySettingsSource(
                new Dictionary <string, string>
            {
                { "InMemoryKey", "In memory value" },
                { "CommonKey", "In memory value for common key" }
            });

            sut = new MultipleSettingsSource(new List <IRawSettingsSource>
            {
                environmentSettingsSource,
                inMemorySettingsSource
            });
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestTokenReplacementSettingSource"/> class.
 /// </summary>
 public TestTokenReplacementSettingSource()
 {
     this.wrappedSource = new InMemorySettingsSource();
     this.source        = new TokenReplacementSettingsSource("__", this.wrappedSource);
 }