Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -r604d0e202fa546642f20240c80aac5d98447e4fc -r825be662d2c1a10b0156cf47ddbfde4e9ab9ee49
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 604d0e202fa546642f20240c80aac5d98447e4fc)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 825be662d2c1a10b0156cf47ddbfde4e9ab9ee49)
@@ -678,5 +678,41 @@
return ResourceManager.GetString("WaveHeightLocationsContext_DisplayName", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Coördinatenstelsel.
+ ///
+ public static string WmtsCapability_MapLayer_CoordinateSystem {
+ get {
+ return ResourceManager.GetString("WmtsCapability_MapLayer_CoordinateSystem", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Formaat.
+ ///
+ public static string WmtsCapability_MapLayer_Format {
+ get {
+ return ResourceManager.GetString("WmtsCapability_MapLayer_Format", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Kaartlaag.
+ ///
+ public static string WmtsCapability_MapLayer_Id {
+ get {
+ return ResourceManager.GetString("WmtsCapability_MapLayer_Id", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Titel.
+ ///
+ public static string WmtsCapability_MapLayer_Title {
+ get {
+ return ResourceManager.GetString("WmtsCapability_MapLayer_Title", resourceCulture);
+ }
+ }
}
}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx
===================================================================
diff -u -r604d0e202fa546642f20240c80aac5d98447e4fc -r825be662d2c1a10b0156cf47ddbfde4e9ab9ee49
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 604d0e202fa546642f20240c80aac5d98447e4fc)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 825be662d2c1a10b0156cf47ddbfde4e9ab9ee49)
@@ -315,4 +315,16 @@
URL
+
+ Kaartlaag
+
+
+ Formaat
+
+
+ Titel
+
+
+ Coördinatenstelsel
+
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj
===================================================================
diff -u -r46f8b6e121fc12d964c219c7726187db68d30892 -r825be662d2c1a10b0156cf47ddbfde4e9ab9ee49
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 46f8b6e121fc12d964c219c7726187db68d30892)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 825be662d2c1a10b0156cf47ddbfde4e9ab9ee49)
@@ -40,6 +40,7 @@
+
@@ -160,6 +161,7 @@
+
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WmtsLocationControl.cs
===================================================================
diff -u -r46f8b6e121fc12d964c219c7726187db68d30892 -r825be662d2c1a10b0156cf47ddbfde4e9ab9ee49
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision 46f8b6e121fc12d964c219c7726187db68d30892)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision 825be662d2c1a10b0156cf47ddbfde4e9ab9ee49)
@@ -23,6 +23,7 @@
using System.Linq;
using System.Windows.Forms;
using Core.Common.Controls.Views;
+using Ringtoets.Integration.Forms.Properties;
namespace Ringtoets.Integration.Forms.Views
{
@@ -69,10 +70,14 @@
dataGridViewControl.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewControl.MultiSelect = false;
- 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);
+ dataGridViewControl.AddTextBoxColumn(nameof(WmtsCapabilityRow.Id), Resources.WmtsCapability_MapLayer_Id,
+ true);
+ dataGridViewControl.AddTextBoxColumn(nameof(WmtsCapabilityRow.Format), Resources.WmtsCapability_MapLayer_Format,
+ true);
+ dataGridViewControl.AddTextBoxColumn(nameof(WmtsCapabilityRow.Title), Resources.WmtsCapability_MapLayer_Title,
+ true);
+ dataGridViewControl.AddTextBoxColumn(nameof(WmtsCapabilityRow.CoordinateSystem), Resources.WmtsCapability_MapLayer_CoordinateSystem,
+ true);
}
private void UpdateDataGridViewDataSource()
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/WmtsConnectionInfoWriter.cs
===================================================================
diff -u -r46f8b6e121fc12d964c219c7726187db68d30892 -r825be662d2c1a10b0156cf47ddbfde4e9ab9ee49
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/WmtsConnectionInfoWriter.cs (.../WmtsConnectionInfoWriter.cs) (revision 46f8b6e121fc12d964c219c7726187db68d30892)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/WmtsConnectionInfoWriter.cs (.../WmtsConnectionInfoWriter.cs) (revision 825be662d2c1a10b0156cf47ddbfde4e9ab9ee49)
@@ -21,8 +21,10 @@
using System;
using System.Collections.Generic;
+using System.Xml;
using Core.Common.IO.Exceptions;
using Core.Common.Utils;
+using Core.Common.Utils.Extensions;
using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources;
namespace Ringtoets.Integration.Forms
@@ -56,11 +58,53 @@
/// Writes the to .
///
/// The objects to write.
+ /// Thrown when is null.
/// Thrown when writing
/// to failed.
public void WriteWmtsConnectionInfo(IEnumerable wmtsConnectionInfos)
{
- throw new CriticalFileWriteException(string.Format(CoreCommonUtilsResources.Error_General_output_error_0, filePath));
+ if (wmtsConnectionInfos == null)
+ {
+ throw new ArgumentNullException(nameof(wmtsConnectionInfos));
+ }
+ try
+ {
+ WriteWmtsConnectionInfosToXml(wmtsConnectionInfos);
+ }
+ catch (Exception exception)
+ {
+ throw new CriticalFileWriteException(string.Format(CoreCommonUtilsResources.Error_General_output_error_0, filePath), exception);
+ }
}
+
+ private void WriteWmtsConnectionInfosToXml(IEnumerable wmtsConnectionInfos)
+ {
+ using (XmlWriter writer = XmlWriter.Create(filePath))
+ {
+ writer.WriteStartDocument();
+ writer.WriteStartElement(WmtsConnectionInfoXmlDefinitions.RootElement);
+
+ foreach (WmtsConnectionInfo wmtsConnectionInfo in wmtsConnectionInfos)
+ {
+ WriteWmtsConnectionInfoToXml(writer, wmtsConnectionInfo);
+ }
+
+ writer.WriteEndElement();
+ writer.WriteEndDocument();
+
+ writer.Flush();
+ writer.Close();
+ }
+ }
+
+ private static void WriteWmtsConnectionInfoToXml(XmlWriter writer, WmtsConnectionInfo wmtsConnectionInfo)
+ {
+ writer.WriteStartElement(WmtsConnectionInfoXmlDefinitions.WmtsConnectionElement);
+
+ writer.WriteElementString(WmtsConnectionInfoXmlDefinitions.WmtsConnectionNameElement, wmtsConnectionInfo.Name);
+ writer.WriteElementString(WmtsConnectionInfoXmlDefinitions.WmtsConnectionUrlElement, wmtsConnectionInfo.Url);
+
+ writer.WriteEndElement();
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/WmtsConnectionInfoXmlDefinitions.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/WmtsConnectionInfoXmlDefinitions.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/WmtsConnectionInfoXmlDefinitions.cs (revision 825be662d2c1a10b0156cf47ddbfde4e9ab9ee49)
@@ -0,0 +1,49 @@
+// 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.
+
+namespace Ringtoets.Integration.Forms
+{
+ ///
+ /// Defines the element names of the WMTS connection configuration file.
+ ///
+ public static class WmtsConnectionInfoXmlDefinitions
+ {
+ ///
+ /// Gets the name of the root element.
+ ///
+ public const string RootElement = "WmtsConnections";
+
+ ///
+ /// Gets the WMTS connection element.
+ ///
+ public const string WmtsConnectionElement = "WmtsConnection";
+
+ ///
+ /// Gets the WMTS connection name element.
+ ///
+ public const string WmtsConnectionNameElement = "Name";
+
+ ///
+ /// Gets the WMTS connection URL element.
+ ///
+ public const string WmtsConnectionUrlElement = "URL";
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj
===================================================================
diff -u -r46f8b6e121fc12d964c219c7726187db68d30892 -r825be662d2c1a10b0156cf47ddbfde4e9ab9ee49
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 46f8b6e121fc12d964c219c7726187db68d30892)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 825be662d2c1a10b0156cf47ddbfde4e9ab9ee49)
@@ -59,6 +59,7 @@
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/WmtsConnectionInfoWriterTest.cs
===================================================================
diff -u -r46f8b6e121fc12d964c219c7726187db68d30892 -r825be662d2c1a10b0156cf47ddbfde4e9ab9ee49
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/WmtsConnectionInfoWriterTest.cs (.../WmtsConnectionInfoWriterTest.cs) (revision 46f8b6e121fc12d964c219c7726187db68d30892)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/WmtsConnectionInfoWriterTest.cs (.../WmtsConnectionInfoWriterTest.cs) (revision 825be662d2c1a10b0156cf47ddbfde4e9ab9ee49)
@@ -20,9 +20,11 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.AccessControl;
+using System.Xml;
using Core.Common.IO.Exceptions;
using Core.Common.TestUtil;
using NUnit.Framework;
@@ -32,7 +34,7 @@
[TestFixture]
public class WmtsConnectionInfoWriterTest
{
- private static readonly string testPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Forms);
+ private static readonly string testPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Forms, "WmtsConnectionInfo");
[Test]
[TestCase("")]
@@ -81,9 +83,10 @@
}
[Test]
- public void WriteWmtsConfiguration_InvalidDirectoryRights_ThrowCriticalFileWriteException()
+ public void WriteWmtsConnectionInfo_InvalidDirectoryRights_ThrowCriticalFileWriteException()
{
- string directoryPath = Path.Combine(testPath, nameof(WmtsConnectionInfoWriterTest) + "_InvalidDirectoryRights");
+ // Setup
+ string directoryPath = Path.Combine(testPath, "InvalidDirectoryRights");
Directory.CreateDirectory(directoryPath);
string filePath = Path.Combine(directoryPath, Path.GetRandomFileName());
var wmtsConfigurationWriter = new WmtsConnectionInfoWriter(filePath);
@@ -106,5 +109,56 @@
Directory.Delete(directoryPath, true);
}
}
+
+ [Test]
+ public void WriteWmtsConnectionInfo_WmtsConnectionInfosNull_ThrowArgumentNullException()
+ {
+ // Setup
+ string filePath = Path.Combine(testPath, Path.GetRandomFileName());
+ var wmtsConfigurationWriter = new WmtsConnectionInfoWriter(filePath);
+
+ // Call
+ TestDelegate call = () => wmtsConfigurationWriter.WriteWmtsConnectionInfo(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("wmtsConnectionInfos", paramName);
+ }
+
+ [Test]
+ public void WriteWmtsConnectionInfo_ValidWmtsConnectionInfo_SavesWmtsConnectionInfoToFile()
+ {
+ // Setup
+ string filePath = Path.Combine(testPath, Path.GetRandomFileName());
+ var wmtsConfigurationWriter = new WmtsConnectionInfoWriter(filePath);
+
+ var wmtsConnectionInfos = new []
+ {
+ new WmtsConnectionInfo("name1", "url1"),
+ new WmtsConnectionInfo("name2", "url2")
+ };
+
+ using (new FileDisposeHelper(filePath))
+ {
+ // Call
+ wmtsConfigurationWriter.WriteWmtsConnectionInfo(wmtsConnectionInfos);
+
+ // Assert
+ string actualContent = GetFileContent(filePath);
+ string expectedContent = "" +
+ "name1url1" +
+ "name2url2" +
+ "";
+ Assert.AreEqual(expectedContent, actualContent);
+ }
+ }
+
+ private static string GetFileContent(string filePath)
+ {
+ using (var reader = new StreamReader(filePath))
+ {
+ return reader.ReadToEnd();
+ }
+ }
}
}
\ No newline at end of file