Index: Core/Components/src/Core.Components.Charting/Data/ChartData.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/src/Core.Components.Charting/Data/ChartData.cs (.../ChartData.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Components/src/Core.Components.Charting/Data/ChartData.cs (.../ChartData.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -5,13 +5,5 @@
///
/// Abstract class for data with the purpose of becoming visible in charting components.
///
- public abstract class ChartData : Observable
- {
- ///
- /// Creates a new instance of .
- ///
- protected ChartData()
- {
- }
- }
+ public abstract class ChartData : Observable { }
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.Charting/Data/ChartDataCollection.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/src/Core.Components.Charting/Data/ChartDataCollection.cs (.../ChartDataCollection.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Components/src/Core.Components.Charting/Data/ChartDataCollection.cs (.../ChartDataCollection.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -1,11 +1,18 @@
using System;
using System.Collections.Generic;
-using Core.Components.Charting.Data;
-namespace Core.Components.OxyPlot.Collection
+namespace Core.Components.Charting.Data
{
+ ///
+ /// This class represents collections of .
+ ///
public class ChartDataCollection : ChartData
{
+ ///
+ /// Creates a new instance of .
+ ///
+ /// A of .
+ /// Thrown when is null.
public ChartDataCollection(IList list)
{
if (list == null)
@@ -15,6 +22,9 @@
List = list;
}
+ ///
+ /// Gets the list of of the .
+ ///
public IList List { get; private set; }
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot.Forms/BaseChart.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/src/Core.Components.OxyPlot.Forms/BaseChart.cs (.../BaseChart.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Components/src/Core.Components.OxyPlot.Forms/BaseChart.cs (.../BaseChart.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -18,12 +18,12 @@
public sealed class BaseChart : Control, IObserver, IChart
{
private readonly ICollection observers = new Collection();
+ private readonly SeriesFactory seriesFactory = new SeriesFactory();
private ChartData data;
private LinearPlotView view;
private DynamicPlotController controller;
- private SeriesFactory seriesFactory = new SeriesFactory();
///
/// Creates a new instance of .
@@ -34,6 +34,56 @@
MinimumSize = new Size(50, 75);
}
+ ///
+ /// Attaches the to the currently set , if there is any.
+ ///
+ private void AttachToData()
+ {
+ if (data != null)
+ {
+ data.Attach(this);
+ }
+ }
+
+ ///
+ /// Detaches the to the currently set , if there is any.
+ ///
+ private void DetachFromData()
+ {
+ if (data != null)
+ {
+ data.Detach(this);
+ }
+ }
+
+ ///
+ /// Initialize the for the .
+ ///
+ private void InitializePlotView()
+ {
+ view = new LinearPlotView();
+ controller = new DynamicPlotController();
+ view.Controller = controller;
+ Controls.Add(view);
+ }
+
+ ///
+ /// Draws series based on the currently set .
+ ///
+ private void DrawSeries()
+ {
+ view.Model.Series.Clear();
+ if (data != null)
+ {
+ foreach (var series in seriesFactory.Create(data))
+ {
+ view.Model.Series.Add(series);
+ }
+ }
+ }
+
+ #region IChart
+
public bool IsPanningEnabled
{
get
@@ -50,7 +100,7 @@
}
}
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ChartData Data
{
get
@@ -66,22 +116,6 @@
}
}
- private void AttachToData()
- {
- if (data != null)
- {
- data.Attach(this);
- }
- }
-
- private void DetachFromData()
- {
- if (data != null)
- {
- data.Detach(this);
- }
- }
-
public void TogglePanning()
{
controller.TogglePanning();
@@ -97,17 +131,14 @@
view.ZoomToAll();
}
- ///
- /// Initialize the for the .
- ///
- private void InitializePlotView()
+ public void UpdateObserver()
{
- view = new LinearPlotView();
- controller = new DynamicPlotController();
- view.Controller = controller;
- Controls.Add(view);
+ DrawSeries();
+ view.InvalidatePlot(true);
}
+ #endregion
+
#region IObservable
public void Attach(IObserver observer)
@@ -137,20 +168,5 @@
}
#endregion
-
- public void UpdateObserver()
- {
- DrawSeries();
- view.InvalidatePlot(true);
- }
-
- private void DrawSeries()
- {
- view.Model.Series.Clear();
- foreach (var series in seriesFactory.Create(data))
- {
- view.Model.Series.Add(series);
- }
- }
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs (.../LinearPlotView.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs (.../LinearPlotView.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -7,8 +7,14 @@
namespace Core.Components.OxyPlot.Forms
{
+ ///
+ /// This class describes a plot view with two linear axes.
+ ///
internal sealed class LinearPlotView : PlotView
{
+ ///
+ /// Creates a new instance of .
+ ///
public LinearPlotView()
{
Dock = DockStyle.Fill;
Index: Core/Components/src/Core.Components.OxyPlot/Converter/ChartDataCollectionConverter.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/src/Core.Components.OxyPlot/Converter/ChartDataCollectionConverter.cs (.../ChartDataCollectionConverter.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/ChartDataCollectionConverter.cs (.../ChartDataCollectionConverter.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -1,11 +1,14 @@
using System;
using System.Collections.Generic;
using Core.Components.Charting.Data;
-using Core.Components.OxyPlot.Collection;
using OxyPlot.Series;
namespace Core.Components.OxyPlot.Converter
{
+ ///
+ /// This class converts the in into
+ /// (one or more) .
+ ///
public class ChartDataCollectionConverter : ChartDataConverter
{
protected override Type SupportedType
Index: Core/Components/src/Core.Components.OxyPlot/Converter/PointDataConverter.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/src/Core.Components.OxyPlot/Converter/PointDataConverter.cs (.../PointDataConverter.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/PointDataConverter.cs (.../PointDataConverter.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -7,6 +7,9 @@
namespace Core.Components.OxyPlot.Converter
{
+ ///
+ /// This class converts into with point styling.
+ ///
public class PointDataConverter : ChartDataConverter
{
protected override Type SupportedType
Index: Core/Components/src/Core.Components.OxyPlot/DynamicPlotController.cs
===================================================================
diff -u -r9b19f753c055f426fcea7b6c01cdf43c8d9f2468 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/src/Core.Components.OxyPlot/DynamicPlotController.cs (.../DynamicPlotController.cs) (revision 9b19f753c055f426fcea7b6c01cdf43c8d9f2468)
+++ Core/Components/src/Core.Components.OxyPlot/DynamicPlotController.cs (.../DynamicPlotController.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -2,6 +2,9 @@
namespace Core.Components.OxyPlot
{
+ ///
+ /// This class represents a controller for which certain interactions can be toggled.
+ ///
internal sealed class DynamicPlotController : ControllerBase, IPlotController
{
public bool IsPanningEnabled { get; private set; }
Index: Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj
===================================================================
diff -u -reb44708823d5479991162f63376ae85dd944e513 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj (.../Core.Components.Charting.Test.csproj) (revision eb44708823d5479991162f63376ae85dd944e513)
+++ Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj (.../Core.Components.Charting.Test.csproj) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -47,6 +47,7 @@
+
Index: Core/Components/test/Core.Components.Charting.Test/Data/ChartDataCollectionTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.Charting.Test/Data/ChartDataCollectionTest.cs (revision 0)
+++ Core/Components/test/Core.Components.Charting.Test/Data/ChartDataCollectionTest.cs (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -0,0 +1,35 @@
+using System;
+using System.Linq;
+using Core.Components.Charting.Data;
+using NUnit.Framework;
+
+namespace Core.Components.Charting.Test.Data
+{
+ [TestFixture]
+ public class ChartDataCollectionTest
+ {
+ [Test]
+ public void Constructor_NullList_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new ChartDataCollection(null);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Constructor_ListSet_InstanceWithListSet()
+ {
+ // Setup
+ var list = Enumerable.Empty().ToList();
+
+ // Call
+ var collection = new ChartDataCollection(list);
+
+ // Assert
+ Assert.IsInstanceOf(collection);
+ Assert.AreSame(list, collection.List);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.OxyPlot.Forms.Test/BaseChartTest.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/test/Core.Components.OxyPlot.Forms.Test/BaseChartTest.cs (.../BaseChartTest.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Components/test/Core.Components.OxyPlot.Forms.Test/BaseChartTest.cs (.../BaseChartTest.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -1,13 +1,13 @@
using System;
using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Forms;
using Core.Common.Base;
+using Core.Common.Utils.Reflection;
using Core.Components.Charting.Data;
using Core.Components.Charting.TestUtil;
-using Core.Components.OxyPlot.Collection;
using NUnit.Framework;
+using OxyPlot.WindowsForms;
using Rhino.Mocks;
namespace Core.Components.OxyPlot.Forms.Test
@@ -25,92 +25,196 @@
Assert.IsInstanceOf(chart);
Assert.AreEqual(75, chart.MinimumSize.Height);
Assert.AreEqual(50, chart.MinimumSize.Width);
+ Assert.IsNull(chart.Data);
Assert.IsFalse(chart.IsPanningEnabled);
+ Assert.IsFalse(chart.IsRectangleZoomingEnabled);
}
- /*
+
[Test]
- public void Data_SetToNull_EmptyData()
+ public void Data_NotKnownChartData_ThrowsNotSupportedException()
{
// Setup
var chart = new BaseChart();
- var dataMock = new PointData(new Collection>());
+ var testData = new TestChartData();
- chart.Data = new [] { dataMock };
+ // Call
+ TestDelegate test = () => chart.Data = testData;
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Data_Null_ReturnsNull()
+ {
+ // Setup
+ var chart = new BaseChart();
+
// Call
chart.Data = null;
-
+
// Assert
- Assert.IsEmpty(chart.Data);
+ Assert.IsNull(chart.Data);
}
[Test]
- public void Data_NotNull_DataSet()
+ public void Data_KnownChartData_BaseChartAttachedSeriesDrawn()
{
// Setup
var chart = new BaseChart();
- var pointData = new PointData(new Collection>());
- var lineData = new LineData(new Collection>());
- var areaData = new AreaData(new Collection>());
+ var testData = new LineData(Enumerable.Empty>());
+ var observers = TypeUtils.GetField>(testData, "observers");
+ var view = TypeUtils.GetField(chart, "view");
// Call
- chart.Data = new ChartData[] { pointData, lineData, areaData };
+ chart.Data = testData;
// Assert
- CollectionAssert.AreEqual(new ChartData[] {pointData, lineData, areaData}, chart.Data);
+ CollectionAssert.AreEqual(new []{chart}, observers);
+ Assert.AreEqual(1, view.Model.Series.Count);
}
[Test]
- public void Data_NotKnownChartData_ThrowsNotSupportedException()
+ public void Data_NewDataSet_BaseChartDetachedFromOldAttachedToNewSeriesUpdated()
{
// Setup
var chart = new BaseChart();
- var testData = new TestChartData();
+ var testDataOld = new LineData(Enumerable.Empty>());
+ var testDataNew = new LineData(Enumerable.Empty>());
+ var observersOld = TypeUtils.GetField>(testDataOld, "observers");
+ var observersNew = TypeUtils.GetField>(testDataNew, "observers");
+ var view = TypeUtils.GetField(chart, "view");
// Call
- TestDelegate test = () => chart.Data = new ChartData[] { testData };
+ chart.Data = testDataOld;
+ chart.Data = testDataNew;
// Assert
- Assert.Throws(test);
+ CollectionAssert.IsEmpty(observersOld);
+ CollectionAssert.AreEqual(new[] { chart }, observersNew);
+ Assert.AreEqual(1, view.Model.Series.Count);
}
[Test]
- public void Data_UpdateReturnedValue_DoesNotAlterData()
+ public void Data_DataSetNewValueIsNull_BaseChartDetachedSeriesCleared()
{
+ // Setup
+ var chart = new BaseChart();
+ var testData = new LineData(Enumerable.Empty>());
+ var observers = TypeUtils.GetField>(testData, "observers");
+ var view = TypeUtils.GetField(chart, "view");
+ chart.Data = testData;
+
+ // Precondition
+ Assert.AreEqual(1, view.Model.Series.Count);
+
+ // Call
+ chart.Data = null;
+
+ // Assert
+ CollectionAssert.IsEmpty(observers);
+ CollectionAssert.IsEmpty(view.Model.Series);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void TogglePanning_Always_ChangesState(bool isPanning)
+ {
// Setup
var chart = new BaseChart();
- var pointData = new PointData(new Collection>());
- chart.Data = new ChartData[] { pointData };
+ if (isPanning)
+ {
+ chart.TogglePanning();
+ }
- var data = chart.Data;
+ // Precondition
+ Assert.AreEqual(isPanning, chart.IsPanningEnabled);
// Call
- data.Remove(pointData);
- data.Add(pointData);
+ chart.TogglePanning();
// Assert
- CollectionAssert.AreEqual(new ChartData[] { pointData }, chart.Data);
+ Assert.AreNotEqual(isPanning, chart.IsPanningEnabled);
}
[Test]
- public void Data_SetNewData_NewDataSet()
+ [TestCase(true)]
+ [TestCase(false)]
+ public void ToggleRectangleZooming_Always_ChangesState(bool isRectangleZooming)
{
+ // Setup
+ var chart = new BaseChart();
+ if (isRectangleZooming)
+ {
+ chart.ToggleRectangleZooming();
+ }
+ // Precondition
+ Assert.AreEqual(isRectangleZooming, chart.IsRectangleZoomingEnabled);
+
+ // Call
+ chart.ToggleRectangleZooming();
+
+ // Assert
+ Assert.AreNotEqual(isRectangleZooming, chart.IsRectangleZoomingEnabled);
+ }
+
+ [Test]
+ public void ZoomToAll_ChartInForm_ViewInvalidatedSeriesSame()
+ {
// Setup
+ var form = new Form();
var chart = new BaseChart();
- var pointData = new PointData(new Collection>());
- var otherPointData = new PointData(new Collection>());
- chart.Data = new ChartData[] { pointData };
+ var testData = new LineData(Enumerable.Empty>());
+ var view = TypeUtils.GetField(chart, "view");
+ var invalidated = 0;
+ chart.Data = testData;
+ var series = view.Model.Series.ToList();
+
+ form.Controls.Add(chart);
+ view.Invalidated += (sender, args) => invalidated++;
+
+ form.Show();
+
// Call
- chart.Data = new ChartData[] { otherPointData };
+ chart.ZoomToAll();
// Assert
- CollectionAssert.AreEqual(new ChartData[] { otherPointData }, chart.Data);
- }*/
+ Assert.AreEqual(1, invalidated);
+ CollectionAssert.AreEqual(series, view.Model.Series);
+ }
[Test]
+ public void UpdateObserver_ChartInForm_ViewInvalidatedSeriesUpdated()
+ {
+ // Setup
+ var form = new Form();
+ var chart = new BaseChart();
+ var testData = new LineData(Enumerable.Empty>());
+ var view = TypeUtils.GetField(chart, "view");
+ var invalidated = 0;
+
+ chart.Data = testData;
+ var series = view.Model.Series.ToList();
+
+ form.Controls.Add(chart);
+ view.Invalidated += (sender, args) => invalidated++;
+
+ form.Show();
+
+ // Call
+ chart.UpdateObserver();
+
+ // Assert
+ Assert.AreEqual(1, invalidated);
+ Assert.AreEqual(1, view.Model.Series.Count);
+ Assert.AreNotSame(series[0], view.Model.Series[0]);
+ }
+
+ [Test]
public void NotifyObservers_WithObserverAttached_ObserverIsNotified()
{
// Setup
@@ -184,17 +288,5 @@
mocks.VerifyAll();
}
- private static BaseChart CreateTestBaseChart()
- {
- return new BaseChart
- {
- Data = new ChartDataCollection(new List
- {
- new LineData(new List>()),
- new PointData(new List>()),
- new AreaData(new List>())
- })
- };
- }
}
}
\ No newline at end of file
Index: Core/Components/test/Core.Components.OxyPlot.Forms.Test/Core.Components.OxyPlot.Forms.Test.csproj
===================================================================
diff -u -r9b19f753c055f426fcea7b6c01cdf43c8d9f2468 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/test/Core.Components.OxyPlot.Forms.Test/Core.Components.OxyPlot.Forms.Test.csproj (.../Core.Components.OxyPlot.Forms.Test.csproj) (revision 9b19f753c055f426fcea7b6c01cdf43c8d9f2468)
+++ Core/Components/test/Core.Components.OxyPlot.Forms.Test/Core.Components.OxyPlot.Forms.Test.csproj (.../Core.Components.OxyPlot.Forms.Test.csproj) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -71,6 +71,14 @@
{3bbfd65b-b277-4e50-ae6d-bd24c3434609}
Core.Common.Base
+
+ {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98}
+ Core.Common.Utils
+
+
+ {D749EE4C-CE50-4C17-BF01-9A953028C126}
+ Core.Common.TestUtil
+
{516EBC95-B8F2-428C-B7F6-733F01BF8FDD}
Core.Components.Charting
Index: Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs (.../LinearPlotViewTest.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs (.../LinearPlotViewTest.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -36,7 +36,7 @@
}
[Test]
- public void ZoomToAll_Always_InvalidatesView()
+ public void ZoomToAll_ViewInForm_InvalidatesView()
{
// Setup
var form = new Form();
Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/AreaDataConverterTest.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/test/Core.Components.OxyPlot.Test/Converter/AreaDataConverterTest.cs (.../AreaDataConverterTest.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/AreaDataConverterTest.cs (.../AreaDataConverterTest.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -26,7 +26,7 @@
}
[Test]
- public void CanConvertSeries_PointData_ReturnTrue()
+ public void CanConvertSeries_AreaData_ReturnTrue()
{
// Setup
var converter = new AreaDataConverter();
Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartDataCollectionConverterTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartDataCollectionConverterTest.cs (revision 0)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartDataCollectionConverterTest.cs (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Core.Components.Charting.Data;
+using Core.Components.Charting.TestUtil;
+using Core.Components.OxyPlot.Converter;
+using NUnit.Framework;
+using OxyPlot;
+using OxyPlot.Series;
+
+namespace Core.Components.OxyPlot.Test.Converter
+{
+ [TestFixture]
+ public class ChartDataCollectionConverterTest
+ {
+
+ [Test]
+ public void DefaultConstructor_IsChartDataConverter()
+ {
+ // Call
+ var converter = new ChartDataCollectionConverter();
+
+ // Assert
+ Assert.IsInstanceOf(converter);
+ }
+
+ [Test]
+ public void CanConvertSeries_ChartDataCollection_ReturnTrue()
+ {
+ // Setup
+ var converter = new ChartDataCollectionConverter();
+ var collectionData = new ChartDataCollection(new List());
+
+ // Call & Assert
+ Assert.IsTrue(converter.CanConvertSeries(collectionData));
+ }
+
+ [Test]
+ public void CanConvertSeries_ChartData_ReturnsFalse()
+ {
+ // Setup
+ var converter = new ChartDataCollectionConverter();
+ var chartData = new TestChartData();
+
+ // Call & Assert
+ Assert.IsFalse(converter.CanConvertSeries(chartData));
+ }
+
+ [Test]
+ public void Convert_CollectionOfAreaDataAndLineData_ReturnsTwoNewSeries()
+ {
+ // Setup
+ var converter = new ChartDataCollectionConverter();
+ var random = new Random(21);
+ var randomCount = random.Next(5, 10);
+ var pointsArea = new Collection>();
+ var pointsLine = new Collection>();
+
+ for (int i = 0; i < randomCount; i++)
+ {
+ pointsArea.Add(new Tuple(random.NextDouble(), random.NextDouble()));
+ pointsLine.Add(new Tuple(random.NextDouble(), random.NextDouble()));
+ }
+
+ var collectionData = new ChartDataCollection(new List());
+ var areaData = new AreaData(pointsArea);
+ var lineData = new LineData(pointsLine);
+
+ collectionData.List.Add(areaData);
+ collectionData.List.Add(lineData);
+
+ // Call
+ var series = converter.Convert(collectionData);
+
+ // Assert
+ Assert.IsInstanceOf>(series);
+ Assert.AreEqual(2, series.Count);
+ Assert.IsInstanceOf(series[0]);
+ Assert.IsInstanceOf(series[1]);
+ }
+
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/LineDataConverterTest.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/test/Core.Components.OxyPlot.Test/Converter/LineDataConverterTest.cs (.../LineDataConverterTest.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/LineDataConverterTest.cs (.../LineDataConverterTest.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -23,7 +23,7 @@
}
[Test]
- public void CanConvertSeries_PointData_ReturnTrue()
+ public void CanConvertSeries_LineData_ReturnTrue()
{
// Setup
var converter = new LineDataConverter();
Index: Core/Components/test/Core.Components.OxyPlot.Test/Core.Components.OxyPlot.Test.csproj
===================================================================
diff -u -r9b19f753c055f426fcea7b6c01cdf43c8d9f2468 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Components/test/Core.Components.OxyPlot.Test/Core.Components.OxyPlot.Test.csproj (.../Core.Components.OxyPlot.Test.csproj) (revision 9b19f753c055f426fcea7b6c01cdf43c8d9f2468)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Core.Components.OxyPlot.Test.csproj (.../Core.Components.OxyPlot.Test.csproj) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -51,6 +51,7 @@
+
Index: Core/Plugins/src/Core.Plugins.OxyPlot/Commands/OpenChartViewCommand.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Plugins/src/Core.Plugins.OxyPlot/Commands/OpenChartViewCommand.cs (.../OpenChartViewCommand.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Plugins/src/Core.Plugins.OxyPlot/Commands/OpenChartViewCommand.cs (.../OpenChartViewCommand.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -3,7 +3,6 @@
using System.Collections.ObjectModel;
using Core.Common.Gui;
using Core.Components.Charting.Data;
-using Core.Components.OxyPlot.Collection;
using Core.Plugins.OxyPlot.Forms;
namespace Core.Plugins.OxyPlot.Commands
Index: Core/Plugins/src/Core.Plugins.OxyPlot/Forms/ChartDataView.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Plugins/src/Core.Plugins.OxyPlot/Forms/ChartDataView.cs (.../ChartDataView.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Plugins/src/Core.Plugins.OxyPlot/Forms/ChartDataView.cs (.../ChartDataView.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -1,7 +1,6 @@
-using System.Collections.Generic;
-using System.Windows.Forms;
+using System.Windows.Forms;
+using Core.Components.Charting;
using Core.Components.Charting.Data;
-using Core.Components.OxyPlot.Forms;
namespace Core.Plugins.OxyPlot.Forms
{
@@ -37,7 +36,7 @@
}
}
- public BaseChart Chart
+ public IChart Chart
{
get
{
Index: Core/Plugins/src/Core.Plugins.OxyPlot/Forms/IChartView.cs
===================================================================
diff -u -r570101d9648e296b96c7e624c4d4f6bfad8d41b6 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Plugins/src/Core.Plugins.OxyPlot/Forms/IChartView.cs (.../IChartView.cs) (revision 570101d9648e296b96c7e624c4d4f6bfad8d41b6)
+++ Core/Plugins/src/Core.Plugins.OxyPlot/Forms/IChartView.cs (.../IChartView.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -1,4 +1,5 @@
using Core.Common.Controls.Views;
+using Core.Components.Charting;
using Core.Components.OxyPlot.Forms;
namespace Core.Plugins.OxyPlot.Forms
@@ -11,6 +12,6 @@
///
/// Gets the set for this .
///
- BaseChart Chart { get; }
+ IChart Chart { get; }
}
}
\ No newline at end of file
Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/ChartNodePresenter.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/ChartNodePresenter.cs (.../ChartNodePresenter.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/ChartNodePresenter.cs (.../ChartNodePresenter.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -3,7 +3,6 @@
using Core.Common.Controls.TreeView;
using Core.Common.Gui.Properties;
using Core.Components.Charting.Data;
-using Core.Components.OxyPlot.Collection;
using Core.Components.OxyPlot.Forms;
namespace Core.Plugins.OxyPlot.Legend
Index: Core/Plugins/src/Core.Plugins.OxyPlot/OxyPlotGuiPlugin.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Plugins/src/Core.Plugins.OxyPlot/OxyPlotGuiPlugin.cs (.../OxyPlotGuiPlugin.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Plugins/src/Core.Plugins.OxyPlot/OxyPlotGuiPlugin.cs (.../OxyPlotGuiPlugin.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -4,7 +4,7 @@
using Core.Common.Gui;
using Core.Common.Gui.Forms;
using Core.Common.Gui.Plugin;
-using Core.Components.OxyPlot.Collection;
+using Core.Components.Charting.Data;
using Core.Plugins.OxyPlot.Commands;
using Core.Plugins.OxyPlot.Forms;
using Core.Plugins.OxyPlot.Legend;
Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Forms/ChartDataViewTest.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Forms/ChartDataViewTest.cs (.../ChartDataViewTest.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Forms/ChartDataViewTest.cs (.../ChartDataViewTest.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -1,5 +1,7 @@
using System;
+using System.Linq;
using System.Windows.Forms;
+using Core.Components.Charting.Data;
using Core.Components.OxyPlot.Forms;
using Core.Plugins.OxyPlot.Forms;
using NUnit.Framework;
@@ -36,7 +38,7 @@
chartView.Data = null;
// Assert
-// Assert.IsEmpty(chart.Data);
+ Assert.IsNull(chart.Data);
}
[Test]
@@ -51,5 +53,21 @@
// Assert
Assert.Throws(test);
}
+
+ [Test]
+ public void Data_SetToChartData_ChartDataSet()
+ {
+ // Setup
+ var chartView = new ChartDataView();
+ var chart = (BaseChart)chartView.Controls[0];
+ var lineData = new LineData(Enumerable.Empty>());
+
+ // Call
+ chartView.Data = lineData;
+
+ // Assert
+ Assert.AreSame(lineData, chart.Data);
+ Assert.AreSame(lineData, chartView.Data);
+ }
}
}
\ No newline at end of file
Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartDataNodePresenterTest.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartDataNodePresenterTest.cs (.../ChartDataNodePresenterTest.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartDataNodePresenterTest.cs (.../ChartDataNodePresenterTest.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -5,7 +5,6 @@
using Core.Common.TestUtil;
using Core.Components.Charting.Data;
using Core.Components.Charting.TestUtil;
-using Core.Components.OxyPlot.Collection;
using Core.Components.OxyPlot.Forms;
using Core.Plugins.OxyPlot.Legend;
using Core.Plugins.OxyPlot.Properties;
Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartNodePresenterTest.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartNodePresenterTest.cs (.../ChartNodePresenterTest.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartNodePresenterTest.cs (.../ChartNodePresenterTest.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -7,7 +7,6 @@
using Core.Common.TestUtil;
using Core.Components.Charting.Data;
using Core.Components.Charting.TestUtil;
-using Core.Components.OxyPlot.Collection;
using Core.Components.OxyPlot.Forms;
using Core.Plugins.OxyPlot.Legend;
using NUnit.Framework;
Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendViewTest.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendViewTest.cs (.../LegendViewTest.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendViewTest.cs (.../LegendViewTest.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -3,7 +3,6 @@
using System.Windows.Forms;
using Core.Common.Controls.Views;
using Core.Components.Charting.Data;
-using Core.Components.OxyPlot.Collection;
using Core.Components.OxyPlot.Forms;
using Core.Plugins.OxyPlot.Legend;
using Core.Plugins.OxyPlot.Properties;
Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs
===================================================================
diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs (.../OxyPlotGuiPluginTest.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8)
+++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs (.../OxyPlotGuiPluginTest.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -8,7 +8,6 @@
using Core.Common.Gui.Forms.ViewManager;
using Core.Components.Charting.Data;
using Core.Components.Charting.TestUtil;
-using Core.Components.OxyPlot.Collection;
using Core.Components.OxyPlot.Forms;
using Core.Plugins.OxyPlot.Forms;
using Core.Plugins.OxyPlot.Legend;
Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/TestChartView.cs
===================================================================
diff -u -r9bf140313b222568c57110c9a8a664e2e1a213e1 -r74cd1965818ae9b23da6cad8776b7da2868be4a7
--- Core/Plugins/test/Core.Plugins.OxyPlot.Test/TestChartView.cs (.../TestChartView.cs) (revision 9bf140313b222568c57110c9a8a664e2e1a213e1)
+++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/TestChartView.cs (.../TestChartView.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7)
@@ -1,4 +1,5 @@
using System.Windows.Forms;
+using Core.Components.Charting;
using Core.Components.OxyPlot.Forms;
using Core.Plugins.OxyPlot.Forms;
@@ -11,7 +12,7 @@
{
public object Data { get; set; }
- public BaseChart Chart
+ public IChart Chart
{
get
{