// Copyright (C) Stichting Deltares 2017. 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 System.Drawing; using Core.Common.Base.Geometry; using Core.Common.TestUtil; using Core.Components.Chart.Data; using Core.Components.Chart.Styles; using NUnit.Framework; namespace Core.Components.Chart.Test.Data { [TestFixture] public class ChartMultipleLineDataTest { [Test] public void Constructor_ExpectedValues() { // Call var data = new ChartMultipleLineData("test data"); // Assert Assert.IsInstanceOf(data); CollectionAssert.IsEmpty(data.Lines); Assert.AreEqual(Color.Black, data.Style.Color); Assert.AreEqual(2, data.Style.Width); Assert.AreEqual(ChartLineDashStyle.Solid, data.Style.DashStyle); Assert.AreEqual(false, data.Style.IsEditable); } [Test] public void Constructor_Always_CreatesNewInstanceOfDefaultStyle() { // Setup var dataA = new ChartMultipleLineData("test data"); // Call var dataB = new ChartMultipleLineData("test data"); // Assert Assert.AreNotSame(dataA.Style, dataB.Style); } [Test] public void Constructor_StyleNull_ThrowArgumentNullException() { // Call TestDelegate test = () => new ChartLineData("test data", null); // Assert var exception = Assert.Throws(test); Assert.AreEqual("style", exception.ParamName); } [Test] public void Constructor_WithStyle_ExpectedValue() { // Setup var style = new ChartLineStyle { Color = Color.Red, Width = 3, DashStyle = ChartLineDashStyle.DashDot, IsEditable = true }; // Call var data = new ChartMultipleLineData("test data", style); // Assert Assert.AreEqual("test data", data.Name); CollectionAssert.IsEmpty(data.Lines); Assert.IsInstanceOf(data); Assert.AreSame(style, data.Style); } [Test] public void Lines_SetValidNewValue_GetsNewValue() { // Setup var data = new ChartMultipleLineData("test data"); var lines = new List(); // Call data.Lines = lines; // Assert Assert.AreSame(lines, data.Lines); } [Test] public void Lines_SetNullValue_ThrowsArgumentNullException() { // Setup var data = new ChartMultipleLineData("test data"); // Call TestDelegate test = () => data.Lines = null; // Assert const string expectedMessage = "The collection of point arrays cannot be null."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } [Test] public void Lines_SetValueContainingNullValue_ThrowsArgumentException() { // Setup var data = new ChartMultipleLineData("test data"); // Call TestDelegate test = () => data.Lines = new List { null }; // Assert const string expectedMessage = "The collection of point arrays cannot contain null values."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } } }