Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj
===================================================================
diff -u -r3f73936da98ec936963df7f4487cb152371a40f5 -r46f8b6e121fc12d964c219c7726187db68d30892
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 3f73936da98ec936963df7f4487cb152371a40f5)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 46f8b6e121fc12d964c219c7726187db68d30892)
@@ -158,6 +158,8 @@
WmtsLocationControl.cs
+
+
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WmtsLocationControl.cs
===================================================================
diff -u -rddc82da5467d427483d90dcb6ef6809fda68462a -r46f8b6e121fc12d964c219c7726187db68d30892
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision ddc82da5467d427483d90dcb6ef6809fda68462a)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision 46f8b6e121fc12d964c219c7726187db68d30892)
@@ -23,7 +23,6 @@
using System.Linq;
using System.Windows.Forms;
using Core.Common.Controls.Views;
-using Core.Common.Utils.Reflection;
namespace Ringtoets.Integration.Forms.Views
{
@@ -70,14 +69,10 @@
dataGridViewControl.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewControl.MultiSelect = false;
- dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Id),
- "Kaartlaag", true);
- dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Format),
- "Formaat", true);
- dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Title),
- "Titel", true);
- dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.CoordinateSystem),
- "Coördinatenstelsel", true);
+ dataGridViewControl.AddTextBoxColumn(nameof(WmtsCapabilityRow.Id), "Kaartlaag", true);
+ dataGridViewControl.AddTextBoxColumn(nameof(WmtsCapabilityRow.Format), "Formaat", true);
+ dataGridViewControl.AddTextBoxColumn(nameof(WmtsCapabilityRow.Title), "Titel", true);
+ dataGridViewControl.AddTextBoxColumn(nameof(WmtsCapabilityRow.CoordinateSystem), "Coördinatenstelsel", true);
}
private void UpdateDataGridViewDataSource()
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/WmtsConnectionInfo.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/WmtsConnectionInfo.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/WmtsConnectionInfo.cs (revision 46f8b6e121fc12d964c219c7726187db68d30892)
@@ -0,0 +1,64 @@
+// 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 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 General Public License for more details.
+//
+// You should have received a copy of the GNU 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;
+
+namespace Ringtoets.Integration.Forms
+{
+ ///
+ /// This class defines properties for a WMTS connection.
+ ///
+ public class WmtsConnectionInfo
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The name associated with the .
+ /// The WMTS URL.
+ /// Thrown when is null.
+ /// Thrown when is null,
+ /// , or consists exclusively of white-space characters.
+ public WmtsConnectionInfo(string name, string url)
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+ if (string.IsNullOrWhiteSpace(url))
+ {
+ throw new ArgumentException($@"{nameof(url)} must have a value.", nameof(url));
+ }
+
+ Name = name;
+ Url = url;
+ }
+
+ ///
+ /// Gets the name associated with the URL.
+ ///
+ public string Name { get; }
+
+ ///
+ /// Gets the URL.
+ ///
+ public string Url { get; }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/WmtsConnectionInfoWriter.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/WmtsConnectionInfoWriter.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/WmtsConnectionInfoWriter.cs (revision 46f8b6e121fc12d964c219c7726187db68d30892)
@@ -0,0 +1,66 @@
+// 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 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 General Public License for more details.
+//
+// You should have received a copy of the GNU 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.IO.Exceptions;
+using Core.Common.Utils;
+using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources;
+
+namespace Ringtoets.Integration.Forms
+{
+ ///
+ /// Writer class for .
+ ///
+ public class WmtsConnectionInfoWriter
+ {
+ private readonly string filePath;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// Path to write to.
+ /// Thrown when is invalid.
+ /// A valid path:
+ ///
+ /// - is not empty or null,
+ /// - does not consist out of only whitespace characters,
+ /// - does not contain an invalid character,
+ /// - does not end with a directory or path separator (empty file name).
+ ///
+ public WmtsConnectionInfoWriter(string filePath)
+ {
+ IOUtils.ValidateFilePath(filePath);
+ this.filePath = filePath;
+ }
+
+ ///
+ /// Writes the to .
+ ///
+ /// The objects to write.
+ /// Thrown when writing
+ /// to failed.
+ public void WriteWmtsConnectionInfo(IEnumerable wmtsConnectionInfos)
+ {
+ throw new CriticalFileWriteException(string.Format(CoreCommonUtilsResources.Error_General_output_error_0, filePath));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj
===================================================================
diff -u -r3f73936da98ec936963df7f4487cb152371a40f5 -r46f8b6e121fc12d964c219c7726187db68d30892
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 3f73936da98ec936963df7f4487cb152371a40f5)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 46f8b6e121fc12d964c219c7726187db68d30892)
@@ -119,6 +119,8 @@
+
+
@@ -133,6 +135,10 @@
{30e4c2ae-719e-4d70-9fa9-668a9767fbfa}
Core.Common.Gui
+
+ {E344867E-9AC9-44C8-88A5-8185681679A9}
+ Core.Common.IO
+
{F49BD8B2-332A-4C91-A196-8CCE0A2C7D98}
Core.Common.Utils
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WmtsLocationControlTest.cs
===================================================================
diff -u -rfe44c186ea146cf8a1debc6a44286011c8e8d2d0 -r46f8b6e121fc12d964c219c7726187db68d30892
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WmtsLocationControlTest.cs (.../WmtsLocationControlTest.cs) (revision fe44c186ea146cf8a1debc6a44286011c8e8d2d0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WmtsLocationControlTest.cs (.../WmtsLocationControlTest.cs) (revision 46f8b6e121fc12d964c219c7726187db68d30892)
@@ -118,6 +118,22 @@
}
[Test]
+ public void Dispose_AlreadyDisposed_DoesNotThrowException()
+ {
+ // Call
+ TestDelegate call = () =>
+ {
+ using (var control = new WmtsLocationControl())
+ {
+ control.Dispose();
+ }
+ };
+
+ // Assert
+ Assert.DoesNotThrow(call);
+ }
+
+ [Test]
public void Data_WmtsCapabilityRow_DataSet()
{
// Setup
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/WmtsConnectionInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/WmtsConnectionInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/WmtsConnectionInfoTest.cs (revision 46f8b6e121fc12d964c219c7726187db68d30892)
@@ -0,0 +1,67 @@
+// 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 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 General Public License for more details.
+//
+// You should have received a copy of the GNU 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 Core.Common.TestUtil;
+using NUnit.Framework;
+
+namespace Ringtoets.Integration.Forms.Test
+{
+ [TestFixture]
+ public class WmtsConnectionInfoTest
+ {
+ [Test]
+ public void Constructor_NameNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => new WmtsConnectionInfo(null, "url");
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("name", paramName);
+ }
+
+ [Test]
+ public void Constructor_UrlNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => new WmtsConnectionInfo("name", null);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "url must have a value.");
+ }
+
+ [Test]
+ public void Constructor_ValidParameters_ExpectedProperties()
+ {
+ // Setup
+ const string name = "name";
+ const string url = "url";
+
+ // Call
+ var connectionInfo = new WmtsConnectionInfo(name, url);
+
+ // Assert
+ Assert.AreEqual(name, connectionInfo.Name);
+ Assert.AreEqual(url, connectionInfo.Url);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/WmtsConnectionInfoWriterTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/WmtsConnectionInfoWriterTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/WmtsConnectionInfoWriterTest.cs (revision 46f8b6e121fc12d964c219c7726187db68d30892)
@@ -0,0 +1,110 @@
+// 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 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 General Public License for more details.
+//
+// You should have received a copy of the GNU 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.IO;
+using System.Linq;
+using System.Security.AccessControl;
+using Core.Common.IO.Exceptions;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+
+namespace Ringtoets.Integration.Forms.Test
+{
+ [TestFixture]
+ public class WmtsConnectionInfoWriterTest
+ {
+ private static readonly string testPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Forms);
+
+ [Test]
+ [TestCase("")]
+ [TestCase(" ")]
+ [TestCase(null)]
+ public void Constructor_NoFilePath_ThrowArgumentException(string filePath)
+ {
+ // Call
+ TestDelegate call = () => new WmtsConnectionInfoWriter(filePath);
+
+ // Assert
+ const string expectedMessage = "bestandspad mag niet leeg of ongedefinieerd zijn.";
+ string message = Assert.Throws(call).Message;
+ StringAssert.Contains(expectedMessage, message);
+ }
+
+ [Test]
+ public void Constructor_FilePathIsDirectory_ThrowArgumentException()
+ {
+ // Call
+ TestDelegate call = () => new WmtsConnectionInfoWriter("c:/");
+
+ // Assert
+ const string expectedMessage = "bestandspad mag niet verwijzen naar een lege bestandsnaam.";
+ string message = Assert.Throws(call).Message;
+ StringAssert.Contains(expectedMessage, message);
+ }
+
+ [Test]
+ public void Constructor_FilePathHasInvalidPathCharacter_ThrowArgumentException()
+ {
+ // Setup
+ char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
+ string invalidCharacter = invalidFileNameChars[0].ToString();
+ var filePath = "c:/_.config".Replace("_", invalidCharacter);
+
+ // Call
+ TestDelegate call = () => new WmtsConnectionInfoWriter(filePath);
+
+ // Assert
+ const string expectedMessage = "Fout bij het lezen van bestand 'c:/\".config': bestandspad " +
+ "mag niet de volgende tekens bevatten: \", <, >, " +
+ "|, \0, , , , , , , \a, \b, \t, \n, \v, \f, \r, " +
+ ", , , , , , , , , , , , , , , , , , :, *, ?, \\, /";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ }
+
+ [Test]
+ public void WriteWmtsConfiguration_InvalidDirectoryRights_ThrowCriticalFileWriteException()
+ {
+ string directoryPath = Path.Combine(testPath, nameof(WmtsConnectionInfoWriterTest) + "_InvalidDirectoryRights");
+ Directory.CreateDirectory(directoryPath);
+ string filePath = Path.Combine(directoryPath, Path.GetRandomFileName());
+ var wmtsConfigurationWriter = new WmtsConnectionInfoWriter(filePath);
+
+ try
+ {
+ using (new DirectoryPermissionsRevoker(directoryPath, FileSystemRights.Write))
+ {
+ // Call
+ TestDelegate call = () => wmtsConfigurationWriter.WriteWmtsConnectionInfo(Enumerable.Empty());
+
+ // Assert
+ string message = Assert.Throws(call).Message;
+ var expectedMessage = $"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.";
+ Assert.AreEqual(expectedMessage, message);
+ }
+ }
+ finally
+ {
+ Directory.Delete(directoryPath, true);
+ }
+ }
+ }
+}
\ No newline at end of file