예제 #1
0
        public void PluginConfiguration_ParseConfiguration_NoSuchFile()
        {
            var currentConfiguration = PluginConfiguration.CurrentInstance;

            if (File.Exists(Path.Combine(currentConfiguration.Directory, "config.json")))
            {
                File.Delete(Path.Combine(currentConfiguration.Directory, "config.json"));
            }

            // Above has not been saved to a directory yet.
            Assert.IsNull(PluginConfiguration.ParseConfiguration(currentConfiguration.Directory));
        }
예제 #2
0
        public void PluginConfiguration_SaveToFile_SavesConfiguration()
        {
            var newPluginConfiguration = PluginConfiguration.CurrentInstance;

            newPluginConfiguration.DefaultConnection = new Connection(
                host: "foobar.languageweaver.com",
                port: 8001
                );

            newPluginConfiguration.LogLevel = "DEBUG";
            newPluginConfiguration.SaveToFile();
            var savedConfiguration = PluginConfiguration.ParseConfiguration(newPluginConfiguration.Directory);

            Assert.AreEqual(savedConfiguration.LogLevel, newPluginConfiguration.LogLevel);
            Assert.AreEqual(savedConfiguration.DefaultConnection.Value.Host, newPluginConfiguration.DefaultConnection.Value.Host);
            Assert.AreEqual(savedConfiguration.DefaultConnection.Value.Port, newPluginConfiguration.DefaultConnection.Value.Port);
            File.Delete(Path.Combine(newPluginConfiguration.Directory, "config.json"));
        }