コード例 #1
0
        public void Should_Throw_On_FileNotFound()
        {
            var configurationSource   = new TextFileConfigurationSource("missing.txt", DefaultSeparator);
            var configurationProvider = new TextFileConfigurationProvider(configurationSource);

            Check.ThatCode(() => configurationProvider.Load()).ThrowsType(typeof(FileNotFoundException));
        }
コード例 #2
0
        public void Should_Throw_On_InvalidPath(string path)
        {
            var configurationSource   = new TextFileConfigurationSource(path, DefaultSeparator);
            var configurationProvider = new TextFileConfigurationProvider(configurationSource);

            Check.ThatCode(() => configurationProvider.Load()).ThrowsType(typeof(ArgumentException));
        }
コード例 #3
0
        public void Should_Handle_Custom_Separator(string key, string expectedValue)
        {
            var configurationSource   = new TextFileConfigurationSource(DefaultPath, '.');
            var configurationProvider = new TextFileConfigurationProvider(configurationSource);

            configurationProvider.Load();
            configurationProvider.TryGet(key, out var value);

            Check.That(value).Equals(expectedValue);
        }
コード例 #4
0
        public void Should_Load_Configuration_From_File(string key, string expectedValue)
        {
            var configurationSource   = new TextFileConfigurationSource(DefaultPath, DefaultSeparator);
            var configurationProvider = new TextFileConfigurationProvider(configurationSource);

            configurationProvider.Load();
            configurationProvider.TryGet(key, out var value);

            Check.That(value).Equals(expectedValue);
        }