コード例 #1
0
ファイル: StoreTest.cs プロジェクト: zerocool951/ictlab
        public void TestRuleStore()
        {
            string fileLoc      = "Unittest.json";
            string key          = "password123";
            string templateName = "Empty";
            string saveKey      = "testKey";
            string saveValue    = "testVal";

            if (File.Exists(fileLoc))
            {
                File.Delete(fileLoc);
            }

            RuleStore newStore = RuleStore.Create(fileLoc, key);

            newStore.Rules.Add(
                new Rule(RuleTemplate.GetByName(templateName))
            {
                Properties = new Dictionary <string, object>()
                {
                    { saveKey, saveValue },
                    { "key2", 1 }
                }
            });

            newStore.WriteToDisc();

            var readStore = RuleStore.Open(fileLoc, key);

            Assert.AreEqual(saveValue, readStore.Rules.First().Properties[saveKey]);
            Assert.IsTrue(readStore.Rules.First().Templates.First().Name == templateName);

            File.Delete(fileLoc);
        }
コード例 #2
0
        public MainWindow(RuleStore store)
        {
            InitializeComponent();
            Store = store;
            Lv_RulesOverview.ItemsSource = Store.Rules;

            this.Closing += (sender, e) => {
                if (StoreChanged)
                {
                    if (MessageBox.Show("There are unsaved changes, save them?", "Save changes?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        Store.WriteToDisc();
                    }
                }
            };
        }
コード例 #3
0
ファイル: StoreTest.cs プロジェクト: zerocool951/ictlab
        public void TestRuleTemplateStore()
        {
            string fileLoc = "Unittest.json";
            string key     = "password123";

            if (File.Exists(fileLoc))
            {
                File.Delete(fileLoc);
            }

            RuleStore newStore = RuleStore.Create(fileLoc, key);
            Rule      rule     = new Rule(RuleTemplate.GetByName("Basic"), RuleTemplate.GetByName("Application"));

            newStore.Rules.Add(rule);
            newStore.WriteToDisc();

            var readStore = RuleStore.Open(fileLoc, key);

            Assert.IsTrue(readStore.Rules.First().Templates.Count() == 2);
            Assert.IsTrue(readStore.Rules.First().Templates.FirstOrDefault(rt => rt.Name == "Basic") != null);
            Assert.IsTrue(readStore.Rules.First().Templates.FirstOrDefault(rt => rt.Name == "Application") != null);

            File.Delete(fileLoc);
        }
コード例 #4
0
 private void Bt_Save_Click(object sender, RoutedEventArgs e)
 {
     Store.WriteToDisc();
     StoreChanged = false;
 }