Index: Migration/Console/src/Migration.Console/DefaultEnvironmentControl.cs =================================================================== diff -u --- Migration/Console/src/Migration.Console/DefaultEnvironmentControl.cs (revision 0) +++ Migration/Console/src/Migration.Console/DefaultEnvironmentControl.cs (revision 111d72b3e14a3dddfaacddbae3f06ae214049f91) @@ -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. + +using System; + +namespace Migration.Console +{ + /// + /// Default control class for . + /// + internal class DefaultEnvironmentControl : EnvironmentControl + { + private static readonly DefaultEnvironmentControl currentInstance = new DefaultEnvironmentControl(); + + public override void Exit(int exitCode) + { + Environment.Exit(exitCode); + } + + /// + /// Gets the current instance of . + /// + public static DefaultEnvironmentControl CurrentInstance + { + get + { + return currentInstance; + } + } + } +} \ No newline at end of file Index: Migration/Console/src/Migration.Console/EnvironmentControl.cs =================================================================== diff -u --- Migration/Console/src/Migration.Console/EnvironmentControl.cs (revision 0) +++ Migration/Console/src/Migration.Console/EnvironmentControl.cs (revision 111d72b3e14a3dddfaacddbae3f06ae214049f91) @@ -0,0 +1,71 @@ +// 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.Security; + +namespace Migration.Console +{ + /// + /// Controls class for . + /// + public abstract class EnvironmentControl + { + private static EnvironmentControl instance; + + /// + /// Gets or sets the current instance. + /// + /// Thrown when is null. + public static EnvironmentControl Instance + { + get + { + return instance ?? (instance = DefaultEnvironmentControl.CurrentInstance); + } + + internal set + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + instance = value; + } + } + + /// + /// Terminates this process and gives the underlying operating system the specified exit code. + /// + /// Exit code to be given to the operating system. + /// The caller does not have sufficient security permission to perform this function. + public abstract void Exit(int exitCode); + + /// + /// Resets the environment to the default. + /// + public static void ResetToDefault() + { + instance = DefaultEnvironmentControl.CurrentInstance; + } + } +} \ No newline at end of file Index: Migration/Console/src/Migration.Console/ErrorCode.cs =================================================================== diff -u --- Migration/Console/src/Migration.Console/ErrorCode.cs (revision 0) +++ Migration/Console/src/Migration.Console/ErrorCode.cs (revision 111d72b3e14a3dddfaacddbae3f06ae214049f91) @@ -0,0 +1,39 @@ +// 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 Migration.Console +{ + /// + /// Enumeration that defines the possible exit codes of an application. + /// + public enum ErrorCode + { + /// + /// Exit because the command provide failed. + /// + ErrorBadCommand = 22, + + /// + /// Exit because bad arguments were provided. + /// + ErrorBadArguments = 160 + } +} \ No newline at end of file Index: Migration/Console/src/Migration.Console/Migration.Console.csproj =================================================================== diff -u -r0882ad7cd6c36603f7da9c400f44c6613a82bb33 -r111d72b3e14a3dddfaacddbae3f06ae214049f91 --- Migration/Console/src/Migration.Console/Migration.Console.csproj (.../Migration.Console.csproj) (revision 0882ad7cd6c36603f7da9c400f44c6613a82bb33) +++ Migration/Console/src/Migration.Console/Migration.Console.csproj (.../Migration.Console.csproj) (revision 111d72b3e14a3dddfaacddbae3f06ae214049f91) @@ -45,6 +45,9 @@ Properties\GlobalAssembly.cs + + + @@ -66,6 +69,20 @@ Designer + + + {e344867e-9ac9-44c8-88a5-8185681679a9} + Core.Common.IO + + + {EFD7E662-5B69-4B71-A448-565B64E9C033} + Migration.Core.Storage + + + {D08DB9E2-6861-44C8-A725-71A70274CC77} + Migration.Scripts.Data + + + \ No newline at end of file Index: Migration/Console/test/Migration.Console.TestUtil.Test/Migration.Console.TestUtil.Test.csproj =================================================================== diff -u -r0882ad7cd6c36603f7da9c400f44c6613a82bb33 -r111d72b3e14a3dddfaacddbae3f06ae214049f91 --- Migration/Console/test/Migration.Console.TestUtil.Test/Migration.Console.TestUtil.Test.csproj (.../Migration.Console.TestUtil.Test.csproj) (revision 0882ad7cd6c36603f7da9c400f44c6613a82bb33) +++ Migration/Console/test/Migration.Console.TestUtil.Test/Migration.Console.TestUtil.Test.csproj (.../Migration.Console.TestUtil.Test.csproj) (revision 111d72b3e14a3dddfaacddbae3f06ae214049f91) @@ -52,6 +52,7 @@ + @@ -60,6 +61,14 @@ + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + + + {2E2C9B96-E72A-4C10-AA54-A5381FE30B0D} + Migration.Console + {679D3CE6-0820-49CF-9D56-D1CF7F1B853A} Migration.Console.TestUtil Index: Migration/Console/test/Migration.Console.TestUtil.Test/TestEnvironmentControlTest.cs =================================================================== diff -u --- Migration/Console/test/Migration.Console.TestUtil.Test/TestEnvironmentControlTest.cs (revision 0) +++ Migration/Console/test/Migration.Console.TestUtil.Test/TestEnvironmentControlTest.cs (revision 111d72b3e14a3dddfaacddbae3f06ae214049f91) @@ -0,0 +1,57 @@ +// 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 Core.Common.TestUtil; + +namespace Migration.Console.TestUtil.Test +{ + [TestFixture] + public class TestEnvironmentControlTest + { + [Test] + public void Constructor_ExpectedProperties() + { + // Call + var testEnvironmentControl = new TestEnvironmentControl(); + + // Assert + Assert.IsInstanceOf(testEnvironmentControl); + } + + [Test] + public void ErrorCodeCalled_ExitCalled_ReturnsTheErrorCodeByWhichExitWasCalled() + { + // Setup + var testEnvironmentControl = new TestEnvironmentControl(); + ErrorCode errorCodeEnum = new Random(74).NextEnumValue(); + int errorCode = (int) errorCodeEnum; + testEnvironmentControl.Exit(errorCode); + + // Call + int called = testEnvironmentControl.ErrorCodeCalled; + + // Assert + Assert.AreEqual(errorCode, called); + } + } +} \ No newline at end of file Index: Migration/Console/test/Migration.Console.TestUtil/Migration.Console.TestUtil.csproj =================================================================== diff -u -r0882ad7cd6c36603f7da9c400f44c6613a82bb33 -r111d72b3e14a3dddfaacddbae3f06ae214049f91 --- Migration/Console/test/Migration.Console.TestUtil/Migration.Console.TestUtil.csproj (.../Migration.Console.TestUtil.csproj) (revision 0882ad7cd6c36603f7da9c400f44c6613a82bb33) +++ Migration/Console/test/Migration.Console.TestUtil/Migration.Console.TestUtil.csproj (.../Migration.Console.TestUtil.csproj) (revision 111d72b3e14a3dddfaacddbae3f06ae214049f91) @@ -48,12 +48,19 @@ + Copying.licenseheader + + + {2E2C9B96-E72A-4C10-AA54-A5381FE30B0D} + Migration.Console + +