Index: Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml =================================================================== diff -u -r03d5df1364557b6f4a184908affb7754e58b3fa4 -r10a16f2a08c6a50176351ae46c9a23a37ab92e28 --- Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml (.../ChartingRibbon.xaml) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) +++ Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml (.../ChartingRibbon.xaml) (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -18,18 +18,18 @@ - - + + - + - + Index: Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml.cs =================================================================== diff -u -r0a601445097c12310c8fb1bff0c43f45a75c9e11 -r10a16f2a08c6a50176351ae46c9a23a37ab92e28 --- Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml.cs (.../ChartingRibbon.xaml.cs) (revision 0a601445097c12310c8fb1bff0c43f45a75c9e11) +++ Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml.cs (.../ChartingRibbon.xaml.cs) (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -7,16 +7,26 @@ namespace Core.Plugins.OxyPlot { /// - /// Interaction logic for ribbon.xaml + /// This class represents the ribbon interaction which has to do with charting. /// public partial class ChartingRibbon : IRibbonCommandHandler { + /// + /// Creates a new instance of . + /// public ChartingRibbon() { InitializeComponent(); } + /// + /// Sets the command used when the open chart button is clicked. + /// public ICommand OpenChartViewCommand { private get; set; } + + /// + /// Sets the command used when the toggle legend view button is clicked. + /// public ICommand ToggleLegendViewCommand { private get; set; } public IEnumerable Commands @@ -28,11 +38,17 @@ } } + /// + /// Shows the charting contextual tab. + /// public void ShowChartingTab() { ChartingContextualGroup.Visibility = Visibility.Visible; } + /// + /// Hides the charting contextual tab. + /// public void HideChartingTab() { ChartingContextualGroup.Visibility = Visibility.Collapsed; @@ -45,7 +61,7 @@ public void ValidateItems() { - ToggleLegendButton.IsChecked = ToggleLegendViewCommand.Checked; + ToggleLegendViewButton.IsChecked = ToggleLegendViewCommand.Checked; } public bool IsContextualTabVisible(string tabGroupName, string tabName) Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/ChartNodePresenter.cs =================================================================== diff -u -r570101d9648e296b96c7e624c4d4f6bfad8d41b6 -r10a16f2a08c6a50176351ae46c9a23a37ab92e28 --- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/ChartNodePresenter.cs (.../ChartNodePresenter.cs) (revision 570101d9648e296b96c7e624c4d4f6bfad8d41b6) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/ChartNodePresenter.cs (.../ChartNodePresenter.cs) (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -12,7 +12,7 @@ { public override void UpdateNode(TreeNode parentNode, TreeNode node, BaseChart nodeData) { - node.Text = "Grafiek"; + node.Text = Properties.Resources.General_Chart; node.Image = Resources.folder; } Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs =================================================================== diff -u -r570101d9648e296b96c7e624c4d4f6bfad8d41b6 -r10a16f2a08c6a50176351ae46c9a23a37ab92e28 --- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs (.../LegendView.cs) (revision 570101d9648e296b96c7e624c4d4f6bfad8d41b6) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs (.../LegendView.cs) (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -21,7 +21,7 @@ public LegendView() { InitializeComponent(); - Text = Resources.Ribbon_Chart; + Text = Resources.General_Chart; } public object Data Index: Core/Plugins/src/Core.Plugins.OxyPlot/Properties/Resources.Designer.cs =================================================================== diff -u -r5a98830aee77b1ee0158c11ba5cccffc656226e0 -r10a16f2a08c6a50176351ae46c9a23a37ab92e28 --- Core/Plugins/src/Core.Plugins.OxyPlot/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5a98830aee77b1ee0158c11ba5cccffc656226e0) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -91,6 +91,15 @@ } /// + /// Looks up a localized string similar to Grafiek. + /// + public static string General_Chart { + get { + return ResourceManager.GetString("General_Chart", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// public static System.Drawing.Bitmap LineIcon { @@ -120,15 +129,6 @@ } /// - /// Looks up a localized string similar to Grafiek. - /// - public static string Ribbon_Chart { - get { - return ResourceManager.GetString("Ribbon_Chart", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Grafieken. /// public static string Ribbon_ContextualGroup_Charting { Index: Core/Plugins/src/Core.Plugins.OxyPlot/Properties/Resources.resx =================================================================== diff -u -r5a98830aee77b1ee0158c11ba5cccffc656226e0 -r10a16f2a08c6a50176351ae46c9a23a37ab92e28 --- Core/Plugins/src/Core.Plugins.OxyPlot/Properties/Resources.resx (.../Resources.resx) (revision 5a98830aee77b1ee0158c11ba5cccffc656226e0) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Properties/Resources.resx (.../Resources.resx) (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -127,6 +127,9 @@ ..\resources\document.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Grafiek + ..\resources\line.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -136,9 +139,6 @@ ..\resources\points.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Grafiek - Grafieken Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/ChartingRibbonTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/ChartingRibbonTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/ChartingRibbonTest.cs (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -0,0 +1,163 @@ +using System.Linq; +using System.Windows; +using System.Windows.Automation.Peers; +using System.Windows.Automation.Provider; +using System.Windows.Controls.Primitives; +using System.Windows.Input; +using Core.Plugins.OxyPlot.Commands; +using Core.Plugins.OxyPlot.Legend; +using Fluent; +using NUnit.Framework; +using Rhino.Mocks; +using ICommand = Core.Common.Controls.Commands.ICommand; +using ToggleButton = Fluent.ToggleButton; + +namespace Core.Plugins.OxyPlot.Test +{ + [TestFixture] + public class ChartingRibbonTest + { + [Test] + [RequiresSTA] + public void Commands_NoCommandsAssigned_ReturnsNullForCommands() + { + // Setup + var ribbon = new ChartingRibbon(); + + // Call + var commands = ribbon.Commands.ToArray(); + + // Assert + CollectionAssert.AreEqual(Enumerable.Repeat(null,2),commands); + } + + [Test] + [RequiresSTA] + public void Commands_CommandsAssigned_ReturnsAssignedCommands() + { + // Setup + using(var oxyPlotGuiPlugin = new OxyPlotGuiPlugin()) { + var openChartViewCommand = new OpenChartViewCommand(); + var toggleLegendViewCommand = new ToggleLegendViewCommand(new LegendController(oxyPlotGuiPlugin)); + var ribbon = new ChartingRibbon + { + OpenChartViewCommand = openChartViewCommand, + ToggleLegendViewCommand = toggleLegendViewCommand + }; + + // Call + var commands = ribbon.Commands.ToArray(); + + // Assert + CollectionAssert.AreEqual(new ICommand[]{openChartViewCommand, toggleLegendViewCommand}, commands); + } + } + + [Test] + [RequiresSTA] + public void DefaultConstructor_Always_CreatesControl() + { + // Setup + var ribbon = new ChartingRibbon(); + + // Call & Assert + Assert.IsInstanceOf(ribbon.GetRibbonControl()); + } + + [Test] + [RequiresSTA] + public void IsContextualTabVisible_Always_ReturnsFalse() + { + // Setup + var ribbon = new ChartingRibbon(); + + // Call & Assert + Assert.IsFalse(ribbon.IsContextualTabVisible(null,null)); + } + + [Test] + [RequiresSTA] + public void OpenChartViewButton_OnClick_ExecutesOpenChartViewCommand() + { + // Setup + var mocks = new MockRepository(); + var command = mocks.StrictMock(); + command.Expect(c => c.Execute()); + + mocks.ReplayAll(); + + var ribbon = new ChartingRibbon + { + OpenChartViewCommand = command + }; + var button = ribbon.GetRibbonControl().FindName("OpenChartViewButton") as Button; + + // Precondition + Assert.IsNotNull(button, "Ribbon should have an open chart view button."); + + // Call + button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + + // Assert + mocks.VerifyAll(); + } + + [Test] + [RequiresSTA] + public void ToggleLegendViewButton_OnClick_ExecutesToggleLegendViewCommand() + { + // Setup + var mocks = new MockRepository(); + var command = mocks.StrictMock(); + command.Expect(c => c.Execute()); + + mocks.ReplayAll(); + + var ribbon = new ChartingRibbon + { + ToggleLegendViewCommand = command + }; + var button = ribbon.GetRibbonControl().FindName("ToggleLegendViewButton") as ToggleButton; + + // Precondition + Assert.IsNotNull(button, "Ribbon should have an open chart view button."); + + // Call + button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + + // Assert + mocks.VerifyAll(); + } + + [Test] + [RequiresSTA] + [TestCase(true)] + [TestCase(false)] + public void ValidateItems_Always_IsCheckedEqualToCommandChecked(bool commandChecked) + { + // Setup + var mocks = new MockRepository(); + var command = mocks.StrictMock(); + command.Expect(c => c.Checked).Return(commandChecked); + + mocks.ReplayAll(); + + var ribbon = new ChartingRibbon + { + ToggleLegendViewCommand = command + }; + + var button = ribbon.GetRibbonControl().FindName("ToggleLegendViewButton") as ToggleButton; + + // Precondition + Assert.IsNotNull(button, "Ribbon should have an open chart view button."); + + // Call + ribbon.ValidateItems(); + + // Assert + Assert.AreEqual(commandChecked, button.IsChecked); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Core.Plugins.OxyPlot.Test.csproj =================================================================== diff -u -r570101d9648e296b96c7e624c4d4f6bfad8d41b6 -r10a16f2a08c6a50176351ae46c9a23a37ab92e28 --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Core.Plugins.OxyPlot.Test.csproj (.../Core.Plugins.OxyPlot.Test.csproj) (revision 570101d9648e296b96c7e624c4d4f6bfad8d41b6) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Core.Plugins.OxyPlot.Test.csproj (.../Core.Plugins.OxyPlot.Test.csproj) (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -61,6 +61,7 @@ + @@ -69,13 +70,16 @@ + + + Component - + @@ -86,6 +90,10 @@ Core.Common.Base True + + {1d27f91f-4e62-4eaf-a0a8-a32708b9a9b1} + Core.Common.Controls.TreeView + {9a2d67e6-26ac-4d17-b11a-2b4372f2f572} Core.Common.Controls @@ -95,6 +103,10 @@ {30E4C2AE-719E-4D70-9FA9-668A9767FBFA} Core.Common.Gui + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + {DADAA0A5-288C-49CB-9F08-337F16832C86} Core.Components.OxyPlot.Forms Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Forms/ChartDataViewTest.cs =================================================================== diff -u -r570101d9648e296b96c7e624c4d4f6bfad8d41b6 -r10a16f2a08c6a50176351ae46c9a23a37ab92e28 --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Forms/ChartDataViewTest.cs (.../ChartDataViewTest.cs) (revision 570101d9648e296b96c7e624c4d4f6bfad8d41b6) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Forms/ChartDataViewTest.cs (.../ChartDataViewTest.cs) (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -24,6 +24,7 @@ var chart = (BaseChart)chartObject; Assert.AreEqual(DockStyle.Fill, chart.Dock); + Assert.NotNull(chartView.Chart); } [Test] Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartDataNodePresenterTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartDataNodePresenterTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartDataNodePresenterTest.cs (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -0,0 +1,96 @@ +using System; +using System.Collections.ObjectModel; +using Core.Common.Controls.TreeView; +using Core.Common.TestUtil; +using Core.Components.OxyPlot.Data; +using Core.Plugins.OxyPlot.Legend; +using Core.Plugins.OxyPlot.Properties; +using NUnit.Framework; +using OxyPlot; + +namespace Core.Plugins.OxyPlot.Test.Legend +{ + [TestFixture] + public class ChartDataNodePresenterTest + { + private readonly Collection> emptyCollection = new Collection>(); + + [Test] + public void DefaultConstructor_ReturnsTreeViewNodePresenterBase() + { + // Call + var nodePresenter = new ChartDataNodePresenter(); + + // Assert + Assert.IsInstanceOf>(nodePresenter); + } + + [Test] + public void UpdateNode_ForPointData_SetsTextAndIcon() + { + // Setup + var nodePresenter = new ChartDataNodePresenter(); + var treeNode = new TreeNode(null); + + // Call + nodePresenter.UpdateNode(null, treeNode, new PointData(emptyCollection)); + + // Assert + Assert.AreEqual("PointData", treeNode.Text); + TestHelper.AssertImagesAreEqual(Resources.PointsIcon, treeNode.Image); + } + + [Test] + public void UpdateNode_ForLineData_SetsTextAndIcon() + { + // Setup + var nodePresenter = new ChartDataNodePresenter(); + var treeNode = new TreeNode(null); + + // Call + nodePresenter.UpdateNode(null, treeNode, new LineData(emptyCollection)); + + // Assert + Assert.AreEqual("LineData", treeNode.Text); + TestHelper.AssertImagesAreEqual(Resources.LineIcon, treeNode.Image); + } + + [Test] + public void UpdateNode_ForAreaData_SetsTextAndIcon() + { + // Setup + var nodePresenter = new ChartDataNodePresenter(); + var treeNode = new TreeNode(null); + + // Call + nodePresenter.UpdateNode(null, treeNode, new AreaData(emptyCollection)); + + // Assert + Assert.AreEqual("AreaData", treeNode.Text); + TestHelper.AssertImagesAreEqual(Resources.AreaIcon, treeNode.Image); + } + + [Test] + public void UpdateNode_ForOtherIChartData_SetsText() + { + // Setup + var nodePresenter = new ChartDataNodePresenter(); + var treeNode = new TreeNode(null); + var data = new TestChartData(); + + // Call + nodePresenter.UpdateNode(null, treeNode, data); + + // Assert + Assert.AreEqual("TestChartData", treeNode.Text); + Assert.IsNull(treeNode.Image); + } + } + + public class TestChartData : IChartData { + public void AddTo(PlotModel model) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartNodePresenterTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartNodePresenterTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartNodePresenterTest.cs (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -0,0 +1,55 @@ +using Core.Common.Controls.TreeView; +using Core.Common.Gui.Properties; +using Core.Common.TestUtil; +using Core.Components.OxyPlot.Data; +using Core.Components.OxyPlot.Forms; +using Core.Plugins.OxyPlot.Legend; +using NUnit.Framework; + +namespace Core.Plugins.OxyPlot.Test.Legend +{ + [TestFixture] + public class ChartNodePresenterTest + { + + [Test] + public void DefaultConstructor_ReturnsTreeViewNodePresenterBase() + { + // Call + var nodePresenter = new ChartNodePresenter(); + + // Assert + Assert.IsInstanceOf>(nodePresenter); + } + + [Test] + public void UpdateNode_Always_SetsTextAndIcon() + { + // Setup + var nodePresenter = new ChartNodePresenter(); + var treeNode = new TreeNode(null); + + // Call + nodePresenter.UpdateNode(null, treeNode, null); + + // Assert + Assert.AreEqual("Grafiek", treeNode.Text); + TestHelper.AssertImagesAreEqual(Resources.folder, treeNode.Image); + } + + [Test] + public void GetChildNodeObjects_Always_ReturnsSeries() + { + // Setup + var nodePresenter = new ChartNodePresenter(); + var treeNode = new TreeNode(null); + var chart = new BaseChart(); + + // Call + var result = nodePresenter.GetChildNodeObjects(chart); + + // Assert + Assert.AreSame(chart.Model.Series, result); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendTreeViewTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendTreeViewTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendTreeViewTest.cs (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -0,0 +1,22 @@ +using System.Linq; +using Core.Plugins.OxyPlot.Legend; +using NUnit.Framework; + +namespace Core.Plugins.OxyPlot.Test.Legend +{ + [TestFixture] + public class LegendTreeViewTest + { + [Test] + public void DefaultConstructor_SetsTwoNodePresenters() + { + // Call + var view = new LegendTreeView(); + + // Assert + Assert.AreEqual(2, view.NodePresenters.Count()); + Assert.IsInstanceOf(view.NodePresenters.ElementAt(0)); + Assert.IsInstanceOf(view.NodePresenters.ElementAt(1)); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs =================================================================== diff -u -r570101d9648e296b96c7e624c4d4f6bfad8d41b6 -r10a16f2a08c6a50176351ae46c9a23a37ab92e28 --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs (.../OxyPlotGuiPluginTest.cs) (revision 570101d9648e296b96c7e624c4d4f6bfad8d41b6) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs (.../OxyPlotGuiPluginTest.cs) (revision 10a16f2a08c6a50176351ae46c9a23a37ab92e28) @@ -83,19 +83,83 @@ // Setup using (var plugin = new OxyPlotGuiPlugin()) { + var view = new ChartDataView(); + // Call var views = plugin.GetViewInfoObjects().ToArray(); // Assert Assert.AreEqual(1, views.Length); Assert.AreEqual(typeof(IChartData), views[0].DataType); Assert.AreEqual(typeof(ChartDataView), views[0].ViewType); + Assert.AreEqual("Diagram", views[0].GetViewName(view, null)); } } [Test] + public void CloseToolView_Always_CloseToolView() + { + // Setup + using (var plugin = new OxyPlotGuiPlugin()) + { + var mocks = new MockRepository(); + var gui = mocks.StrictMock(); + var view = mocks.StrictMock(); + gui.Expect(g => g.CloseToolView(view)); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + plugin.CloseToolView(view); + + // Assert + mocks.VerifyAll(); + } + } + + [Test] + [RequiresSTA] [TestCase(true)] [TestCase(false)] + public void GivenConfiguredGui_WhenOpenToolView_UpdateComponentsWithDataFromActiveView(bool isChartViewActive) + { + // Given + using (var gui = new RingtoetsGui()) + using (var plugin = new OxyPlotGuiPlugin()) + { + gui.MainWindow = new MainWindow(gui); + var mocks = new MockRepository(); + IView viewMock = isChartViewActive ? (IView)new TestChartView() : new TestView(); + viewMock.Data = new BaseChart(); + + mocks.ReplayAll(); + + gui.Plugins.Add(plugin); + gui.Run(); + + gui.DocumentViews.Add(viewMock); + gui.DocumentViews.ActiveView = viewMock; + var legendView = gui.ToolWindowViews.First(t => t is LegendView); + + gui.ToolWindowViews.Remove(legendView); + + // Precondition + Assert.IsNull(legendView.Data); + + // When + plugin.OpenToolView(legendView); + + // Then + Assert.AreSame(isChartViewActive ? viewMock.Data : null, legendView.Data); + mocks.VerifyAll(); + } + } + + [Test] + [TestCase(true)] + [TestCase(false)] [RequiresSTA] public void GivenConfiguredGui_WhenActiveViewChangesToIChartView_ThenRibbonSetVisibility(bool visible) { @@ -112,8 +176,6 @@ gui.Plugins.Add(plugin); gui.Run(); - gui.DocumentViews.IgnoreActivation = false; - // When gui.DocumentViews.Add(viewMock); gui.DocumentViews.ActiveView = viewMock; Fisheye: Tag 10a16f2a08c6a50176351ae46c9a23a37ab92e28 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.OxyPlot.Test/RibbonTest.cs'. Fisheye: No comparison available. Pass `N' to diff?