// 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.Linq;
using System.Windows.Forms;
using Core.Common.Base.Geometry;
using Core.Components.DotSpatial.MapFunctions;
using Core.Components.Gis.Data;
using Core.Components.Gis.Features;
using Core.Components.Gis.Forms;
using Core.Components.Gis.Geometries;
using DotSpatial.Controls;
using DotSpatial.Data;
using NUnit.Extensions.Forms;
using NUnit.Framework;
namespace Core.Components.DotSpatial.Forms.Test
{
[TestFixture]
public class MapControlTest
{
private const double padding = 0.05;
[Test]
public void DefaultConstructor_DefaultValues()
{
// Call
using (var map = new MapControl())
{
// Assert
Assert.IsInstanceOf(map);
Assert.IsInstanceOf(map);
Assert.IsInstanceOf(map.Data);
Assert.IsNotNull(map.Data);
CollectionAssert.IsEmpty(map.Data.Collection);
Assert.IsTrue(map.IsPanningEnabled);
Assert.IsFalse(map.IsRectangleZoomingEnabled);
Assert.IsTrue(map.IsMouseCoordinatesVisible);
}
}
[Test]
[RequiresSTA]
public void DefaultConstructor_MapFunctionsCorrectlyInitialized()
{
using (var form = new Form())
{
// Call
var mapControl = new MapControl();
form.Controls.Add(mapControl);
form.Show();
var map = (Map) new ControlTester("Map").TheObject;
// Assert
Assert.AreEqual(9, map.MapFunctions.Count);
Assert.AreEqual(1, map.MapFunctions.OfType().Count());
Assert.AreEqual(1, map.MapFunctions.OfType().Count());
}
}
[Test]
public void Data_NotNull_ReturnsData()
{
// Setup
using (var map = new MapControl())
{
var testData = new MapPointData("test data");
// Call
map.Data.Add(testData);
// Assert
Assert.AreSame(testData, map.Data.Collection.First());
}
}
[Test]
public void UpdateObserver_UpdateData_UpdateMap()
{
// Setup
using (var map = new MapControl())
{
var mapView = map.Controls.OfType