<commit_before>﻿using NUnit.Framework;

namespace Centroid.Tests
{
    [TestFixture]
    public class ConfigTest
    {
        private const string SharedFilePath = @"..\..\..\..\config.json";

        private const string JsonConfig = @"
            {
                ""Dev"": {
                    ""Database"": {
                        ""Server"": ""the-dev-database""
                    }
                },
                ""Prod"": {
                    ""Database"": {
                        ""Server"": ""the-prod-database""
                    }
                },
                ""All"": {
                    ""SharedNest"": {
                        ""SharedKey"": ""shared value""
                    }
                }
            }
        ";

        [Test]
        public void environment_property_shows_correct_environment()
        {
            var config = new Config(JsonConfig).WithEnvironment("Prod");
            Assert.AreEqual("Prod", config.Environment);
        }

        [Test]
        public void environment_specific_config_is_included_correctly()
        {
            var config = new Config(JsonConfig).WithEnvironment("Dev");
            Assert.AreEqual("the-dev-database", config.Database.Server);
        }

        [Test]
        public void shared_config_is_included_correctly()
        {
            var config = new Config(JsonConfig).WithEnvironment("Prod");
            Assert.AreEqual("shared value", config.SharedNest.SharedKey);
        }

        [Test]
        public void pascal_case_can_be_used_with_snake_cased_json()
        {
            dynamic config = new Config(@"{ ""snake_key"": ""some value"" }");
            Assert.AreEqual("some value", config.SnakeKey);
        }

        [Test]
        public void can_load_config_from_file()
        {
            Assert.DoesNotThrow(() =>
                {
                    dynamic config = Config.FromFile(SharedFilePath);
                    Assert.NotNull(config.All);
                });
        }
    }
}<commit_msg>Make config file path in tests cross platform<commit_after>﻿using NUnit.Framework;
using System.IO;

namespace Centroid.Tests
{
    [TestFixture]
    public class ConfigTest
    {
        private readonly string sharedFilePath;

        private const string JsonConfig = @"
            {
                ""Dev"": {
                    ""Database"": {
                        ""Server"": ""the-dev-database""
                    }
                },
                ""Prod"": {
                    ""Database"": {
                        ""Server"": ""the-prod-database""
                    }
                },
                ""All"": {
                    ""SharedNest"": {
                        ""SharedKey"": ""shared value""
                    }
                }
            }
        ";

        public ConfigTest()
        {
            sharedFilePath = Path.Combine("..", "..", "..", "..", "config.json");
        }

        [Test]
        public void environment_property_shows_correct_environment()
        {
            var config = new Config(JsonConfig).WithEnvironment("Prod");
            Assert.AreEqual("Prod", config.Environment);
        }

        [Test]
        public void environment_specific_config_is_included_correctly()
        {
            var config = new Config(JsonConfig).WithEnvironment("Dev");
            Assert.AreEqual("the-dev-database", config.Database.Server);
        }

        [Test]
        public void shared_config_is_included_correctly()
        {
            var config = new Config(JsonConfig).WithEnvironment("Prod");
            Assert.AreEqual("shared value", config.SharedNest.SharedKey);
        }

        [Test]
        public void pascal_case_can_be_used_with_snake_cased_json()
        {
            dynamic config = new Config(@"{ ""snake_key"": ""some value"" }");
            Assert.AreEqual("some value", config.SnakeKey);
        }

        [Test]
        public void can_load_config_from_file()
        {
            Assert.DoesNotThrow(() =>
                {
                    dynamic config = Config.FromFile(sharedFilePath);
                    Assert.NotNull(config.All);
                });
        }
    }
}
{'fraction_non_alphanumeric': 0.11972498814604078, 'fraction_numerical': 0.0, 'mean_word_length': 1.375563063063063, 'pattern_counts': {'":': 20, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4536904', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1033, 'n_words': 181}