public void LoadMethodCanHandleEmptyValue()
        {
            var yaml = @"name:";
            var yamlConfigSrc = new YamlConfigurationSource(TestStreamHelpers.ArbitraryFilePath);

            yamlConfigSrc.Load(TestStreamHelpers.StringToStream(yaml));

            Assert.Equal(string.Empty, yamlConfigSrc.Get("name"));
        }
        public void NonObjectRootIsInvalid()
        {
            var yaml = @"test";
            var yamlConfigSrc = new YamlConfigurationSource("Foo");

            var exception = Assert.Throws<FormatException>(
                () => yamlConfigSrc.Load(TestStreamHelpers.StringToStream(yaml)));

            Assert.NotNull(exception.Message);
        }
        public void SupportAndIgnoreComments()
        {
            var yaml = @"# Comments
                # Comments
                name: test #foo
                address:
                    street: Something street # Comments
                    zipcode: 12345";
            var yamlConfigSrc = new YamlConfigurationSource("Foo");

            yamlConfigSrc.Load(TestStreamHelpers.StringToStream(yaml));

            Assert.Equal("test", yamlConfigSrc.Get("name"));
            Assert.Equal("Something street", yamlConfigSrc.Get("address:street"));
            Assert.Equal("12345", yamlConfigSrc.Get("address:zipcode"));
        }
        public void LoadKeyValuePairsFromValidYaml()
        {
            var yaml = @"
            firstname: test
            test.last.name: last.name
            residential.address:
            street.name: Something street
            zipcode: 12345";
            var yamlConfigSrc = new YamlConfigurationSource(TestStreamHelpers.ArbitraryFilePath);

            yamlConfigSrc.Load(TestStreamHelpers.StringToStream(yaml.TrimStart()));

            Assert.Equal("test", yamlConfigSrc.Get("firstname"));
            Assert.Equal("last.name", yamlConfigSrc.Get("test.last.name"));
            Assert.Equal("Something street", yamlConfigSrc.Get("residential.address:STREET.name"));
            Assert.Equal("12345", yamlConfigSrc.Get("residential.address:zipcode"));
        }
        public void SupportForMultiple()
        {
            var yaml = @"---
            name: test #foo
            address:
            home:
            street: Some Home Address
            zipcode: 12345
            work:
            street: Some Work Address
            zipcode: 54321
            ...";
            var yamlConfigSrc = new YamlConfigurationSource(TestStreamHelpers.ArbitraryFilePath);

            yamlConfigSrc.Load(TestStreamHelpers.StringToStream(yaml));

            Assert.Equal("Some Home Address", yamlConfigSrc.Get("address:home:street"));
            Assert.Equal("12345", yamlConfigSrc.Get("address:home:zipcode"));
            Assert.Equal("Some Work Address", yamlConfigSrc.Get("address:work:street"));
            Assert.Equal("54321", yamlConfigSrc.Get("address:work:zipcode"));
        }