Index: Core/Plugins/src/Core.Plugins.CommonTools.Gui/Core.Plugins.CommonTools.Gui.csproj =================================================================== diff -u -rd616e06dd49f563130b2d571107e0e54f09b0bbb -rf0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 --- Core/Plugins/src/Core.Plugins.CommonTools.Gui/Core.Plugins.CommonTools.Gui.csproj (.../Core.Plugins.CommonTools.Gui.csproj) (revision d616e06dd49f563130b2d571107e0e54f09b0bbb) +++ Core/Plugins/src/Core.Plugins.CommonTools.Gui/Core.Plugins.CommonTools.Gui.csproj (.../Core.Plugins.CommonTools.Gui.csproj) (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -137,10 +137,6 @@ Core.Plugins.Charting - - - - - + \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/ChartingGuiPluginTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/ChartingGuiPluginTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/ChartingGuiPluginTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,73 @@ +using System.Linq; +using Core.Common.Base.Plugin; +using Core.Common.Controls.Charting; +using Core.Common.Gui; +using Core.Common.Gui.Forms.MainWindow; +using Core.Plugins.Charting.Forms; +using Core.Plugins.Charting.Property; +using Core.Plugins.CommonTools.Gui.Test; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test +{ + [TestFixture] + public class ChartingGuiPluginTest + { + [Test] + [RequiresSTA] + public void ChartLegendViewIsUpdatedForCurrentActiveView() + { + var mocks = new MockRepository(); + var gui = mocks.Stub(); + var applicationCore = mocks.Stub(); + var pluginGui = new ChartingGuiPlugin(); + var mainWindow = mocks.Stub(); + var toolWindowViews = new TestViewList(); + var documentViews = new TestViewList(); + var chartView = new ChartView(); + + gui.Expect(g => g.ApplicationCore).Return(applicationCore).Repeat.Any(); + gui.Expect(g => g.DocumentViews).Return(documentViews).Repeat.Any(); + gui.Expect(g => g.ToolWindowViews).Return(toolWindowViews).Repeat.Any(); + gui.Expect(g => g.MainWindow).Return(mainWindow).Repeat.Any(); + mainWindow.Expect(w => w.Visible).Return(true).Repeat.Any(); + + mocks.ReplayAll(); + + documentViews.Add(chartView); + + pluginGui.Gui = gui; + pluginGui.Activate(); + + documentViews.ActiveView = chartView; + + var chartLegendView = gui.ToolWindowViews.OfType().FirstOrDefault(); + + Assert.IsNotNull(chartLegendView); + Assert.AreEqual(chartView.Data, chartLegendView.Data); + + mocks.VerifyAll(); + } + + [Test] + public void TestGetObjectProperties() + { + var guiPlugin = new ChartingGuiPlugin(); + var propertyInfos = guiPlugin.GetPropertyInfos().ToList(); + + var propertyInfo = propertyInfos.First(pi => pi.ObjectType == typeof(IChart)); + Assert.AreEqual(typeof(ChartProperties), propertyInfo.PropertyType); + } + + [Test] + public void TestGetViewInfoObjectsContent() + { + var guiPlugin = new ChartingGuiPlugin(); + var viewInfos = guiPlugin.GetViewInfoObjects().ToList(); + + Assert.NotNull(viewInfos); + Assert.IsTrue(viewInfos.Any(vi => vi.DataType == typeof(Chart) && vi.ViewType == typeof(ChartView))); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Commands/ChartViewCommandBaseTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Commands/ChartViewCommandBaseTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Commands/ChartViewCommandBaseTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,190 @@ +using System; +using System.Drawing; +using Core.Common.Controls.Charting; +using Core.Common.Gui; +using Core.Common.Test.TestObjects; +using Core.Plugins.Charting.Commands; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Commands +{ + [TestFixture] + public class ChartViewCommandBaseTest + { + private MockRepository mocks; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + } + + [Test] + [TestCase(11)] + [TestCase(1)] + [TestCase(0)] + [TestCase(-11)] + [TestCase(-5)] + public void GetChangedFontSize_StartWithSize12ModifiedWithPoints_ReturnsSmallerFont(int points) + { + // Setup + var command = new TestChartViewCommandBase(); + var startSize = 12f; + var font = new Font(FontFamily.GenericSansSerif, startSize); + + // Call + var newFont = command.GetChangedFontSize(font, points); + + // Assert + Assert.AreEqual(startSize + points, newFont.SizeInPoints); + } + + [Test] + [TestCase(-12)] + [TestCase(-13)] + public void GetChangedFontSize_StartWithSize12ModifiedWithPointsLargerEqualTo12_ThrowsArgumentException(int points) + { + // Setup + var command = new TestChartViewCommandBase(); + var startSize = 12f; + var font = new Font(FontFamily.GenericSansSerif, startSize); + + // Call + TestDelegate test = () => command.GetChangedFontSize(font, points); + + // Assert + Assert.Throws(test); + } + + [Test] + public void View_WithoutGui_Null() + { + // Setup + var command = new TestChartViewCommandBase(); + + // Call + var result = command.GetView(); + + // Assert + Assert.IsNull(result); + } + + [Test] + public void View_GuiWithoutDocumentView_ThrowsNullReferenceException() + { + // Setup + var guiMock = mocks.StrictMock(); + guiMock.Expect(g => g.DocumentViews).Return(null); + + mocks.ReplayAll(); + + var command = new TestChartViewCommandBase + { + Gui = guiMock + }; + + // Call + TestDelegate test = () => command.GetView(); + + // Assert + Assert.Throws(test); + + mocks.VerifyAll(); + } + + [Test] + public void View_GuiWithDocumentViewActiveViewNull_CallsActiveViewReturnsNull() + { + // Setup + var guiMock = mocks.StrictMock(); + var viewListMock = mocks.StrictMock(); + guiMock.Expect(g => g.DocumentViews).Return(viewListMock); + viewListMock.Expect(vl => vl.ActiveView).Return(null); + + mocks.ReplayAll(); + + var command = new TestChartViewCommandBase + { + Gui = guiMock + }; + + // Call + var result = command.GetView(); + + // Assert + Assert.IsNull(result); + + mocks.VerifyAll(); + } + + [Test] + public void View_GuiWithDocumentViewActiveViewNotChartView_CallsActiveViewReturnsNull() + { + // Setup + var guiMock = mocks.StrictMock(); + var viewListMock = mocks.StrictMock(); + guiMock.Expect(g => g.DocumentViews).Return(viewListMock); + viewListMock.Expect(vl => vl.ActiveView).Return(new TestView()); + + mocks.ReplayAll(); + + var command = new TestChartViewCommandBase + { + Gui = guiMock + }; + + // Call + var result = command.GetView(); + + // Assert + Assert.IsNull(result); + + mocks.VerifyAll(); + } + + [Test] + public void View_GuiWithDocumentViewActiveViewChartView_CallsActiveViewReturnsChartView() + { + // Setup + var expectedView = new ChartView(); + + var guiMock = mocks.StrictMock(); + var viewListMock = mocks.StrictMock(); + guiMock.Expect(g => g.DocumentViews).Return(viewListMock); + viewListMock.Expect(vl => vl.ActiveView).Return(expectedView); + + mocks.ReplayAll(); + + var command = new TestChartViewCommandBase + { + Gui = guiMock + }; + + // Call + var result = command.GetView(); + + // Assert + Assert.AreSame(expectedView, result); + + mocks.VerifyAll(); + } + + private class TestChartViewCommandBase : ChartViewCommandBase { + public override void Execute(params object[] args) + { + throw new NotImplementedException(); + } + + public new Font GetChangedFontSize(Font font, int points) + { + return base.GetChangedFontSize(font, points); + } + + public IChartView GetView() + { + return View; + } + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Commands/DecreaseFontSizeCommandTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Commands/DecreaseFontSizeCommandTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Commands/DecreaseFontSizeCommandTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,95 @@ +using System.Drawing; +using Core.Common.Controls.Charting; +using Core.Common.Gui; +using Core.Common.Test.TestObjects; +using Core.Plugins.Charting.Commands; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Commands +{ + [TestFixture] + public class DecreaseFontSizeCommandTest + { + private MockRepository mocks; + private IGui gui; + private IViewList documentsView; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + gui = mocks.StrictMock(); + documentsView = mocks.StrictMock(); + gui.Expect(g => g.DocumentViews).Return(documentsView); + } + + [Test] + public void Execute_WithActiveChartView_FontSizesDecreasedByOne() + { + // Setup + IChart chart = new Chart(); + var view = new ChartView + { + Chart = chart + }; + var command = new DecreaseFontSizeCommand + { + Gui = gui + }; + + documentsView.Expect(dv => dv.ActiveView).Return(view); + + var family = FontFamily.GenericSansSerif; + var size = 12; + + chart.Font = new Font(family, size); + chart.Legend.Font = new Font(family, size); + chart.LeftAxis.LabelsFont = new Font(family, size); + chart.LeftAxis.TitleFont = new Font(family, size); + chart.BottomAxis.LabelsFont = new Font(family, size); + chart.BottomAxis.TitleFont = new Font(family, size); + chart.RightAxis.LabelsFont = new Font(family, size); + chart.RightAxis.TitleFont = new Font(family, size); + + mocks.ReplayAll(); + + // Call + command.Execute(); + + // Assert + var expectedSize = size - 1; + Assert.AreEqual(expectedSize, chart.Font.SizeInPoints); + Assert.AreEqual(expectedSize, chart.Legend.Font.SizeInPoints); + Assert.AreEqual(expectedSize, chart.LeftAxis.LabelsFont.SizeInPoints); + Assert.AreEqual(expectedSize, chart.LeftAxis.TitleFont.SizeInPoints); + Assert.AreEqual(expectedSize, chart.BottomAxis.LabelsFont.SizeInPoints); + Assert.AreEqual(expectedSize, chart.BottomAxis.TitleFont.SizeInPoints); + Assert.AreEqual(expectedSize, chart.RightAxis.LabelsFont.SizeInPoints); + Assert.AreEqual(expectedSize, chart.RightAxis.TitleFont.SizeInPoints); + + mocks.VerifyAll(); + } + + [Test] + public void Execute_WithActiveOtherView_DoesNotThrow() + { + // Setup + var view = new TestView(); + var command = new DecreaseFontSizeCommand + { + Gui = gui + }; + + documentsView.Expect(dv => dv.ActiveView).Return(view); + + mocks.ReplayAll(); + + // Call + command.Execute(); + + // Assert + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Commands/ExportChartAsImageCommandTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Commands/ExportChartAsImageCommandTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Commands/ExportChartAsImageCommandTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,69 @@ +using Core.Common.Controls.Charting; +using Core.Common.Gui; +using Core.Common.Test.TestObjects; +using Core.Plugins.Charting.Commands; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Commands +{ + [TestFixture] + public class ExportChartAsImageCommandTest + { + private MockRepository mocks; + private IGui gui; + private IViewList documentsView; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + gui = mocks.StrictMock(); + documentsView = mocks.StrictMock(); + gui.Expect(g => g.DocumentViews).Return(documentsView); + } + + [Test] + public void Execute_WithActiveChartView_CallsExportAsImage() + { + // Setup + var chartView = mocks.StrictMock(); + chartView.Expect(cv => cv.ExportAsImage()); + documentsView.Expect(dv => dv.ActiveView).Return(chartView); + + mocks.ReplayAll(); + + var command = new ExportChartAsImageCommand + { + Gui = gui + }; + + // Call + command.Execute(); + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void Execute_WithActiveOtherView_DoesNotThrow() + { + // Setup + var view = new TestView(); + var command = new IncreaseFontSizeCommand + { + Gui = gui + }; + + documentsView.Expect(dv => dv.ActiveView).Return(view); + + mocks.ReplayAll(); + + // Call + command.Execute(); + + // Assert + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Commands/IncreaseFontSizeCommandTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Commands/IncreaseFontSizeCommandTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Commands/IncreaseFontSizeCommandTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,95 @@ +using System.Drawing; +using Core.Common.Controls.Charting; +using Core.Common.Gui; +using Core.Common.Test.TestObjects; +using Core.Plugins.Charting.Commands; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Commands +{ + [TestFixture] + public class IncreaseFontSizeCommandTest + { + private MockRepository mocks; + private IGui gui; + private IViewList documentsView; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + gui = mocks.StrictMock(); + documentsView = mocks.StrictMock(); + gui.Expect(g => g.DocumentViews).Return(documentsView); + } + + [Test] + public void Execute_WithActiveChartView_FontSizesDecreasedByOne() + { + // Setup + IChart chart = new Chart(); + var view = new ChartView + { + Chart = chart + }; + var command = new IncreaseFontSizeCommand + { + Gui = gui + }; + + documentsView.Expect(dv => dv.ActiveView).Return(view); + + var family = FontFamily.GenericSansSerif; + var size = 12; + + chart.Font = new Font(family, size); + chart.Legend.Font = new Font(family, size); + chart.LeftAxis.LabelsFont = new Font(family, size); + chart.LeftAxis.TitleFont = new Font(family, size); + chart.BottomAxis.LabelsFont = new Font(family, size); + chart.BottomAxis.TitleFont = new Font(family, size); + chart.RightAxis.LabelsFont = new Font(family, size); + chart.RightAxis.TitleFont = new Font(family, size); + + mocks.ReplayAll(); + + // Call + command.Execute(); + + // Assert + var expectedSize = size + 1; + Assert.AreEqual(expectedSize, chart.Font.SizeInPoints); + Assert.AreEqual(expectedSize, chart.Legend.Font.SizeInPoints); + Assert.AreEqual(expectedSize, chart.LeftAxis.LabelsFont.SizeInPoints); + Assert.AreEqual(expectedSize, chart.LeftAxis.TitleFont.SizeInPoints); + Assert.AreEqual(expectedSize, chart.BottomAxis.LabelsFont.SizeInPoints); + Assert.AreEqual(expectedSize, chart.BottomAxis.TitleFont.SizeInPoints); + Assert.AreEqual(expectedSize, chart.RightAxis.LabelsFont.SizeInPoints); + Assert.AreEqual(expectedSize, chart.RightAxis.TitleFont.SizeInPoints); + + mocks.VerifyAll(); + } + + [Test] + public void Execute_WithActiveOtherView_DoesNotThrow() + { + // Setup + var view = new TestView(); + var command = new IncreaseFontSizeCommand + { + Gui = gui + }; + + documentsView.Expect(dv => dv.ActiveView).Return(view); + + mocks.ReplayAll(); + + // Call + command.Execute(); + + // Assert + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Core.Plugins.Charting.Test.csproj =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Core.Plugins.Charting.Test.csproj (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Core.Plugins.Charting.Test.csproj (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,135 @@ + + + + + Debug + x86 + {B0A220BE-9029-47B3-89C6-7562094819B7} + Library + Properties + Core.Plugins.Charting.Test + Core.Plugins.Charting.Test + v4.0 + 512 + + + true + bin\Debug\ + 4 + x86 + MinimumRecommendedRules.ruleset + TRACE;DEBUG + full + + + bin\Release\ + 4 + x86 + MinimumRecommendedRules.ruleset + TRACE + true + + + bin\ReleaseForCodeCoverage\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + + ..\..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll + + + ..\..\..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll + + + + + + + + + + + + ..\..\..\..\lib\TeeChart.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + + + {43CD4CC3-8500-411B-822E-1D3B5AF56FBC} + Core.Common.Controls.Charting + + + {1D27F91F-4E62-4EAF-A0A8-A32708B9A9B1} + Core.Common.Controls.TreeView + + + {9a2d67e6-26ac-4d17-b11a-2b4372f2f572} + Core.Common.Controls + + + {30E4C2AE-719E-4D70-9FA9-668A9767FBFA} + Core.Common.Gui + + + {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} + Core.Common.Utils + + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + + + {E0990383-FB2E-47D1-99CD-9B9FA2929E5B} + Core.Common.Test + + + {16050ED1-3E4F-4540-9B5D-6ADD4FC43D9D} + Core.Plugins.Charting + + + {8BD31773-6F6D-42EE-810D-0A5DAD809F9D} + Core.Plugins.CommonTools.Gui.Test + + + + + \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Forms/ChartSeriesTreeNodePresenterTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Forms/ChartSeriesTreeNodePresenterTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Forms/ChartSeriesTreeNodePresenterTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,199 @@ +using System; +using System.Drawing; +using Core.Common.Controls.Charting; +using Core.Common.Controls.Charting.Series; +using Core.Common.Controls.TreeView; +using Core.Common.TestUtil; +using Core.Plugins.Charting.Forms; +using Core.Plugins.Charting.Properties; +using NUnit.Framework; +using Rhino.Mocks; +using Steema.TeeChart.Styles; + +namespace Core.Plugins.Charting.Test.Forms +{ + [TestFixture] + public class ChartSeriesTreeNodePresenterTest + { + [Test] + public void DefaultConstructor_Always_PropertiesSet() + { + // Call + var nodePresenter = new ChartSeriesTreeNodePresenter(); + + // Assert + Assert.IsInstanceOf>(nodePresenter); + } + + [Test] + public void CanRenameNode_Always_ReturnsTrue() + { + // Setup + var nodePresenter = new ChartSeriesTreeNodePresenter(); + + // Call + var result = nodePresenter.CanRenameNode(null); + + // Assert + Assert.IsTrue(result); + } + + [Test] + public void OnNodeRenamed_NoChartSeries_DoesNotThrow() + { + // Setup + var nodePresenter = new ChartSeriesTreeNodePresenter(); + + // Call + TestDelegate testDelegate = () => nodePresenter.OnNodeRenamed(null, String.Empty); + + // Assert + Assert.DoesNotThrow(testDelegate); + } + + [Test] + public void OnNodeRenamed_NewNodeName_ChartSeriesTitleSetToNodeName() + { + // Setup + var nodePresenter = new ChartSeriesTreeNodePresenter(); + var name = ""; + var newName = ""; + var chartSeries = new TestChartSeries(); + chartSeries.Title = name; + + // Call + nodePresenter.OnNodeRenamed(chartSeries, newName); + + // Assert + Assert.AreEqual(newName, chartSeries.Title); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void UpdateNode_NoKnownSeriesType_PropertiesSetImageNull(bool visible) + { + // Setup + var nodePresenter = new ChartSeriesTreeNodePresenter(); + var node = new TreeNode(null); + var testTitle = ""; + var chartSeries = new TestChartSeries + { + Title = testTitle, + Visible = visible + }; + + // Call + nodePresenter.UpdateNode(null, node, chartSeries); + + // Assert + Assert.AreEqual(testTitle, node.Text); + Assert.AreEqual(visible, node.Checked); + Assert.IsTrue(node.ShowCheckBox); + Assert.IsNull(node.Image); + Assert.AreSame(chartSeries, node.Tag); + } + + [Test] + [TestCase(typeof(AreaChartSeries), "Area")] + [TestCase(typeof(LineChartSeries), "Line")] + [TestCase(typeof(PointChartSeries), "Points")] + [TestCase(typeof(PolygonChartSeries), "Polygon")] + [TestCase(typeof(BarSeries), "Bars")] + public void UpdateNode_KnownSeriesType_NodeImageSet(Type chartType, string resourceName) + { + // Setup + var nodePresenter = new ChartSeriesTreeNodePresenter(); + var node = new TreeNode(null); + var chartSeries = Activator.CreateInstance(chartType); + + // Call + nodePresenter.UpdateNode(null, node, chartSeries); + Image expectedImage = Resources.ResourceManager.GetObject(resourceName) as Image; + // Assert + TestHelper.AssertImagesAreEqual(expectedImage, node.Image); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void OnNodeChecked_NodeChecked_VisibleTrue(bool visible) + { + // Setup + var mocks = new MockRepository(); + var nodePresenter = new ChartSeriesTreeNodePresenter(); + var node = mocks.StrictMock(); + var chartSeries = new TestChartSeries(); + node.Expect(n => n.Tag).Return(chartSeries); + node.Expect(n => n.Checked).Return(visible); + + mocks.ReplayAll(); + + // Call + nodePresenter.OnNodeChecked(node); + + // Assert + Assert.AreEqual(visible, chartSeries.Visible); + + mocks.VerifyAll(); + } + + [Test] + public void CanDrag_Always_ReturnMove() + { + // Setup + var nodePresenter = new ChartSeriesTreeNodePresenter(); + + // Call + var result = nodePresenter.CanDrag(null); + + // Assert + Assert.AreEqual(DragOperations.Move, result); + } + + [Test] + public void RemoveNodeData_NodeNotInChartSeries_ReturnsFalse() + { + // Assert + var nodePresenter = new ChartSeriesTreeNodePresenter(); + var chartSeries = new TestChartSeries(); + var chart = new Chart(); + chartSeries.Chart = chart; + + // Precondition + CollectionAssert.DoesNotContain(chart.Series, chartSeries); + + // Call + var result = nodePresenter.RemoveNodeData(null, chartSeries); + + // Assert + Assert.IsFalse(result); + } + + [Test] + public void RemoveNodeData_NodeInChartSeries_ChartSeriesRemoved() + { + // Assert + var nodePresenter = new ChartSeriesTreeNodePresenter(); + var chartSeries = new TestChartSeries(); + var chart = new Chart(); + chartSeries.Chart = chart; + chart.AddChartSeries(chartSeries); + + // Precondition + CollectionAssert.Contains(chart.Series, chartSeries); + + // Call + var result = nodePresenter.RemoveNodeData(null, chartSeries); + + // Assert + CollectionAssert.DoesNotContain(chart.Series, chartSeries); + Assert.IsTrue(result); + } + } + + public class TestChartSeries : ChartSeries { + public TestChartSeries() : base(new CustomPoint()) { } + public override Color Color { get; set; } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Forms/ChartTreeNodePresenterTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Forms/ChartTreeNodePresenterTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Forms/ChartTreeNodePresenterTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,241 @@ +using System; +using System.Collections; +using System.Linq; +using Core.Common.Controls.Charting; +using Core.Common.Controls.Charting.Series; +using Core.Common.Controls.TreeView; +using Core.Common.TestUtil; +using Core.Plugins.Charting.Forms; +using Core.Plugins.Charting.Properties; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Forms +{ + [TestFixture] + public class ChartTreeNodePresenterTest + { + [Test] + public void DefaultConstructor_Always_PropertiesSet() + { + // Call + var nodePresenter = new ChartTreeNodePresenter(); + + // Assert + Assert.IsInstanceOf>(nodePresenter); + } + + [Test] + public void CanRenameNode_Always_ReturnsTrue() + { + // Setup + var nodePresenter = new ChartTreeNodePresenter(); + + // Call + var result = nodePresenter.CanRenameNode(null); + + // Assert + Assert.IsTrue(result); + } + + [Test] + [TestCase("Some name")] + [TestCase("")] + public void UpdateNode_NoKnownSeriesType_PropertiesSetImageNull(string title) + { + // Setup + var nodePresenter = new ChartTreeNodePresenter(); + var node = new TreeNode(null); + var chart = new Chart + { + Title = title + }; + + // Call + nodePresenter.UpdateNode(null, node, chart); + + // Assert + Assert.AreEqual(string.IsNullOrEmpty(title) ? Resources.ChartingGuiPlugin_Chart : title, node.Text); + TestHelper.AssertImagesAreEqual(Resources.Chart, node.Image); + Assert.AreSame(chart, node.Tag); + } + + [Test] + public void OnNodeRenamed_NoChartSeries_DoesNotThrow() + { + // Setup + var nodePresenter = new ChartTreeNodePresenter(); + + // Call + TestDelegate testDelegate = () => nodePresenter.OnNodeRenamed(null, string.Empty); + + // Assert + Assert.DoesNotThrow(testDelegate); + } + + [Test] + public void OnNodeRenamed_NewNodeName_ChartSeriesTitleSetToNodeName() + { + // Setup + var nodePresenter = new ChartTreeNodePresenter(); + var name = ""; + var newName = ""; + var chart = new Chart + { + Title = name + }; + + // Call + nodePresenter.OnNodeRenamed(chart, newName); + + // Assert + Assert.AreEqual(newName, chart.Title); + } + + [Test] + public void GetChildNodeObjects_Always_ReturnsSeries() + { + // Setup + var mocks = new MockRepository(); + var nodePresenter = new ChartTreeNodePresenter(); + var chart = mocks.StrictMock(); + chart.Expect(c => c.Series).Return(Enumerable.Empty()); + + mocks.ReplayAll(); + + // Call + var result = nodePresenter.GetChildNodeObjects(chart); + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void CanInsert_TreeViewHasSorter_ReturnFalse() + { + // Setup + var mocks = new MockRepository(); + var treeView = mocks.StrictMock(); + treeView.Expect(tv => tv.TreeViewNodeSorter).Return(mocks.Stub()); + + mocks.ReplayAll(); + + var nodePresenter = new ChartTreeNodePresenter { TreeView = treeView }; + + // Call + var insertionAllowed = nodePresenter.CanInsert(null, null, null); + + // Assert + Assert.IsFalse(insertionAllowed); + mocks.VerifyAll(); + } + + [Test] + public void CanInsert_TreeViewDoesNotHaveSorter_ReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var treeView = mocks.StrictMock(); + treeView.Expect(tv => tv.TreeViewNodeSorter).Return(null); + + mocks.ReplayAll(); + + var nodePresenter = new ChartTreeNodePresenter { TreeView = treeView }; + + // Call + var insertionAllowed = nodePresenter.CanInsert(null, null, null); + + // Assert + Assert.IsTrue(insertionAllowed); + mocks.VerifyAll(); + } + + [Test] + [TestCase(DragOperations.Move)] + [TestCase(DragOperations.None)] + public void CanDrop_ItemNotIChartSeries_ReturnsNone(DragOperations validOperation) + { + // Setup + var nodePresenter = new ChartTreeNodePresenter(); + + // Call + var result = nodePresenter.CanDrop(new object(), null, null, validOperation); + + // Assert + Assert.AreEqual(DragOperations.None, result); + } + + [Test] + [TestCase(DragOperations.Move)] + [TestCase(DragOperations.None)] + public void CanDrop_ItemIChartSeries_ReturnsValidOperation(DragOperations validOperation) + { + // Setup + var mocks = new MockRepository(); + var nodePresenter = new ChartTreeNodePresenter(); + var chartSeries = mocks.StrictMock(); + + mocks.ReplayAll(); + + // Call + var result = nodePresenter.CanDrop(chartSeries, null, null, validOperation); + + // Assert + Assert.AreEqual(validOperation, result); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(DragOperations.Move)] + [TestCase(DragOperations.None)] + public void OnDragDrop_ChartSeriesItemIChartParent_RemovesAndInserts(DragOperations operation) + { + // Setup + var mocks = new MockRepository(); + var nodePresenter = new ChartTreeNodePresenter(); + var series = new TestChartSeries(); + var random = new Random(21); + var position = random.Next(); + + var parent = mocks.StrictMock(); + var target = mocks.StrictMock(); + parent.Expect(p => p.RemoveChartSeries(series)).Return(true); + target.Expect(t => t.InsertChartSeries(series, position)); + + mocks.ReplayAll(); + + // Call + nodePresenter.OnDragDrop(series, parent, target, operation, position); + + // Assert + mocks.VerifyAll(); + } + + [Test] + [TestCase(DragOperations.Move)] + [TestCase(DragOperations.None)] + public void OnDragDrop_ChartSeriesItemObjectParent_RemovesAndInserts(DragOperations operation) + { + // Setup + var mocks = new MockRepository(); + var nodePresenter = new ChartTreeNodePresenter(); + var series = new TestChartSeries(); + var random = new Random(21); + var position = random.Next(); + + var parent = new object(); + var target = mocks.StrictMock(); + target.Expect(p => p.RemoveChartSeries(series)).Return(true); + target.Expect(t => t.InsertChartSeries(series, position)); + + mocks.ReplayAll(); + + // Call + nodePresenter.OnDragDrop(series, parent, target, operation, position); + + // Assert + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Properties/AssemblyInfo.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Properties/AssemblyInfo.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Properties/AssemblyInfo.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Core.Plugins.Charting.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Core.Plugins.Charting.Test")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("92c9327e-4bfc-44c5-b2fc-9948477abf54")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Index: Core/Plugins/test/Core.Plugins.Charting.Test/Property/AreaChartSeriesPropertiesTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Property/AreaChartSeriesPropertiesTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Property/AreaChartSeriesPropertiesTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,180 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using Core.Common.Controls.Charting; +using Core.Common.Controls.Charting.Series; +using Core.Common.Utils.PropertyBag; +using Core.Plugins.Charting.Property; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Property +{ + [TestFixture] + public class AreaChartSeriesPropertiesTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var properties = new AreaChartSeriesProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var someInterpolationType = InterpolationType.Constant; + var someColor = Color.FromArgb(255, 240, 240, 222); // Using Color constant fails, probably due to how Area.Color works (in AreaChartSeries.Color). + var someTransparency = 0; + var someUseHatch = false; + var someHatchStyle = HatchStyle.BackwardDiagonal; + var someHatchColor = Color.AliceBlue; + var someLineColor = Color.AliceBlue; + var someLineWidth = 2; + var someLineVisible = false; + var somePointerColor = Color.AliceBlue; + var somePointerStyle = PointerStyles.Circle; + var somePointerVisible = false; + var somePointerSize = 2; + var somePointerLineColor = Color.AliceBlue; + var somePointerLineVisible = false; + + var chartSeries = new AreaChartSeries + { + InterpolationType = someInterpolationType, + Color = someColor, + Transparency = someTransparency, + UseHatch = someUseHatch, + HatchStyle = someHatchStyle, + HatchColor = someHatchColor, + LineColor = someLineColor, + LineWidth = someLineWidth, + LineVisible = someLineVisible, + PointerColor = somePointerColor, + PointerStyle = somePointerStyle, + PointerVisible = somePointerVisible, + PointerSize = somePointerSize, + PointerLineColor = somePointerLineColor, + PointerLineVisible = somePointerLineVisible + }; + + var properties = new AreaChartSeriesProperties + { + Data = chartSeries + }; + + // Call & Assert + Assert.AreEqual(someInterpolationType, properties.InterpolationType); + Assert.AreEqual(someColor, properties.Color); + Assert.AreEqual(someTransparency, properties.Transparency); + Assert.AreEqual(someUseHatch, properties.UseHatch); + Assert.AreEqual(someHatchStyle, properties.HatchStyle); + Assert.AreEqual(someHatchColor, properties.HatchColor); + Assert.AreEqual(someLineColor, properties.LineColor); + Assert.AreEqual(someLineWidth, properties.LineWidth); + Assert.AreEqual(someLineVisible, properties.LineVisible); + Assert.AreEqual(somePointerColor, properties.PointerColor); + Assert.AreEqual(somePointerStyle, properties.PointerStyle); + Assert.AreEqual(somePointerVisible, properties.PointerVisible); + Assert.AreEqual(somePointerSize, properties.PointerSize); + Assert.AreEqual(somePointerLineColor, properties.PointerLineColor); + Assert.AreEqual(somePointerLineVisible, properties.PointerLineVisible); + } + + [Test] + public void SetProperties_WithData_CallsSetters() + { + // Setup + var mocks = new MockRepository(); + var chartSeries = mocks.StrictMock(); + + var someInterpolationType = InterpolationType.Constant; + var someColor = Color.FromArgb(255, 240, 240, 222); // Using Color constant fails, probably due to how Area.Color works (in AreaChartSeries.Color). + var someTransparency = 0; + var someUseHatch = false; + var someHatchStyle = HatchStyle.BackwardDiagonal; + var someHatchColor = Color.AliceBlue; + var someLineColor = Color.AliceBlue; + var someLineWidth = 2; + var someLineVisible = false; + var somePointerColor = Color.AliceBlue; + var somePointerStyle = PointerStyles.Circle; + var somePointerVisible = false; + var somePointerSize = 2; + var somePointerLineColor = Color.AliceBlue; + var somePointerLineVisible = false; + + chartSeries.Expect(cs => cs.InterpolationType).SetPropertyWithArgument(someInterpolationType); + chartSeries.Expect(cs => cs.Color).SetPropertyWithArgument(someColor); + chartSeries.Expect(cs => cs.Transparency).SetPropertyWithArgument(someTransparency); + chartSeries.Expect(cs => cs.UseHatch).SetPropertyWithArgument(someUseHatch); + chartSeries.Expect(cs => cs.HatchStyle).SetPropertyWithArgument(someHatchStyle); + chartSeries.Expect(cs => cs.HatchColor).SetPropertyWithArgument(someHatchColor); + chartSeries.Expect(cs => cs.LineColor).SetPropertyWithArgument(someLineColor); + chartSeries.Expect(cs => cs.LineWidth).SetPropertyWithArgument(someLineWidth); + chartSeries.Expect(cs => cs.LineVisible).SetPropertyWithArgument(someLineVisible); + chartSeries.Expect(cs => cs.PointerColor).SetPropertyWithArgument(somePointerColor); + chartSeries.Expect(cs => cs.PointerStyle).SetPropertyWithArgument(somePointerStyle); + chartSeries.Expect(cs => cs.PointerVisible).SetPropertyWithArgument(somePointerVisible); + chartSeries.Expect(cs => cs.PointerSize).SetPropertyWithArgument(somePointerSize); + chartSeries.Expect(cs => cs.PointerLineColor).SetPropertyWithArgument(somePointerLineColor); + chartSeries.Expect(cs => cs.PointerLineVisible).SetPropertyWithArgument(somePointerLineVisible); + + mocks.ReplayAll(); + + // Call + new AreaChartSeriesProperties + { + Data = chartSeries, + InterpolationType = someInterpolationType, + Color = someColor, + Transparency = someTransparency, + UseHatch = someUseHatch, + HatchStyle = someHatchStyle, + HatchColor = someHatchColor, + LineColor = someLineColor, + LineWidth = someLineWidth, + LineVisible = someLineVisible, + PointerColor = somePointerColor, + PointerStyle = somePointerStyle, + PointerVisible = somePointerVisible, + PointerSize = somePointerSize, + PointerLineColor = somePointerLineColor, + PointerLineVisible = somePointerLineVisible + }; + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_Always_ReturnsEightteenProperties() + { + // Setup + var mocks = new MockRepository(); + var data = mocks.Stub(); + + mocks.ReplayAll(); + + var bag = new DynamicPropertyBag(new AreaChartSeriesProperties + { + Data = data + }); + + // Call + var properties = bag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + + // Assert + Assert.AreEqual(18, properties.Count); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Property/BarSeriesPropertiesTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Property/BarSeriesPropertiesTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Property/BarSeriesPropertiesTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,177 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using Core.Common.Controls.Charting.Series; +using Core.Common.Utils.PropertyBag; +using Core.Plugins.Charting.Property; +using NUnit.Framework; + +namespace Core.Plugins.Charting.Test.Property +{ + [TestFixture] + public class BarSeriesPropertiesTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var properties = new BarSeriesProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void Color_WithData_SameAsData() + { + // Setup + var someColor = Color.AliceBlue; + var otherColor = Color.AntiqueWhite; + + var chartSeries = new BarSeries + { + Color = someColor + }; + var properties = new BarSeriesProperties + { + Data = chartSeries + }; + + // Call & Assert + Assert.AreEqual(someColor, properties.Color); + + // Call + properties.Color = otherColor; + + // Assert + Assert.AreEqual(otherColor, chartSeries.Color); + } + + [Test] + public void LineColor_WithData_SameAsData() + { + // Setup + var someLineColor = Color.AliceBlue; + var otherLineColor = Color.AntiqueWhite; + + var chartSeries = new BarSeries + { + LineColor = someLineColor + }; + var properties = new BarSeriesProperties + { + Data = chartSeries + }; + + // Call & Assert + Assert.AreEqual(someLineColor, properties.LineColor); + + // Call + properties.LineColor = otherLineColor; + + // Assert + Assert.AreEqual(otherLineColor, chartSeries.LineColor); + } + + [Test] + public void Width_WithData_SameAsData() + { + // Setup + var someWidth = 2; + var otherWidth = 3; + + var chartSeries = new BarSeries + { + LineWidth = someWidth + }; + var properties = new BarSeriesProperties + { + Data = chartSeries + }; + + // Call & Assert + Assert.AreEqual(someWidth, properties.Width); + + // Call + properties.Width = otherWidth; + + // Assert + Assert.AreEqual(otherWidth, chartSeries.LineWidth); + } + + [Test] + public void DashStyle_WithData_SameAsData() + { + // Setup + var someDashStyle = DashStyle.Dash; + var otherDashStyle = DashStyle.Dot; + + var chartSeries = new BarSeries + { + DashStyle = someDashStyle + }; + var properties = new BarSeriesProperties + { + Data = chartSeries + }; + + // Call & Assert + Assert.AreEqual(someDashStyle, properties.DashStyle); + + // Call + properties.DashStyle = otherDashStyle; + + // Assert + Assert.AreEqual(otherDashStyle, chartSeries.DashStyle); + } + + [Test] + public void LineVisible_WithData_SameAsData() + { + // Setup + var someLineVisible = false; + var otherLineVisible = true; + + var chartSeries = new BarSeries + { + LineVisible = someLineVisible + }; + var properties = new BarSeriesProperties + { + Data = chartSeries + }; + + // Call & Assert + Assert.AreEqual(someLineVisible, properties.LineVisible); + + // Call + properties.LineVisible = otherLineVisible; + + // Assert + Assert.AreEqual(otherLineVisible, chartSeries.LineVisible); + } + + [Test] + public void GetProperties_Always_ReturnsEightProperties() + { + // Setup + var data = new BarSeries(); + + var bag = new DynamicPropertyBag(new BarSeriesProperties + { + Data = data + }); + + // Call + var properties = bag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + + // Assert + Assert.AreEqual(8, properties.Count); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartAxisDateTimePropertiesTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartAxisDateTimePropertiesTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartAxisDateTimePropertiesTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,94 @@ +using System; +using System.ComponentModel; +using Core.Common.Controls.Charting; +using Core.Common.Utils.PropertyBag; +using Core.Plugins.Charting.Property; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Property +{ + [TestFixture] + public class ChartAxisDateTimePropertiesTest + { + [Test] + public void Constructor_WithAxis_ExpectedValues() + { + // Call + var mocks = new MockRepository(); + var chartAxis = mocks.StrictMock(); + var properties = new ChartAxisDateTimeProperties(chartAxis); + + // Assert + Assert.IsInstanceOf(properties); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var random = new Random(21); + var maximum = random.NextDouble(); + var minimum = random.NextDouble(); + var chartAxis = mocks.StrictMock(); + chartAxis.Expect(a => a.Maximum).Return(maximum); + chartAxis.Expect(a => a.Minimum).Return(minimum); + + mocks.ReplayAll(); + + var properties = new ChartAxisDateTimeProperties(chartAxis); + + // Call & Assert + Assert.AreEqual(DateTime.FromOADate(maximum), properties.Maximum); + Assert.AreEqual(DateTime.FromOADate(minimum), properties.Minimum); + + mocks.VerifyAll(); + } + + [Test] + public void SetProperties_WithData_CallsSetters() + { + // Setup + var mocks = new MockRepository(); + var chartAxis = mocks.StrictMock(); + var maximum = DateTime.Parse("2015/12/17"); + var minimum = DateTime.Parse("2015/12/3"); + chartAxis.Expect(a => a.Maximum).SetPropertyWithArgument(maximum.ToOADate()); + chartAxis.Expect(a => a.Minimum).SetPropertyWithArgument(minimum.ToOADate()); + + mocks.ReplayAll(); + + // Call + new ChartAxisDateTimeProperties(chartAxis) + { + Maximum = maximum, + Minimum = minimum + }; + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_Always_ReturnsEightProperties() + { + // Setup + var mocks = new MockRepository(); + var chartAxis = mocks.Stub(); + + mocks.ReplayAll(); + + var bag = new DynamicPropertyBag(new ChartAxisDateTimeProperties(chartAxis)); + + // Call + var properties = bag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + + // Assert + Assert.AreEqual(8, properties.Count); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartAxisDoublePropertiesTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartAxisDoublePropertiesTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartAxisDoublePropertiesTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,101 @@ +using System; +using System.ComponentModel; +using Core.Common.Controls.Charting; +using Core.Common.Utils.PropertyBag; +using Core.Plugins.Charting.Property; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Property +{ + [TestFixture] + public class ChartAxisDoublePropertiesTest + { + [Test] + public void Constructor_WithAxis_ExpectedValues() + { + // Call + var mocks = new MockRepository(); + var chartAxis = mocks.StrictMock(); + var properties = new ChartAxisDoubleProperties(chartAxis); + + // Assert + Assert.IsInstanceOf(properties); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var random = new Random(21); + var maximum = random.NextDouble(); + var minimum = random.NextDouble(); + var logaritmic = true; + var chartAxis = mocks.StrictMock(); + chartAxis.Expect(a => a.Maximum).Return(maximum); + chartAxis.Expect(a => a.Minimum).Return(minimum); + chartAxis.Expect(a => a.Logaritmic).Return(logaritmic); + + mocks.ReplayAll(); + + var properties = new ChartAxisDoubleProperties(chartAxis); + + // Call & Assert + Assert.AreEqual(maximum, properties.Maximum); + Assert.AreEqual(minimum, properties.Minimum); + Assert.AreEqual(logaritmic, properties.Logaritmic); + + mocks.VerifyAll(); + } + + [Test] + public void SetProperties_WithData_CallsSetters() + { + // Setup + var mocks = new MockRepository(); + var chartAxis = mocks.StrictMock(); + var random = new Random(21); + var maximum = random.NextDouble(); + var minimum = random.NextDouble(); + var logaritmic = true; + chartAxis.Expect(a => a.Maximum).SetPropertyWithArgument(maximum); + chartAxis.Expect(a => a.Minimum).SetPropertyWithArgument(minimum); + chartAxis.Expect(a => a.Logaritmic).SetPropertyWithArgument(logaritmic); + + mocks.ReplayAll(); + + // Call + new ChartAxisDoubleProperties(chartAxis) + { + Maximum = maximum, + Minimum = minimum, + Logaritmic = logaritmic + }; + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_Always_ReturnsNineProperties() + { + // Setup + var mocks = new MockRepository(); + var chartAxis = mocks.Stub(); + + mocks.ReplayAll(); + + var bag = new DynamicPropertyBag(new ChartAxisDoubleProperties(chartAxis)); + + // Call + var properties = bag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + + // Assert + Assert.AreEqual(9, properties.Count); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartAxisPropertiesTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartAxisPropertiesTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartAxisPropertiesTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,112 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using Core.Common.Controls.Charting; +using Core.Common.Utils.PropertyBag; +using Core.Plugins.Charting.Property; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Property +{ + [TestFixture] + public class ChartAxisPropertiesTest + { + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var visible = true; + var automatic = true; + var title = "some title"; + var labels = true; + var labelsFont = new Font(FontFamily.GenericSansSerif, 12); + var titleFont = new Font(FontFamily.GenericSansSerif, 12); + + var chartAxis = mocks.StrictMock(); + chartAxis.Expect(a => a.Visible).Return(visible); + chartAxis.Expect(a => a.Automatic).Return(automatic); + chartAxis.Expect(a => a.Title).Return(title); + chartAxis.Expect(a => a.Labels).Return(labels); + chartAxis.Expect(a => a.LabelsFont).Return(labelsFont); + chartAxis.Expect(a => a.TitleFont).Return(titleFont); + + mocks.ReplayAll(); + + var properties = new TestChartAxisProperties(chartAxis); + + // Call & Assert + Assert.AreEqual(visible, properties.Visible); + Assert.AreEqual(automatic, properties.Automatic); + Assert.AreEqual(title, properties.Title); + Assert.AreEqual(labels, properties.Labels); + Assert.AreEqual(labelsFont, properties.LabelsFont); + Assert.AreEqual(titleFont, properties.TitleFont); + + mocks.VerifyAll(); + } + + [Test] + public void SetProperties_WithData_CallsSetters() + { + // Setup + var mocks = new MockRepository(); + var visible = true; + var automatic = true; + var title = "some title"; + var labels = true; + var labelsFont = new Font(FontFamily.GenericSansSerif, 12); + var titleFont = new Font(FontFamily.GenericSansSerif, 12); + + var chartAxis = mocks.StrictMock(); + chartAxis.Expect(a => a.Visible).SetPropertyWithArgument(visible); + chartAxis.Expect(a => a.Automatic).SetPropertyWithArgument(automatic); + chartAxis.Expect(a => a.Title).SetPropertyWithArgument(title); + chartAxis.Expect(a => a.Labels).SetPropertyWithArgument(labels); + chartAxis.Expect(a => a.LabelsFont).SetPropertyWithArgument(labelsFont); + chartAxis.Expect(a => a.TitleFont).SetPropertyWithArgument(titleFont); + mocks.ReplayAll(); + + // Call + new TestChartAxisProperties(chartAxis) + { + Visible = visible, + Automatic = automatic, + Title = title, + Labels = labels, + LabelsFont = labelsFont, + TitleFont = titleFont + }; + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_Always_ReturnsSixProperties() + { + // Setup + var mocks = new MockRepository(); + var chartAxis = mocks.Stub(); + + mocks.ReplayAll(); + + var bag = new DynamicPropertyBag(new TestChartAxisProperties(chartAxis)); + + // Call + var properties = bag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + + // Assert + Assert.AreEqual(6, properties.Count); + } + } + + public class TestChartAxisProperties : ChartAxisProperties + { + public TestChartAxisProperties(IChartAxis chartAxis) : base(chartAxis) {} + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartFontPropertiesConverterTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartFontPropertiesConverterTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartFontPropertiesConverterTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,49 @@ +using System.Drawing; +using Core.Plugins.Charting.Property; +using NUnit.Framework; + +namespace Core.Plugins.Charting.Test.Property +{ + [TestFixture] + public class ChartFontPropertiesConverterTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var converter = new ChartFontPropertiesConverter(); + + // Assert + Assert.IsInstanceOf(converter); + } + + [Test] + public void GetProperties_Always_ReturnsAllowedProperties() + { + // Setup + var converter = new ChartFontPropertiesConverter(); + // Call + var properties = converter.GetProperties(new Font(FontFamily.GenericSansSerif, 12)); + + // Assert + Assert.AreEqual(5, properties.Count); + var sizeProperty = properties.Find("Size", false); + var boldProperty = properties.Find("Bold", false); + var italicProperty = properties.Find("Italic", false); + var underlineProperty = properties.Find("Underline", false); + var strikeoutProperty = properties.Find("Strikeout", false); + + Assert.True(sizeProperty.IsReadOnly); + Assert.True(boldProperty.IsReadOnly); + Assert.True(italicProperty.IsReadOnly); + Assert.True(underlineProperty.IsReadOnly); + Assert.True(strikeoutProperty.IsReadOnly); + + Assert.AreEqual("Size", sizeProperty.DisplayName); + Assert.AreEqual("Bold", boldProperty.DisplayName); + Assert.AreEqual("Italic", italicProperty.DisplayName); + Assert.AreEqual("Underline", underlineProperty.DisplayName); + Assert.AreEqual("Strikeout", strikeoutProperty.DisplayName); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartPropertiesTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartPropertiesTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartPropertiesTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,112 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using Core.Common.Controls.Charting; +using Core.Common.Gui; +using Core.Common.Utils.PropertyBag; +using Core.Plugins.Charting.Property; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Property +{ + [TestFixture] + public class ChartPropertiesTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var properties = new ChartProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var chartAxis = mocks.StrictMock(); + var chart = mocks.StrictMock(); + var legend = mocks.StrictMock(); + + var backgroundColor = Color.AliceBlue; + var showLegend = false; + var legendAlignment = LegendAlignment.Top; + var legendFont = new Font(FontFamily.GenericSansSerif, 12); + var title = "some title"; + var titleFont = new Font(FontFamily.GenericSansSerif, 12); + var titleVisible = false; + + chart.Expect(a => a.BackGroundColor).Return(backgroundColor); + chart.Expect(a => a.Title).Return(title); + chart.Expect(a => a.Font).Return(titleFont); + chart.Expect(a => a.TitleVisible).Return(titleVisible); + chart.Expect(a => a.LeftAxis).Return(chartAxis).Repeat.Twice(); + chart.Expect(a => a.BottomAxis).Return(chartAxis).Repeat.Twice(); + chart.Expect(a => a.RightAxis).Return(chartAxis).Repeat.Twice(); + + chart.Expect(a => a.Legend).Return(legend).Repeat.Times(3); + legend.Expect(a => a.Visible).Return(showLegend); + legend.Expect(a => a.Alignment).Return(legendAlignment); + legend.Expect(a => a.Font).Return(legendFont); + + chartAxis.Expect(a => a.IsDateTime).Return(false).Repeat.Times(3); + + mocks.ReplayAll(); + + var properties = new ChartProperties + { + Data = chart + }; + + // Call & Assert + Assert.AreEqual(backgroundColor, properties.BackgroundColor); + Assert.AreEqual(showLegend, properties.ShowLegend); + Assert.AreEqual(legendAlignment, properties.LegendAlignment); + Assert.AreEqual(legendFont, properties.LegendFont); + Assert.AreEqual(title, properties.Title); + Assert.AreEqual(titleFont, properties.TitleFont); + Assert.AreEqual(titleVisible, properties.TitleVisibile); + Assert.IsInstanceOf(properties.LeftAxis); + Assert.IsInstanceOf(properties.BottomAxis); + Assert.IsInstanceOf(properties.RightAxis); + + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_Always_ReturnsTenProperties() + { + // Setup + var mocks = new MockRepository(); + var data = mocks.Stub(); + var chartAxis = mocks.Stub(); + var legend = mocks.Stub(); + + data.Expect(a => a.Legend).Return(legend).Repeat.AtLeastOnce(); + data.Expect(a => a.LeftAxis).Return(chartAxis).Repeat.AtLeastOnce(); + data.Expect(a => a.BottomAxis).Return(chartAxis).Repeat.AtLeastOnce(); + data.Expect(a => a.RightAxis).Return(chartAxis).Repeat.AtLeastOnce(); + + mocks.ReplayAll(); + + var bag = new DynamicPropertyBag(new ChartProperties + { + Data = data + }); + + // Call + var properties = bag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + + // Assert + Assert.AreEqual(10, properties.Count); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartSeriesPropertiesTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartSeriesPropertiesTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Property/ChartSeriesPropertiesTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,106 @@ +using System; +using System.ComponentModel; +using Core.Common.Controls.Charting; +using Core.Common.Gui; +using Core.Common.Utils.PropertyBag; +using Core.Plugins.Charting.Property; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Property +{ + [TestFixture] + public class ChartSeriesPropertiesTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var properties = new ChartSeriesProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var showInLegend = false; + var title = "some title"; + var verticalAxis = new VerticalAxis(); + var chartSeries = mocks.StrictMock(); + chartSeries.Expect(a => a.ShowInLegend).Return(showInLegend); + chartSeries.Expect(a => a.Title).Return(title); + chartSeries.Expect(a => a.VertAxis).Return(verticalAxis); + + mocks.ReplayAll(); + + var properties = new ChartSeriesProperties + { + Data = chartSeries + }; + + // Call & Assert + Assert.AreEqual(showInLegend, properties.ShowInLegend); + Assert.AreEqual(title, properties.Title); + Assert.AreEqual(verticalAxis, properties.VerticalAxis); + + mocks.VerifyAll(); + } + + [Test] + public void SetProperties_WithData_CallsSetters() + { + // Setup + var mocks = new MockRepository(); + var chartSeries = mocks.StrictMock(); + var showInLegend = false; + var title = "some title"; + var verticalAxis = new VerticalAxis(); + chartSeries.Expect(a => a.ShowInLegend).SetPropertyWithArgument(showInLegend); + chartSeries.Expect(a => a.Title).SetPropertyWithArgument(title); + chartSeries.Expect(a => a.VertAxis).SetPropertyWithArgument(verticalAxis); + + mocks.ReplayAll(); + + // Call + new ChartSeriesProperties + { + Data = chartSeries, + ShowInLegend = showInLegend, + Title = title, + VerticalAxis = verticalAxis + }; + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_Always_ReturnsThreeProperties() + { + // Setup + var mocks = new MockRepository(); + var data = mocks.Stub(); + + mocks.ReplayAll(); + + var bag = new DynamicPropertyBag(new ChartSeriesProperties + { + Data = data + }); + + // Call + var properties = bag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + + // Assert + Assert.AreEqual(3, properties.Count); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Property/LineChartSeriesPropertiesTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Property/LineChartSeriesPropertiesTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Property/LineChartSeriesPropertiesTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,152 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using Core.Common.Controls.Charting; +using Core.Common.Controls.Charting.Series; +using Core.Common.Utils.PropertyBag; +using Core.Plugins.Charting.Property; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Property +{ + [TestFixture] + public class LineChartSeriesPropertiesTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var properties = new LineChartSeriesProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var random = new Random(21); + var interpolationType = InterpolationType.Linear; + var titleLabelVisible = false; + var color = Color.AliceBlue; + var width = random.Next(1, 10); + var dashStyle = DashStyle.Dash; + var pointerSize = random.Next(1,10); + var pointerLineColor = Color.AliceBlue; + var pointerStyle = PointerStyles.SmallDot; + var pointerVisible = false; + var pointerLineVisible = false; + var chartSeries = mocks.StrictMock(); + + chartSeries.Expect(a => a.InterpolationType).Return(interpolationType); + chartSeries.Expect(a => a.TitleLabelVisible).Return(titleLabelVisible); + chartSeries.Expect(a => a.Color).Return(color); + chartSeries.Expect(a => a.Width).Return(width); + chartSeries.Expect(a => a.DashStyle).Return(dashStyle); + chartSeries.Expect(a => a.PointerSize).Return(pointerSize); + chartSeries.Expect(a => a.PointerLineColor).Return(pointerLineColor); + chartSeries.Expect(a => a.PointerStyle).Return(pointerStyle); + chartSeries.Expect(a => a.PointerVisible).Return(pointerVisible); + chartSeries.Expect(a => a.PointerLineVisible).Return(pointerLineVisible); + + mocks.ReplayAll(); + + var properties = new LineChartSeriesProperties{ + Data = chartSeries + }; + + // Call & Assert + Assert.AreEqual(interpolationType, properties.InterpolationType); + Assert.AreEqual(titleLabelVisible, properties.TitleLabelVisible); + Assert.AreEqual(color, properties.Color); + Assert.AreEqual(width, properties.Width); + Assert.AreEqual(dashStyle, properties.DashStyle); + Assert.AreEqual(pointerSize, properties.PointerSize); + Assert.AreEqual(pointerLineColor, properties.PointerLineColor); + Assert.AreEqual(pointerStyle, properties.PointerStyle); + Assert.AreEqual(pointerVisible, properties.PointerVisible); + Assert.AreEqual(pointerLineVisible, properties.PointerLineVisible); + + mocks.VerifyAll(); + } + + [Test] + public void SetProperties_WithData_CallsSetters() + { + // Setup + var mocks = new MockRepository(); + var random = new Random(21); + var interpolationType = InterpolationType.Linear; + var titleLabelVisible = false; + var color = Color.AliceBlue; + var width = random.Next(1, 10); + var dashStyle = DashStyle.Dash; + var pointerSize = random.Next(1, 10); + var pointerLineColor = Color.AliceBlue; + var pointerStyle = PointerStyles.SmallDot; + var pointerVisible = false; + var pointerLineVisible = false; + var chartSeries = mocks.StrictMock(); + + chartSeries.Expect(a => a.InterpolationType).SetPropertyWithArgument(interpolationType); + chartSeries.Expect(a => a.TitleLabelVisible).SetPropertyWithArgument(titleLabelVisible); + chartSeries.Expect(a => a.Color).SetPropertyWithArgument(color); + chartSeries.Expect(a => a.Width).SetPropertyWithArgument(width); + chartSeries.Expect(a => a.DashStyle).SetPropertyWithArgument(dashStyle); + chartSeries.Expect(a => a.PointerSize).SetPropertyWithArgument(pointerSize); + chartSeries.Expect(a => a.PointerLineColor).SetPropertyWithArgument(pointerLineColor); + chartSeries.Expect(a => a.PointerStyle).SetPropertyWithArgument(pointerStyle); + chartSeries.Expect(a => a.PointerVisible).SetPropertyWithArgument(pointerVisible); + chartSeries.Expect(a => a.PointerLineVisible).SetPropertyWithArgument(pointerLineVisible); + + mocks.ReplayAll(); + + // Call + new LineChartSeriesProperties{ + Data = chartSeries, + InterpolationType = interpolationType, + TitleLabelVisible = titleLabelVisible, + Color = color, + Width = width, + DashStyle = dashStyle, + PointerSize = pointerSize, + PointerLineColor = pointerLineColor, + PointerStyle = pointerStyle, + PointerVisible = pointerVisible, + PointerLineVisible = pointerLineVisible + }; + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_Always_ReturnsFourteenProperties() + { + // Setup + var mocks = new MockRepository(); + var data = mocks.Stub(); + + mocks.ReplayAll(); + + var bag = new DynamicPropertyBag(new LineChartSeriesProperties + { + Data = data + }); + + // Call + var properties = bag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + + // Assert + Assert.AreEqual(14, properties.Count); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Property/PointChartSeriesPropertiesTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Property/PointChartSeriesPropertiesTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Property/PointChartSeriesPropertiesTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,123 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using Core.Common.Controls.Charting; +using Core.Common.Controls.Charting.Series; +using Core.Common.Utils.PropertyBag; +using Core.Plugins.Charting.Property; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Property +{ + [TestFixture] + public class PointChartSeriesPropertiesTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var properties = new PointChartSeriesProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var random = new Random(21); + var color = Color.AliceBlue; + var lineColor = Color.AliceBlue; + var pointerLineVisible = false; + var size = random.Next(1, 10); + var style = PointerStyles.SmallDot; + var chartSeries = mocks.StrictMock(); + + chartSeries.Expect(a => a.Color).Return(color); + chartSeries.Expect(a => a.LineColor).Return(lineColor); + chartSeries.Expect(a => a.LineVisible).Return(pointerLineVisible); + chartSeries.Expect(a => a.Size).Return(size); + chartSeries.Expect(a => a.Style).Return(style); + + mocks.ReplayAll(); + + var properties = new PointChartSeriesProperties + { + Data = chartSeries + }; + + // Call & Assert + Assert.AreEqual(color, properties.Color); + Assert.AreEqual(lineColor, properties.LineColor); + Assert.AreEqual(pointerLineVisible, properties.PointerLineVisible); + Assert.AreEqual(size, properties.Size); + Assert.AreEqual(style, properties.Style); + + mocks.VerifyAll(); + } + + [Test] + public void SetProperties_WithData_CallsSetters() + { + // Setup + var mocks = new MockRepository(); + var random = new Random(21); + var color = Color.AliceBlue; + var lineColor = Color.AliceBlue; + var pointerLineVisible = false; + var size = random.Next(1, 10); + var style = PointerStyles.SmallDot; + var chartSeries = mocks.StrictMock(); + + chartSeries.Expect(a => a.Color).SetPropertyWithArgument(color); + chartSeries.Expect(a => a.LineColor).SetPropertyWithArgument(lineColor); + chartSeries.Expect(a => a.LineVisible).SetPropertyWithArgument(pointerLineVisible); + chartSeries.Expect(a => a.Size).SetPropertyWithArgument(size); + chartSeries.Expect(a => a.Style).SetPropertyWithArgument(style); + + mocks.ReplayAll(); + + // Call + new PointChartSeriesProperties + { + Data = chartSeries, + Color = color, + LineColor = lineColor, + PointerLineVisible = pointerLineVisible, + Size = size, + Style = style + }; + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_Always_ReturnsEightProperties() + { + // Setup + var mocks = new MockRepository(); + var data = mocks.Stub(); + + mocks.ReplayAll(); + + var bag = new DynamicPropertyBag(new PointChartSeriesProperties + { + Data = data + }); + + // Call + var properties = bag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + + // Assert + Assert.AreEqual(8, properties.Count); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/Property/PolygonChartSeriesPropertiesTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/Property/PolygonChartSeriesPropertiesTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/Property/PolygonChartSeriesPropertiesTest.cs (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,148 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using Core.Common.Controls.Charting.Series; +using Core.Common.Utils.PropertyBag; +using Core.Plugins.Charting.Property; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Charting.Test.Property +{ + [TestFixture] + public class PolygonChartSeriesPropertiesTest + { + + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var properties = new PolygonChartSeriesProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var random = new Random(21); + var closed = false; + var color = Color.AliceBlue; + var transparency = random.Next(1, 10); + var useHatch = false; + var hatchStyle = HatchStyle.Cross; + var hatchColor = Color.AliceBlue; + var lineColor = Color.AliceBlue; + var lineWidth = random.Next(1, 10); + var lineVisible = false; + var chartSeries = mocks.StrictMock(); + + chartSeries.Expect(a => a.AutoClose).Return(closed); + chartSeries.Expect(a => a.Color).Return(color); + chartSeries.Expect(a => a.Transparency).Return(transparency); + chartSeries.Expect(a => a.UseHatch).Return(useHatch); + chartSeries.Expect(a => a.HatchStyle).Return(hatchStyle); + chartSeries.Expect(a => a.HatchColor).Return(hatchColor); + chartSeries.Expect(a => a.LineColor).Return(lineColor); + chartSeries.Expect(a => a.LineWidth).Return(lineWidth); + chartSeries.Expect(a => a.LineVisible).Return(lineVisible); + + mocks.ReplayAll(); + + var properties = new PolygonChartSeriesProperties + { + Data = chartSeries + }; + + // Call & Assert + Assert.AreEqual(closed, properties.Closed); + Assert.AreEqual(color, properties.Color); + Assert.AreEqual(transparency, properties.Transparency); + Assert.AreEqual(useHatch, properties.UseHatch); + Assert.AreEqual(hatchStyle, properties.HatchStyle); + Assert.AreEqual(hatchColor, properties.HatchColor); + Assert.AreEqual(lineColor, properties.LineColor); + Assert.AreEqual(lineWidth, properties.LineWidth); + Assert.AreEqual(lineVisible, properties.LineVisible); + + mocks.VerifyAll(); + } + + [Test] + public void SetProperties_WithData_CallsSetters() + { + // Setup + var mocks = new MockRepository(); + var random = new Random(21); + var closed = false; + var color = Color.AliceBlue; + var transparency = random.Next(1, 10); + var useHatch = false; + var hatchStyle = HatchStyle.Cross; + var hatchColor = Color.AliceBlue; + var lineColor = Color.AliceBlue; + var lineWidth = random.Next(1, 10); + var lineVisible = false; + var chartSeries = mocks.StrictMock(); + + chartSeries.Expect(a => a.AutoClose).SetPropertyWithArgument(closed); + chartSeries.Expect(a => a.Color).SetPropertyWithArgument(color); + chartSeries.Expect(a => a.Transparency).SetPropertyWithArgument(transparency); + chartSeries.Expect(a => a.UseHatch).SetPropertyWithArgument(useHatch); + chartSeries.Expect(a => a.HatchStyle).SetPropertyWithArgument(hatchStyle); + chartSeries.Expect(a => a.HatchColor).SetPropertyWithArgument(hatchColor); + chartSeries.Expect(a => a.LineColor).SetPropertyWithArgument(lineColor); + chartSeries.Expect(a => a.LineWidth).SetPropertyWithArgument(lineWidth); + chartSeries.Expect(a => a.LineVisible).SetPropertyWithArgument(lineVisible); + + mocks.ReplayAll(); + + // Call + new PolygonChartSeriesProperties + { + Data = chartSeries, + Closed = closed, + Color = color, + Transparency = transparency, + UseHatch = useHatch, + HatchStyle = hatchStyle, + HatchColor = hatchColor, + LineColor = lineColor, + LineWidth = lineWidth, + LineVisible = lineVisible + }; + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_Always_ReturnsTwelveProperties() + { + // Setup + var mocks = new MockRepository(); + var data = mocks.Stub(); + + mocks.ReplayAll(); + + var bag = new DynamicPropertyBag(new PolygonChartSeriesProperties + { + Data = data + }); + + // Call + var properties = bag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + + // Assert + Assert.AreEqual(12, properties.Count); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Charting.Test/packages.config =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Charting.Test/packages.config (revision 0) +++ Core/Plugins/test/Core.Plugins.Charting.Test/packages.config (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/App.config'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/ChartingGuiPluginTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Commands/Charting/ChartViewCommandBaseTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Commands/Charting/DecreaseFontSizeCommandTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Commands/Charting/ExportChartAsImageCommandTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Commands/Charting/IncreaseFontSizeCommandTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Core.Plugins.CommonTools.Gui.Test.csproj =================================================================== diff -u -r477b3dd45b75bf40fcdd4dcba75ae194ea201446 -rf0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 --- Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Core.Plugins.CommonTools.Gui.Test.csproj (.../Core.Plugins.CommonTools.Gui.Test.csproj) (revision 477b3dd45b75bf40fcdd4dcba75ae194ea201446) +++ Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Core.Plugins.CommonTools.Gui.Test.csproj (.../Core.Plugins.CommonTools.Gui.Test.csproj) (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -80,24 +80,6 @@ - - - - - - - - - - - - - - - - - - @@ -173,7 +155,6 @@ - Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Forms/Charting/ChartSeriesTreeNodePresenterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Forms/Charting/ChartTreeNodePresenterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Forms/TextDocumentViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/AreaChartSeriesPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/BarSeriesPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartAxisDateTimePropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartAxisDoublePropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartAxisPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartFontPropertiesConverterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartSeriesPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/LineChartSeriesPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/PointChartSeriesPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/PolygonChartSeriesPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets.sln =================================================================== diff -u -r477b3dd45b75bf40fcdd4dcba75ae194ea201446 -rf0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 --- Ringtoets.sln (.../Ringtoets.sln) (revision 477b3dd45b75bf40fcdd4dcba75ae194ea201446) +++ Ringtoets.sln (.../Ringtoets.sln) (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -231,6 +231,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.Plugins.Charting", "Core\Plugins\src\Core.Plugins.Charting\Core.Plugins.Charting.csproj", "{16050ED1-3E4F-4540-9B5D-6ADD4FC43D9D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.Plugins.Charting.Test", "Core\Plugins\test\Core.Plugins.Charting.Test\Core.Plugins.Charting.Test.csproj", "{B0A220BE-9029-47B3-89C6-7562094819B7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution CreateInstaller|x86 = CreateInstaller|x86 @@ -943,6 +945,14 @@ {16050ED1-3E4F-4540-9B5D-6ADD4FC43D9D}.Release|x86.Build.0 = Release|x86 {16050ED1-3E4F-4540-9B5D-6ADD4FC43D9D}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86 {16050ED1-3E4F-4540-9B5D-6ADD4FC43D9D}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86 + {B0A220BE-9029-47B3-89C6-7562094819B7}.CreateInstaller|x86.ActiveCfg = Release|x86 + {B0A220BE-9029-47B3-89C6-7562094819B7}.CreateInstallerWithDemoProject|x86.ActiveCfg = Release|x86 + {B0A220BE-9029-47B3-89C6-7562094819B7}.Debug|x86.ActiveCfg = Debug|x86 + {B0A220BE-9029-47B3-89C6-7562094819B7}.Debug|x86.Build.0 = Debug|x86 + {B0A220BE-9029-47B3-89C6-7562094819B7}.Release|x86.ActiveCfg = Release|x86 + {B0A220BE-9029-47B3-89C6-7562094819B7}.Release|x86.Build.0 = Release|x86 + {B0A220BE-9029-47B3-89C6-7562094819B7}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86 + {B0A220BE-9029-47B3-89C6-7562094819B7}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1013,6 +1023,7 @@ {8BD31773-6F6D-42EE-810D-0A5DAD809F9D} = {209AC67F-DCFA-4355-B45A-9D9A2E4593D2} {07206938-9671-4DC7-BDE4-35B0F6E20DBC} = {209AC67F-DCFA-4355-B45A-9D9A2E4593D2} {4FDA4BD2-2C84-4C7C-9908-818884D52DBB} = {209AC67F-DCFA-4355-B45A-9D9A2E4593D2} + {B0A220BE-9029-47B3-89C6-7562094819B7} = {209AC67F-DCFA-4355-B45A-9D9A2E4593D2} {0590D3BB-EB3E-4B53-BD64-1725E1CBB1F4} = {041EDC04-3A1E-4FBA-BEB7-F391571C609F} {B5F4F5A5-FD36-405D-ABA1-56C270207C8F} = {041EDC04-3A1E-4FBA-BEB7-F391571C609F} {BC8DB1E0-0428-4FB1-9A63-028C749A8AF9} = {041EDC04-3A1E-4FBA-BEB7-F391571C609F} Index: packages/repositories.config =================================================================== diff -u -r477b3dd45b75bf40fcdd4dcba75ae194ea201446 -rf0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43 --- packages/repositories.config (.../repositories.config) (revision 477b3dd45b75bf40fcdd4dcba75ae194ea201446) +++ packages/repositories.config (.../repositories.config) (revision f0c2a16f1d03185660d0ac6fbb5fce8bb5c2ee43) @@ -37,6 +37,7 @@ +