// Copyright (C) Stichting Deltares 2016. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using System.Collections.Generic;
using Core.Common.TestUtil;
using Core.Components.Charting.Data;
using Core.Components.Charting.TestUtil;
using Core.Components.OxyPlot.Converter;
using NUnit.Framework;
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("test data");
// Call
var canConvert = converter.CanConvertSeries(collectionData);
// Assert
Assert.IsTrue(canConvert);
}
[Test]
public void CanConvertSeries_ChartData_ReturnsFalse()
{
// Setup
var converter = new ChartDataCollectionConverter();
var chartData = new TestChartData();
// Call
var canConvert = converter.CanConvertSeries(chartData);
// Assert
Assert.IsFalse(canConvert);
}
[Test]
public void Convert_CollectionOfAreaDataAndLineData_ReturnsTwoNewSeries()
{
// Setup
var converter = new ChartDataCollectionConverter();
var collectionData = new ChartDataCollection("test data");
var areaData = new ChartAreaData("test data");
var lineData = new ChartLineData("test data");
collectionData.Add(areaData);
collectionData.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]);
}
[Test]
public void Convert_DataNull_ThrowsArgumentNullException()
{
// Setup
var testConverter = new ChartDataCollectionConverter();
// Call
TestDelegate test = () => testConverter.Convert(null);
// Assert
Assert.Throws(test);
}
[Test]
public void Convert_DataCannotBeConverted_ThrowsArgumentException()
{
// Setup
var testConverter = new ChartDataCollectionConverter();
var testChartData = new TestChartData();
var expectedMessage = string.Format("The data of type {0} cannot be converted by this converter.", testChartData.GetType());
// Precondition
Assert.IsFalse(testConverter.CanConvertSeries(testChartData));
// Call
TestDelegate test = () => testConverter.Convert(testChartData);
// Assert
TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
}
}
}