Index: Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsCreateScript.cs =================================================================== diff -u -r1fe151fcfd0dce8fa2c1d93243cae90eee991e70 -r9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a --- Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsCreateScript.cs (.../RingtoetsCreateScript.cs) (revision 1fe151fcfd0dce8fa2c1d93243cae90eee991e70) +++ Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsCreateScript.cs (.../RingtoetsCreateScript.cs) (revision 9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a) @@ -47,10 +47,8 @@ /// public RingtoetsCreateScript(string version, string query) : base(version) { - if (!RingtoetsVersionHelper.IsValidVersion(version)) - { - throw new ArgumentException($@"{version} is not a valid Ringtoets database version.", nameof(version)); - } + RingtoetsVersionHelper.ValidateVersion(version); + if (string.IsNullOrWhiteSpace(query)) { throw new ArgumentException(@"Query must have a value.", nameof(query)); Index: Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsUpgradeScript.cs =================================================================== diff -u -r1fe151fcfd0dce8fa2c1d93243cae90eee991e70 -r9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a --- Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsUpgradeScript.cs (.../RingtoetsUpgradeScript.cs) (revision 1fe151fcfd0dce8fa2c1d93243cae90eee991e70) +++ Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsUpgradeScript.cs (.../RingtoetsUpgradeScript.cs) (revision 9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a) @@ -55,14 +55,8 @@ throw new ArgumentException(@"Query must have a value.", nameof(query)); } - if (!RingtoetsVersionHelper.IsValidVersion(fromVersion)) - { - throw new ArgumentException($@"{fromVersion} is not a valid Ringtoets database version.", nameof(fromVersion)); - } - if (!RingtoetsVersionHelper.IsValidVersion(toVersion)) - { - throw new ArgumentException($@"{toVersion} is not a valid Ringtoets database version.", nameof(toVersion)); - } + RingtoetsVersionHelper.ValidateVersion(fromVersion); + RingtoetsVersionHelper.ValidateVersion(toVersion); upgradeQuery = query; } Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsCreateScriptTest.cs =================================================================== diff -u -r1fe151fcfd0dce8fa2c1d93243cae90eee991e70 -r9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a --- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsCreateScriptTest.cs (.../RingtoetsCreateScriptTest.cs) (revision 1fe151fcfd0dce8fa2c1d93243cae90eee991e70) +++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsCreateScriptTest.cs (.../RingtoetsCreateScriptTest.cs) (revision 9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a) @@ -36,8 +36,7 @@ [Test] [TestCase("")] [TestCase(null)] - [TestCase("4")] - public void Constructor_InvalidVersion_ThrowsArgumentException(string version) + public void Constructor_VersionOrEmpty_ThrowsArgumentException(string version) { // Setup const string query = "Valid query"; @@ -51,6 +50,21 @@ } [Test] + [TestCase("4")] + public void Constructor_InvalidVersion_ThrowsArgumentException(string version) + { + // Setup + const string query = "Valid query"; + + // Call + TestDelegate call = () => new RingtoetsCreateScript(version, query); + + // Assert + string expectedMessage = $@"'{version}' is geen geldige Ringtoets versie."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] [TestCase("")] [TestCase(" ")] [TestCase(null)] Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsUpgradeScriptTest.cs =================================================================== diff -u -r1fe151fcfd0dce8fa2c1d93243cae90eee991e70 -r9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a --- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsUpgradeScriptTest.cs (.../RingtoetsUpgradeScriptTest.cs) (revision 1fe151fcfd0dce8fa2c1d93243cae90eee991e70) +++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsUpgradeScriptTest.cs (.../RingtoetsUpgradeScriptTest.cs) (revision 9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a) @@ -36,8 +36,7 @@ [Test] [TestCase("")] [TestCase(null)] - [TestCase("4")] - public void Constructor_InvalidFromVersion_ThrowsArgumentException(string fromVersion) + public void Constructor_FromVersionOrEmpty_ThrowsArgumentException(string fromVersion) { // Setup const string query = "Valid query"; @@ -54,8 +53,7 @@ [Test] [TestCase("")] [TestCase(null)] - [TestCase("4")] - public void Constructor_InvalidToVersion_ThrowsArgumentException(string toVersion) + public void Constructor_ToVersionOrEmpty_ThrowsArgumentException(string toVersion) { // Setup string fromVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion(); @@ -70,6 +68,38 @@ } [Test] + [TestCase("4")] + public void Constructor_InvalidFromVersion_ThrowsArgumentException(string fromVersion) + { + // Setup + const string query = "Valid query"; + string toVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion(); + + // Call + TestDelegate call = () => new RingtoetsUpgradeScript(fromVersion, toVersion, query); + + // Assert + string expectedMessage = $@"'{fromVersion}' is geen geldige Ringtoets versie."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + [TestCase("4")] + public void Constructor_InvalidToVersion_ThrowsArgumentException(string toVersion) + { + // Setup + string fromVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion(); + const string query = "Valid query"; + + // Call + TestDelegate call = () => new RingtoetsUpgradeScript(fromVersion, toVersion, query); + + // Assert + string expectedMessage = $@"'{toVersion}' is geen geldige Ringtoets versie."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] [TestCase("")] [TestCase(" ")] [TestCase(null)] @@ -144,7 +174,7 @@ // Assert Assert.IsTrue(File.Exists(filePath)); - using (new FileDisposeHelper(filePath)) { } + using (new FileDisposeHelper(filePath)) {} } } } \ No newline at end of file Index: Migration/Console/src/Migration.Console/ConsoleHelper.cs =================================================================== diff -u -r1fe151fcfd0dce8fa2c1d93243cae90eee991e70 -r9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a --- Migration/Console/src/Migration.Console/ConsoleHelper.cs (.../ConsoleHelper.cs) (revision 1fe151fcfd0dce8fa2c1d93243cae90eee991e70) +++ Migration/Console/src/Migration.Console/ConsoleHelper.cs (.../ConsoleHelper.cs) (revision 9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a) @@ -82,17 +82,16 @@ { throw new ArgumentNullException(nameof(args)); } - var windowWidth = GetWindowWidth() - paddingRight; - int bufferSize = windowWidth - paddingLeft; + int bufferSize = GetLineWidth() - paddingRight - paddingLeft; var paddingString = new string(' ', paddingLeft); foreach (var line in format.SplitByLength(bufferSize)) { SystemConsole.WriteLine($@"{paddingString}{line.TrimStart()}", args); } } - private static int GetWindowWidth() + private static int GetLineWidth() { try { Index: Ringtoets/Common/src/Ringtoets.Common.Utils/Properties/Resources.Designer.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Utils/Properties/Resources.Designer.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Utils/Properties/Resources.Designer.cs (revision 9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a) @@ -0,0 +1,93 @@ +// 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. + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Ringtoets.Common.Utils.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Ringtoets.Common.Utils.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to '{0}' is geen geldige Ringtoets versie.. + /// + internal static string RingtoetsVersionHelper_Version_0_Not_Valid { + get { + return ResourceManager.GetString("RingtoetsVersionHelper_Version_0_Not_Valid", resourceCulture); + } + } + } +} Index: Ringtoets/Common/src/Ringtoets.Common.Utils/Properties/Resources.resx =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Utils/Properties/Resources.resx (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Utils/Properties/Resources.resx (revision 9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a) @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + '{0}' is geen geldige Ringtoets versie. + + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Utils/Ringtoets.Common.Utils.csproj =================================================================== diff -u -r24fff72c73f0e43ad9f9fcf3a616ab0f8f96e077 -r9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a --- Ringtoets/Common/src/Ringtoets.Common.Utils/Ringtoets.Common.Utils.csproj (.../Ringtoets.Common.Utils.csproj) (revision 24fff72c73f0e43ad9f9fcf3a616ab0f8f96e077) +++ Ringtoets/Common/src/Ringtoets.Common.Utils/Ringtoets.Common.Utils.csproj (.../Ringtoets.Common.Utils.csproj) (revision 9487e717f5c13a44bdf7bc60cfa7fccb9a3fd84a) @@ -41,6 +41,11 @@ + + True + True + Resources.resx + @@ -66,6 +71,12 @@ False + + + ResXFileCodeGenerator + Resources.Designer.cs + +