<commit_before>﻿using Newtonsoft.Json;

namespace SchemaZen.Tests;

public static class ConfigHelper {
	private static readonly IDictionary<string, string> config;

	static ConfigHelper() {
		var settingsString = File.ReadAllText("appsettings.json");
		config = JsonConvert.DeserializeObject<IDictionary<string, string>>(settingsString);
	}

	public static string TestDB => GetSetting("testdb");

	public static string TestSchemaDir => GetSetting("test_schema_dir");

	public static string SqlDbDiffPath => GetSetting("SqlDbDiffPath");

	private static string GetSetting(string key) {
		var val = Environment.GetEnvironmentVariable(key);
		return val ?? (config.TryGetValue(key, out val) ? val : null);
	}<commit_msg>Fix build warning<commit_after>﻿using Newtonsoft.Json;

namespace SchemaZen.Tests;

public static class ConfigHelper {
	private static readonly IDictionary<string, string> config;

	static ConfigHelper() {
		var settingsString = File.ReadAllText("appsettings.json");
		config = JsonConvert.DeserializeObject<IDictionary<string, string>>(settingsString);
	}

	public static string TestDB => GetSetting("testdb");

	public static string TestSchemaDir => GetSetting("test_schema_dir");

	private static string GetSetting(string key) {
		var val = Environment.GetEnvironmentVariable(key);
		if (val != null) return val;

		if (config.TryGetValue(key, out val)) return val;

		throw new Exception(
			$"Setting: {key} not found in appsettings or environment variable");
	}
{'fraction_non_alphanumeric': 0.10444743935309973, 'fraction_numerical': 0.0, 'mean_word_length': 6.139423076923077, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 14, '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': '1525810', 'n_tokens_mistral': 429, 'n_tokens_neox': 404, 'n_words': 117}