コード例 #1
0
        public void TestDelete()
        {
            bool eventEmitted = false;
            CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider(storage);

            Assert.AreEqual(1, provider.Templates.Count);
            // Template does not exists
            Assert.DoesNotThrow(() => provider.Delete(LMDashboard.DefaultTemplate(1)));
            // System template
            Assert.Throws <TemplateNotFoundException <Dashboard> > (() => provider.Delete(provider.Templates [0]));
            LMDashboard d = LMDashboard.DefaultTemplate(10);

            d.Name = "jamematen";
            provider.Save(d);
            Assert.AreEqual(2, provider.Templates.Count);
            provider.CollectionChanged += (sender, e) => {
                if (e.Action == NotifyCollectionChangedAction.Remove && e.OldItems [0] == d)
                {
                    eventEmitted = true;
                }
            };
            provider.Delete(d);
            Assert.AreEqual(1, provider.Templates.Count);
            Assert.IsFalse(provider.Exists(d.Name));
            Assert.IsTrue(eventEmitted);
        }
コード例 #2
0
        public void TestListTemplates()
        {
            CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider(storage);

            Assert.AreEqual(1, provider.Templates.Count);
            LMDashboard d = LMDashboard.DefaultTemplate(10);

            d.Name = "NEW";
            provider.Save(d);
            Assert.AreEqual(2, provider.Templates.Count);
        }
コード例 #3
0
        public void TestExists()
        {
            CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider(storage);

            Assert.IsFalse(provider.Exists("ACANDEMOR"));
            LMDashboard d = LMDashboard.DefaultTemplate(10);

            d.Name = "NEW";
            provider.Save(d);
            Assert.IsTrue(provider.Exists("NEW"));
        }
コード例 #4
0
        public void TestSaveUpdateLoad()
        {
            CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider(storage);
            LMDashboard d = LMDashboard.DefaultTemplate(10);

            d.Name = "jamematen";
            provider.Save(d);
            Assert.IsTrue(provider.Exists("jamematen"));

            d      = LMDashboard.DefaultTemplate(10);
            d.Name = "system";
            provider.Register(d);
            Assert.IsNotNull(provider.Exists("system"));
        }
コード例 #5
0
        public void TestSaveUpdateLoad()
        {
            CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider (storage);
            DashboardLongoMatch d = DashboardLongoMatch.DefaultTemplate (10);
            d.Name = "jamematen";
            provider.Save (d);
            Assert.IsTrue (provider.Exists ("jamematen"));

            d = DashboardLongoMatch.DefaultTemplate (10);
            d.Name = "system";
            provider.Register (d);
            Assert.IsNotNull (provider.Exists ("system"));
        }
コード例 #6
0
 public void TestListTemplates()
 {
     CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider (storage);
     Assert.AreEqual (1, provider.Templates.Count);
     DashboardLongoMatch d = DashboardLongoMatch.DefaultTemplate (10);
     d.Name = "NEW";
     provider.Save (d);
     Assert.AreEqual (2, provider.Templates.Count);
 }
コード例 #7
0
 public void TestExists()
 {
     CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider (storage);
     Assert.IsFalse (provider.Exists ("ACANDEMOR"));
     DashboardLongoMatch d = DashboardLongoMatch.DefaultTemplate (10);
     d.Name = "NEW";
     provider.Save (d);
     Assert.IsTrue (provider.Exists ("NEW"));
 }
コード例 #8
0
 public void TestDelete()
 {
     bool eventEmitted = false;
     CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider (storage);
     Assert.AreEqual (1, provider.Templates.Count);
     // Template does not exists
     Assert.DoesNotThrow (() => provider.Delete (DashboardLongoMatch.DefaultTemplate (1)));
     // System template
     Assert.Throws<TemplateNotFoundException<DashboardLongoMatch>> (() => provider.Delete (provider.Templates [0]));
     DashboardLongoMatch d = DashboardLongoMatch.DefaultTemplate (10);
     d.Name = "jamematen";
     provider.Save (d);
     Assert.AreEqual (2, provider.Templates.Count);
     provider.CollectionChanged += (sender, e) => {
         if (e.Action == NotifyCollectionChangedAction.Remove && e.OldItems [0] == d) {
             eventEmitted = true;
         }
     };
     provider.Delete (d);
     Assert.AreEqual (1, provider.Templates.Count);
     Assert.IsFalse (provider.Exists (d.Name));
     Assert.IsTrue (eventEmitted);
 }