Index: Core/Components/test/Core.Components.OxyPlot.Forms.Test/BaseChartTest.cs =================================================================== diff -u -r2b683c57220a71446dcf4eda3894fd003546347f -rebc0e549bad9f3ae073dc82376509b9ee5a9fc49 --- Core/Components/test/Core.Components.OxyPlot.Forms.Test/BaseChartTest.cs (.../BaseChartTest.cs) (revision 2b683c57220a71446dcf4eda3894fd003546347f) +++ Core/Components/test/Core.Components.OxyPlot.Forms.Test/BaseChartTest.cs (.../BaseChartTest.cs) (revision ebc0e549bad9f3ae073dc82376509b9ee5a9fc49) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; using System.Windows.Forms; using Core.Common.Base; using Core.Components.Charting.Data; @@ -111,9 +112,23 @@ } [Test] + public void SetVisibility_SerieNotOnChart_ThrowsInvalidOperationException() + { + // Setup + var chart = new BaseChart(); + var pointData = new PointData(new Collection>()); + + // Call + TestDelegate test = () => chart.SetVisibility(pointData, true); + + // Assert + Assert.Throws(test); + } + + [Test] [TestCase(true)] [TestCase(false)] - public void SetVisibility_ForContainingData_SetsDataVisibility(bool visibility) + public void SetVisibility_SerieOnChart_SetsDataVisibility(bool visibility) { // Setup var chart = new BaseChart(); @@ -128,33 +143,79 @@ } [Test] - public void SetVisibility_ForNonContainingData_ThrowsInvalidOperationException() + public void SetVisibility_ForNull_ThrowsArgumentNullException() { // Setup var chart = new BaseChart(); - var pointData = new PointData(new Collection>()); // Call - TestDelegate test = () => chart.SetVisibility(pointData, true); + TestDelegate test = () => chart.SetVisibility(null, true); // Assert - Assert.Throws(test); + Assert.Throws(test); } [Test] - public void SetVisibility_ForNull_ThrowsArgumentNullException() + public void SetPosition_DataNull_ThrowsArgumentNullException() { // Setup var chart = new BaseChart(); // Call - TestDelegate test = () => chart.SetVisibility(null, true); - + TestDelegate test = () => chart.SetPosition(null, new Random(21).Next()); + // Assert Assert.Throws(test); } [Test] + public void SetPosition_SerieNotOnChart_ThrowsInvalidOperationException() + { + // Setup + BaseChart chart = CreateTestBaseChart(); + + // Call + TestDelegate test = () => chart.SetPosition(new TestChartData(), 0); + + // Assert + Assert.Throws(test); + } + + [Test] + [TestCase(-50)] + [TestCase(-1)] + [TestCase(3)] + [TestCase(50)] + public void SetPosition_SerieOnChartPositionOutsideRange_ThrowsInvalidOperationException(int position) + { + // Setup + BaseChart chart = CreateTestBaseChart(); + + // Call + TestDelegate test = () => chart.SetPosition(new TestChartData(), position); + + // Assert + Assert.Throws(test); + } + + [Test] + [TestCase(0)] + [TestCase(1)] + [TestCase(2)] + public void SetPosition_SerieOnChartPositionInRange_SetsNewPosition(int position) + { + // Setup + BaseChart chart = CreateTestBaseChart(); + var testElement = chart.Data.ElementAt(new Random(21).Next(0,3)); + + // Call + chart.SetPosition(testElement, position); + + // Assert + Assert.AreSame(testElement, chart.Data.ElementAt(position)); + } + + [Test] public void NotifyObservers_WithObserverAttached_ObserverIsNotified() { // Setup @@ -227,5 +288,18 @@ // Assert mocks.VerifyAll(); } + + private static BaseChart CreateTestBaseChart() + { + return new BaseChart + { + Data = new ChartData[] + { + new LineData(new List>()), + new PointData(new List>()), + new AreaData(new List>()) + } + }; + } } } \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartNodePresenterTest.cs =================================================================== diff -u -r2b683c57220a71446dcf4eda3894fd003546347f -rebc0e549bad9f3ae073dc82376509b9ee5a9fc49 --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartNodePresenterTest.cs (.../ChartNodePresenterTest.cs) (revision 2b683c57220a71446dcf4eda3894fd003546347f) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartNodePresenterTest.cs (.../ChartNodePresenterTest.cs) (revision ebc0e549bad9f3ae073dc82376509b9ee5a9fc49) @@ -89,7 +89,7 @@ BaseChart baseChart = CreateTestBaseChart(); ChartData testElement = baseChart.Data.ElementAt(0); - + // Call nodePresenter.OnDragDrop(testElement, null, baseChart, 0, position); @@ -98,19 +98,6 @@ Assert.AreSame(testElement, baseChart.Data.ElementAt(reversedIndex)); } - private static BaseChart CreateTestBaseChart() - { - return new BaseChart - { - Data = new ChartData[] - { - new LineData(new List>()), - new PointData(new List>()), - new AreaData(new List>()) - } - }; - } - [Test] [TestCase(-50)] [TestCase(-1)] @@ -144,7 +131,7 @@ // Assert Assert.AreEqual("Grafiek", treeNode.Text); TestHelper.AssertImagesAreEqual(Resources.folder, treeNode.Image); - } + } [Test] public void GetChildNodeObjects_Always_ReturnsReverseSeries() @@ -158,6 +145,19 @@ // Assert CollectionAssert.AreEqual(chart.Data.Reverse(), result); - } + } + + private static BaseChart CreateTestBaseChart() + { + return new BaseChart + { + Data = new ChartData[] + { + new LineData(new List>()), + new PointData(new List>()), + new AreaData(new List>()) + } + }; + } } } \ No newline at end of file