[longomatch] Add a new funtion to remove buttons from the dashboard
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add a new funtion to remove buttons from the dashboard
- Date: Fri, 17 Apr 2015 16:24:15 +0000 (UTC)
commit 48284a01e4fcdcd606c636403b927e69e7392cd4
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Tue Apr 14 01:10:37 2015 +0200
Add a new funtion to remove buttons from the dashboard
LongoMatch.Core/Store/Templates/Dashboard.cs | 12 ++++++++++++
Tests/Core/Store/Templates/TestDashboard.cs | 23 ++++++++++++++++++++++-
Tests/Core/Store/Templates/TestTeamTemplate.cs | 2 +-
3 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/LongoMatch.Core/Store/Templates/Dashboard.cs b/LongoMatch.Core/Store/Templates/Dashboard.cs
index a206ada..0dbd9bc 100644
--- a/LongoMatch.Core/Store/Templates/Dashboard.cs
+++ b/LongoMatch.Core/Store/Templates/Dashboard.cs
@@ -248,6 +248,18 @@ namespace LongoMatch.Core.Store.Templates
}
/// <summary>
+ /// Removes a button from the list remving also dead links.
+ /// </summary>
+ /// <param name="button">The button to remove.</param>
+ public void RemoveButton (DashboardButton button)
+ {
+ List.Remove (button);
+ foreach (DashboardButton b in List) {
+ b.ActionLinks.RemoveAll (l => l.DestinationButton == button);
+ }
+ }
+
+ /// <summary>
/// Adds a new <see cref="AnalysisEventButton"/> with the default values
/// </summary>
/// <returns>A new button.</returns>
diff --git a/Tests/Core/Store/Templates/TestDashboard.cs b/Tests/Core/Store/Templates/TestDashboard.cs
index 2c3a355..f3b2b96 100644
--- a/Tests/Core/Store/Templates/TestDashboard.cs
+++ b/Tests/Core/Store/Templates/TestDashboard.cs
@@ -22,7 +22,7 @@ using LongoMatch.Core.Common;
using LongoMatch.Core.Store;
using LongoMatch.Core.Store.Templates;
-namespace Tests.Core
+namespace Tests.Core.Store.Templates
{
[TestFixture ()]
public class TestDashboard
@@ -71,6 +71,27 @@ namespace Tests.Core
b3.ActionLinks.Add (new ActionLink { DestinationButton = b1 });
Assert.IsTrue (dashboard.HasCircularDependencies ());
}
+
+ [Test ()]
+ public void TestRemoveButton ()
+ {
+ Dashboard dashboard = new Dashboard ();
+ DashboardButton b1 = new DashboardButton ();
+ DashboardButton b2 = new DashboardButton ();
+ DashboardButton b3 = new DashboardButton ();
+ dashboard.List.Add (b1);
+ dashboard.List.Add (b2);
+ dashboard.List.Add (b3);
+
+ b1.ActionLinks.Add (new ActionLink { DestinationButton = b2 });
+ b2.ActionLinks.Add (new ActionLink { DestinationButton = b3 });
+ b3.ActionLinks.Add (new ActionLink { DestinationButton = b1 });
+
+ dashboard.RemoveButton (b3);
+ Assert.AreEqual (0, b2.ActionLinks.Count);
+ dashboard.RemoveButton (b2);
+ Assert.AreEqual (0, b1.ActionLinks.Count);
+ }
}
}
diff --git a/Tests/Core/Store/Templates/TestTeamTemplate.cs b/Tests/Core/Store/Templates/TestTeamTemplate.cs
index 8fdafbb..71ebc77 100644
--- a/Tests/Core/Store/Templates/TestTeamTemplate.cs
+++ b/Tests/Core/Store/Templates/TestTeamTemplate.cs
@@ -22,7 +22,7 @@ using NUnit.Framework;
using LongoMatch.Core.Store;
using LongoMatch.Core.Store.Templates;
-namespace Tests.Core.Templates
+namespace Tests.Core.Store.Templates
{
[TestFixture ()]
public class TestTeamTemplate
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]