public ApplicationContext()
        {
            Settings = new Settings();
            Settings.Load(Settings.SettingsFolder);

            //todo: stop ApplicationContext with EventManager and BitcoinNode ?
            eventManager.Start();
        }
        public void TestSaveImpossible()
        {
            string testFolder = TestUtils.PrepareTestFolder(typeof(TestSettings), "TestSaveImpossible", "*.json");

            Directory.CreateDirectory(Path.Combine(testFolder, Settings.SettingsFilename));

            Settings settings = new Settings();
            Assert.Throws<UnauthorizedAccessException>(() => settings.Save(testFolder));
        }
        public void Test()
        {
            string testFolder = TestUtils.PrepareTestFolder(typeof(TestSettings), "Test", "*.json");

            Settings settings = new Settings();

            Assert.That(Settings.SettingsFolder, Is.StringEnding("GUI"));
            Assert.That(Settings.SettingsFilename, Is.EqualTo("settings.json"));

            Assert.That(settings.BlockchainFolder, Is.StringEnding("Blockchain"));
            Assert.That(settings.WalletFolder, Is.StringEnding("Wallet"));

            settings.BlockchainFolder = "test-blockchain";
            settings.WalletFolder = "test-wallet";

            Assert.False(settings.Load("non-existing-folder"));

            Assert.That(settings.BlockchainFolder, Is.EqualTo("test-blockchain"));
            Assert.That(settings.WalletFolder, Is.EqualTo("test-wallet"));

            settings.Save(testFolder);

            settings.BlockchainFolder = "test-blockchain2";
            settings.WalletFolder = "test-wallet2";

            Assert.That(settings.BlockchainFolder, Is.EqualTo("test-blockchain2"));
            Assert.That(settings.WalletFolder, Is.EqualTo("test-wallet2"));

            Assert.True(settings.Load(testFolder));

            Assert.That(settings.BlockchainFolder, Is.EqualTo("test-blockchain"));
            Assert.That(settings.WalletFolder, Is.EqualTo("test-wallet"));

            File.WriteAllText(Path.Combine(testFolder, Settings.SettingsFilename), "not json");
            Assert.False(settings.Load(testFolder));

            Assert.That(settings.BlockchainFolder, Is.EqualTo("test-blockchain"));
            Assert.That(settings.WalletFolder, Is.EqualTo("test-wallet"));
        }
 private void Init(Settings settings)
 {
     BlockchainFolder = settings.BlockchainFolder;
     WalletFolder = settings.WalletFolder;
 }
 public void SetDefaults()
 {
     Settings settings = new Settings();
     Init(settings);
 }