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")); }
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")); }
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); }
public void TestRegister() { CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider(storage); LMDashboard d = LMDashboard.DefaultTemplate(10); d.Name = "system"; provider.Register(d); Assert.IsNotNull(provider.Exists("system")); Assert.IsTrue(provider.Templates [0].Static); }
public void TestCreate() { bool eventEmitted = false; CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider(storage); provider.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add && ((Dashboard)e.NewItems [0]).Name == "jamematen") { eventEmitted = true; } }; provider.Register(provider.Create("jamematen")); Assert.AreEqual(2, provider.Templates.Count); Assert.IsTrue(provider.Exists("jamematen")); Assert.IsTrue(eventEmitted); }
public void TestCopy() { bool eventEmitted = false; CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider(storage); provider.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add && ((Dashboard)e.NewItems [0]).Name == "NEW") { eventEmitted = true; } }; provider.Copy(provider.Templates [0], "NEW"); Assert.AreEqual(2, provider.Templates.Count); Assert.IsNotNull(provider.Exists("NEW")); Assert.DoesNotThrow(() => provider.Copy(LMDashboard.DefaultTemplate(5), "NEW")); Assert.IsTrue(eventEmitted); }
public void TestCopy() { bool eventEmitted = false; CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider (storage); provider.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add && ((Dashboard)e.NewItems [0]).Name == "NEW") { eventEmitted = true; } }; provider.Copy (provider.Templates [0], "NEW"); Assert.AreEqual (2, provider.Templates.Count); Assert.IsNotNull (provider.Exists ("NEW")); Assert.DoesNotThrow (() => provider.Copy (DashboardLongoMatch.DefaultTemplate (5), "NEW")); Assert.IsTrue (eventEmitted); }
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")); }
public void TestRegister() { CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider (storage); DashboardLongoMatch d = DashboardLongoMatch.DefaultTemplate (10); d.Name = "system"; provider.Register (d); Assert.IsNotNull (provider.Exists ("system")); Assert.IsTrue (provider.Templates [0].Static); }
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")); }
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); }
public void TestCreate() { bool eventEmitted = false; CategoriesTemplatesProvider provider = new CategoriesTemplatesProvider (storage); provider.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add && ((Dashboard)e.NewItems [0]).Name == "jamematen") { eventEmitted = true; } }; provider.Register (provider.Create ("jamematen")); Assert.AreEqual (2, provider.Templates.Count); Assert.IsTrue (provider.Exists ("jamematen")); Assert.IsTrue (eventEmitted); }