Index: Migration/Console/src/Migration.Console/Application.cs
===================================================================
diff -u -r535a93fde55619f58673f758edae5dc7c1b9df51 -r2b087ce4a7c30f4fcf8ca1ed99af874c42c8ef19
--- Migration/Console/src/Migration.Console/Application.cs (.../Application.cs) (revision 535a93fde55619f58673f758edae5dc7c1b9df51)
+++ Migration/Console/src/Migration.Console/Application.cs (.../Application.cs) (revision 2b087ce4a7c30f4fcf8ca1ed99af874c42c8ef19)
@@ -19,10 +19,102 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System.Linq;
+using Migration.Console.Properties;
+using SystemConsole = System.Console;
+
namespace Migration.Console
{
public class Application
{
- static void Main(string[] args) {}
+ private const string commandMigrate = "--migrate";
+ private const string commandVersionSupported = "--supported";
+ private const string commandHelp = "--help";
+
+ static void Main(string[] args)
+ {
+ string command = args.FirstOrDefault() ?? commandHelp;
+ switch (command)
+ {
+ case commandMigrate:
+ MigrateCommand(args);
+ break;
+ case commandVersionSupported:
+ IsVersionSupportedCommand(args);
+ break;
+ case commandHelp:
+ DisplayAllCommands();
+ break;
+ default:
+ {
+ InvalidCommand(command);
+ DisplayAllCommands();
+ break;
+ }
+ }
+ }
+
+ private static void DisplayAllCommands()
+ {
+ ConsoleHelper.WriteInfoLine(commandHelp
+ + "\t"
+ + Resources.CommandHelp_Command_0_Detailed, commandHelp);
+ ShowMigrateCommand();
+ ShowSupportedCommand();
+ }
+
+ #region Invalid Command
+
+ private static void InvalidCommand(string command)
+ {
+ ConsoleHelper.WriteErrorLine(Resources.CommandInvalid_Command_0_Is_not_valid, command);
+ SystemConsole.WriteLine("");
+ }
+
+ #endregion
+
+ #region Version Supported Command
+
+ private static void IsVersionSupportedCommand(string[] args)
+ {
+ if (args.Length != 2)
+ {
+ ConsoleHelper.WriteErrorLine(Resources.Command_0_Incorrect_number_of_parameters, commandVersionSupported);
+ SystemConsole.WriteLine("");
+ ShowSupportedCommand();
+ return;
+ }
+ }
+
+ private static void ShowSupportedCommand()
+ {
+ ConsoleHelper.WriteInfoLine(Resources.CommandSupported_Command_0_Brief
+ + "\t"
+ + Resources.CommandSupported_Detailed, commandVersionSupported);
+ }
+
+ #endregion
+
+ #region Migrate Command
+
+ private static void MigrateCommand(string[] args)
+ {
+ if (args.Length != 3)
+ {
+ ConsoleHelper.WriteErrorLine(Resources.Command_0_Incorrect_number_of_parameters, commandMigrate);
+ SystemConsole.WriteLine("");
+ ShowMigrateCommand();
+ return;
+ }
+ }
+
+ private static void ShowMigrateCommand()
+ {
+ ConsoleHelper.WriteInfoLine(Resources.CommandMigrate_Command_0_Brief
+ + "\t"
+ + Resources.CommandMigrate_Detailed, commandMigrate);
+ }
+
+ #endregion
}
}
\ No newline at end of file
Index: Migration/Console/src/Migration.Console/ConsoleHelper.cs
===================================================================
diff -u
--- Migration/Console/src/Migration.Console/ConsoleHelper.cs (revision 0)
+++ Migration/Console/src/Migration.Console/ConsoleHelper.cs (revision 2b087ce4a7c30f4fcf8ca1ed99af874c42c8ef19)
@@ -0,0 +1,73 @@
+// 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 SystemConsole = System.Console;
+
+namespace Migration.Console
+{
+ ///
+ /// This class defines methods that help writing to the .
+ ///
+ public static class ConsoleHelper
+ {
+ ///
+ /// Writes as an error text to the .
+ ///
+ /// A composite format string.
+ /// An array of objects to write using .
+ /// Thrown when any of the input parameters is null.
+ /// Thrown when an I/O error occurred.
+ /// Thrown when the format specification in is invalid.
+ ///
+ public static void WriteErrorLine(string format, params object[] args)
+ {
+ if (format == null)
+ {
+ throw new ArgumentNullException(nameof(format));
+ }
+ if (args == null)
+ {
+ throw new ArgumentNullException(nameof(args));
+ }
+ SystemConsole.ForegroundColor = ConsoleColor.Red;
+ SystemConsole.WriteLine(format, args);
+ SystemConsole.ResetColor();
+ }
+
+ ///
+ /// Writes as an info text to the .
+ ///
+ /// A composite format string.
+ /// An array of objects to write using .
+ /// Thrown when any of the input parameters is null.
+ /// Thrown when an I/O error occurred.
+ /// Thrown when the format specification in is invalid.
+ ///
+ public static void WriteInfoLine(string format, params object[] args)
+ {
+ SystemConsole.ForegroundColor = ConsoleColor.White;
+ SystemConsole.WriteLine(format, args);
+ SystemConsole.ResetColor();
+ }
+ }
+}
\ No newline at end of file
Index: Migration/Console/src/Migration.Console/Migration.Console.csproj
===================================================================
diff -u -r14e971c5493a0ba1d613b99ee9cb18217ac0995f -r2b087ce4a7c30f4fcf8ca1ed99af874c42c8ef19
--- Migration/Console/src/Migration.Console/Migration.Console.csproj (.../Migration.Console.csproj) (revision 14e971c5493a0ba1d613b99ee9cb18217ac0995f)
+++ Migration/Console/src/Migration.Console/Migration.Console.csproj (.../Migration.Console.csproj) (revision 2b087ce4a7c30f4fcf8ca1ed99af874c42c8ef19)
@@ -6,7 +6,7 @@
ExePropertiesMigration.Console
- Migration.Console
+ RingtoetsMigrationToolv4.0512
@@ -34,6 +34,7 @@
+
@@ -45,13 +46,26 @@
Properties\GlobalAssembly.cs
+
+
+ True
+ True
+ Resources.resx
+
Copying.licenseheader
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ RINGTOETSBESTANDSPAD is het bestandspad naar het Ringtoetsdatabase bestand dat gemigreerd moet worden. NIEUWEVERSIE is de versie naar waar gemigreerd moet worden. UITVOERPAD is het pad waar de het gemigreerde Ringtoetsbestand opgeslagen zal worden.
+
+
+ {0} RINGTOETSBESTANDSPAD NIEUWEVERSIE UITVOERPAD
+
+
+ Er is een verkeerd aantal parameters opgegeven voor de opdracht '{0}'
+
+
+ Geef het hulp menu weer.
+
+
+ {0} is geen geldige opdracht.
+
+
+ RINGTOETSBESTANDSPAD is het bestandspad naar het Ringtoetsdatabase bestand waarvan de versie gevalideerd moet worden.
+
+
+ {0} RINGTOETSBESTANDSPAD
+
+
\ No newline at end of file
Index: Migration/Console/test/Migration.Console.Test/ConsoleHelperTest.cs
===================================================================
diff -u
--- Migration/Console/test/Migration.Console.Test/ConsoleHelperTest.cs (revision 0)
+++ Migration/Console/test/Migration.Console.Test/ConsoleHelperTest.cs (revision 2b087ce4a7c30f4fcf8ca1ed99af874c42c8ef19)
@@ -0,0 +1,203 @@
+// 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 NUnit.Framework;
+using SystemConsole = System.Console;
+
+namespace Migration.Console.Test
+{
+ [TestFixture]
+ public class ConsoleHelperTest
+ {
+ [Test]
+ public void WriteErrorLine_StringNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var originalColor = SystemConsole.ForegroundColor;
+ const string args = "an argument";
+
+ // Call
+ TestDelegate call = () => ConsoleHelper.WriteErrorLine(null, args);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("format", paramName);
+ Assert.AreEqual(originalColor, SystemConsole.ForegroundColor);
+ }
+
+ [Test]
+ public void WriteErrorLine_ArgsNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var originalColor = SystemConsole.ForegroundColor;
+ const string writeLine = "this is an error line with {0}";
+
+ // Call
+ TestDelegate call = () => ConsoleHelper.WriteErrorLine(writeLine, null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("args", paramName);
+ Assert.AreEqual(originalColor, SystemConsole.ForegroundColor);
+ }
+
+ [Test]
+ public void WriteErrorLine_StringAndParamArgs_WritesExpectedLine()
+ {
+ // Setup
+ var originalColor = SystemConsole.ForegroundColor;
+ const string writeLine = "this is an error line with {0}";
+ const string args = "an argument";
+ string consoleText;
+
+ // Call
+ using (var consoleOutput = new ConsoleOutput())
+ {
+ ConsoleHelper.WriteErrorLine(writeLine, args);
+ consoleText = consoleOutput.GetConsoleOutput();
+ }
+
+ // Assert
+ Assert.AreEqual(string.Format(writeLine, args) + Environment.NewLine, consoleText);
+ Assert.AreEqual(originalColor, SystemConsole.ForegroundColor);
+ }
+
+ [Test]
+ public void WriteErrorLine_String_WritesExpectedLine()
+ {
+ // Setup
+ var originalColor = SystemConsole.ForegroundColor;
+ const string writeLine = "this is an error line";
+ string consoleText;
+
+ // Call
+ using (var consoleOutput = new ConsoleOutput())
+ {
+ ConsoleHelper.WriteErrorLine(writeLine);
+ consoleText = consoleOutput.GetConsoleOutput();
+ }
+
+ // Assert
+ Assert.AreEqual(writeLine + Environment.NewLine, consoleText);
+ Assert.AreEqual(originalColor, SystemConsole.ForegroundColor);
+ }
+
+ [Test]
+ public void WriteErrorLine_InvalidString_ThrowsFormatException()
+ {
+ // Setup
+ string invalidFormat = "{d}";
+
+ // Call
+ TestDelegate call = () => ConsoleHelper.WriteErrorLine(invalidFormat, "ABC");
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void WriteInfoLine_StringNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var originalColor = SystemConsole.ForegroundColor;
+ const string args = "an argument";
+
+ // Call
+ TestDelegate call = () => ConsoleHelper.WriteInfoLine(null, args);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("format", paramName);
+ Assert.AreEqual(originalColor, SystemConsole.ForegroundColor);
+ }
+
+ [Test]
+ public void WriteInfoLine_ArgsNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var originalColor = SystemConsole.ForegroundColor;
+ const string writeLine = "this is an info line with {0}";
+
+ // Call
+ TestDelegate call = () => ConsoleHelper.WriteErrorLine(writeLine, null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("args", paramName);
+ Assert.AreEqual(originalColor, SystemConsole.ForegroundColor);
+ }
+
+ [Test]
+ public void WriteInfoLine_StringAndParamArgs_WritesExpectedLine()
+ {
+ // Setup
+ var originalColor = SystemConsole.ForegroundColor;
+ const string writeLine = "this is an info line with {0}";
+ const string args = "an argument";
+ string consoleText;
+
+ // Call
+ using (var consoleOutput = new ConsoleOutput())
+ {
+ ConsoleHelper.WriteInfoLine(writeLine, args);
+ consoleText = consoleOutput.GetConsoleOutput();
+ }
+
+ // Assert
+ Assert.AreEqual(string.Format(writeLine, args) + Environment.NewLine, consoleText);
+ Assert.AreEqual(originalColor, SystemConsole.ForegroundColor);
+ }
+
+ [Test]
+ public void WriteInfoLine_String_WritesExpectedLine()
+ {
+ // Setup
+ var originalColor = SystemConsole.ForegroundColor;
+ const string writeLine = "this is an info line";
+ string consoleText;
+
+ // Call
+ using (var consoleOutput = new ConsoleOutput())
+ {
+ ConsoleHelper.WriteInfoLine(writeLine);
+ consoleText = consoleOutput.GetConsoleOutput();
+ }
+
+ // Assert
+ Assert.AreEqual(writeLine + Environment.NewLine, consoleText);
+ Assert.AreEqual(originalColor, SystemConsole.ForegroundColor);
+ }
+
+ [Test]
+ public void WriteInfoLine_InvalidString_ThrowsFormatException()
+ {
+ // Setup
+ string invalidFormat = "{d}";
+
+ // Call
+ TestDelegate call = () => ConsoleHelper.WriteInfoLine(invalidFormat, "ABC");
+
+ // Assert
+ Assert.Throws(call);
+ }
+ }
+}
\ No newline at end of file
Index: Migration/Console/test/Migration.Console.Test/ConsoleOutput.cs
===================================================================
diff -u
--- Migration/Console/test/Migration.Console.Test/ConsoleOutput.cs (revision 0)
+++ Migration/Console/test/Migration.Console.Test/ConsoleOutput.cs (revision 2b087ce4a7c30f4fcf8ca1ed99af874c42c8ef19)
@@ -0,0 +1,78 @@
+// 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 SystemConsole = System.Console;
+
+namespace Migration.Console.Test
+{
+ ///
+ /// This class captures the output that is sent to .
+ ///
+ public class ConsoleOutput : IDisposable
+ {
+ private readonly StringWriter stringWriter;
+ private readonly TextWriter originalOutput;
+ private bool disposed;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ public ConsoleOutput()
+ {
+ originalOutput = SystemConsole.Out;
+ stringWriter = new StringWriter();
+ SystemConsole.SetOut(stringWriter);
+ }
+
+ ///
+ /// Gets text that was sent to to (if any).
+ ///
+ /// The captured text.
+ public string GetConsoleOutput()
+ {
+ stringWriter.Flush();
+ return stringWriter.ToString();
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposed)
+ {
+ return;
+ }
+
+ if (disposing)
+ {
+ SystemConsole.SetOut(originalOutput);
+ stringWriter?.Dispose();
+ }
+ disposed = true;
+ }
+ }
+}
\ No newline at end of file
Index: Migration/Console/test/Migration.Console.Test/ConsoleOutputTest.cs
===================================================================
diff -u
--- Migration/Console/test/Migration.Console.Test/ConsoleOutputTest.cs (revision 0)
+++ Migration/Console/test/Migration.Console.Test/ConsoleOutputTest.cs (revision 2b087ce4a7c30f4fcf8ca1ed99af874c42c8ef19)
@@ -0,0 +1,79 @@
+// 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 NUnit.Framework;
+using SystemConsole = System.Console;
+
+namespace Migration.Console.Test
+{
+ [TestFixture]
+ public class ConsoleOutputTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ TextWriter originalWriter = SystemConsole.Out;
+ TextWriter consoleOutputwriter;
+
+ // Call
+ using (new ConsoleOutput())
+ {
+ consoleOutputwriter = SystemConsole.Out;
+ }
+
+ // Assert
+ Assert.AreNotSame(consoleOutputwriter, SystemConsole.Out);
+ Assert.AreSame(originalWriter, SystemConsole.Out);
+ }
+
+ [Test]
+ public void GetConsoleOutput_TextSentToConsole_ReturnsCapturedText()
+ {
+ // Setup
+ const string lineOne = "first line.";
+ const string lineTwo = "second line.";
+ const string lineThree = "third line.";
+ SystemConsole.WriteLine(@"Before");
+ string capturedText;
+
+ // Call
+ using (var consoleOutput = new ConsoleOutput())
+ {
+ SystemConsole.WriteLine(lineOne);
+ SystemConsole.WriteLine(lineTwo);
+
+ capturedText = consoleOutput.GetConsoleOutput();
+
+ SystemConsole.WriteLine(lineThree);
+ }
+
+ // Assert
+ SystemConsole.WriteLine(@"After");
+ Assert.AreEqual(string.Concat(
+ lineOne, Environment.NewLine,
+ lineTwo, Environment.NewLine
+ ), capturedText);
+ }
+ }
+}
\ No newline at end of file
Index: Migration/Console/test/Migration.Console.Test/Migration.Console.Test.csproj
===================================================================
diff -u -r6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b -r2b087ce4a7c30f4fcf8ca1ed99af874c42c8ef19
--- Migration/Console/test/Migration.Console.Test/Migration.Console.Test.csproj (.../Migration.Console.Test.csproj) (revision 6cc96c5f52e06c2dc083a1ae3eb56d358b28a62b)
+++ Migration/Console/test/Migration.Console.Test/Migration.Console.Test.csproj (.../Migration.Console.Test.csproj) (revision 2b087ce4a7c30f4fcf8ca1ed99af874c42c8ef19)
@@ -1,7 +1,7 @@
- Debug
+ Debugx86{FC777320-4550-45DF-B31B-C33BA4505AC4}Library
@@ -55,6 +55,9 @@
Properties\GlobalAssembly.cs
+
+
+
@@ -63,6 +66,12 @@
+
+
+ {2E2C9B96-E72A-4C10-AA54-A5381FE30B0D}
+ Migration.Console
+
+