Index: Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs =================================================================== diff -u -r9159e629e90a794aa18b28d61c6b7904407acbcc -rc67344d2d2fd13f652e674a391c6fbb5e188cd26 --- Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs (.../DataGridViewControl.cs) (revision 9159e629e90a794aa18b28d61c6b7904407acbcc) +++ Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs (.../DataGridViewControl.cs) (revision c67344d2d2fd13f652e674a391c6fbb5e188cd26) @@ -142,7 +142,7 @@ } catch (Exception e) when (e is ArgumentException || e is InvalidOperationException) { - throw new ArgumentException(@"Unable to set the cell active.", nameof(cell)); + throw new ArgumentException(@"Unable to set the cell active.", nameof(cell), e); } } Index: Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs =================================================================== diff -u -r086b271f12e1d631bec26abacf84f90fa3fe83ef -rc67344d2d2fd13f652e674a391c6fbb5e188cd26 --- Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs (.../DataGridViewControlTest.cs) (revision 086b271f12e1d631bec26abacf84f90fa3fe83ef) +++ Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs (.../DataGridViewControlTest.cs) (revision c67344d2d2fd13f652e674a391c6fbb5e188cd26) @@ -28,6 +28,7 @@ using Core.Common.Base.Data; using Core.Common.Controls.DataGrid; using Core.Common.Controls.Test.Properties; +using Core.Common.TestUtil; using Core.Common.Utils; using Core.Common.Utils.Attributes; using Core.Common.Utils.Reflection; @@ -1110,8 +1111,10 @@ TestDelegate test = () => control.SetCurrentCell(firstcell); // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("cell", paramName); + const string message = "Unable to set the cell active."; + ArgumentException exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, message); + Assert.AreEqual("cell", exception.ParamName); + Assert.IsInstanceOf(exception.InnerException); } } @@ -1139,8 +1142,10 @@ TestDelegate test = () => control.SetCurrentCell(dataGridViewRow.Cells[0]); // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("cell", paramName); + const string message = "Unable to set the cell active."; + ArgumentException exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, message); + Assert.AreEqual("cell", exception.ParamName); + Assert.IsInstanceOf(exception.InnerException); } } Index: Core/Common/test/Core.Common.Gui.Test/Settings/SettingsHelperTest.cs =================================================================== diff -u -r9e7b8344cc985249f312870b9030705371c82bfe -rc67344d2d2fd13f652e674a391c6fbb5e188cd26 --- Core/Common/test/Core.Common.Gui.Test/Settings/SettingsHelperTest.cs (.../SettingsHelperTest.cs) (revision 9e7b8344cc985249f312870b9030705371c82bfe) +++ Core/Common/test/Core.Common.Gui.Test/Settings/SettingsHelperTest.cs (.../SettingsHelperTest.cs) (revision c67344d2d2fd13f652e674a391c6fbb5e188cd26) @@ -47,7 +47,7 @@ public void ApplicationName_ReturnsProductNameOfExecutingAssembly() { // Call - var settings = SettingsHelper.Instance.ApplicationName; + string settings = SettingsHelper.Instance.ApplicationName; // Assert Assert.AreEqual(AssemblyUtils.GetExecutingAssemblyInfo().Product, settings); @@ -57,7 +57,7 @@ public void ApplicationVersion_ReturnsVersionOfExecutingAssembly() { // Call - var settings = SettingsHelper.Instance.ApplicationVersion; + string settings = SettingsHelper.Instance.ApplicationVersion; // Assert Assert.AreEqual(AssemblyUtils.GetExecutingAssemblyInfo().Version, settings); @@ -67,10 +67,10 @@ public void GetApplicationLocalUserSettingsDirectory_WithoutSubFolder_ReturnsApplicationLocalUserSettingsDirectory() { // Call - var pathFromSettings = SettingsHelper.Instance.GetApplicationLocalUserSettingsDirectory(); + string pathFromSettings = SettingsHelper.Instance.GetApplicationLocalUserSettingsDirectory(); // Assert - var localSettingsDirectoryPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + string localSettingsDirectoryPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); Assert.AreEqual(localSettingsDirectoryPath, pathFromSettings); } @@ -115,7 +115,7 @@ // Assert string dataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), workingDirectory); var expectedMessage = $"De map '{dataPath}' kan niet aangemaakt worden."; - var message = Assert.Throws(test).Message; + string message = Assert.Throws(test).Message; Assert.AreEqual(expectedMessage, message); } } Index: Core/Common/test/Core.Common.Gui.TestUtil.Test/Core.Common.Gui.TestUtil.Test.csproj =================================================================== diff -u -rf3e15928caffd4336c97f5fa3de495a5a05bf6b8 -rc67344d2d2fd13f652e674a391c6fbb5e188cd26 --- Core/Common/test/Core.Common.Gui.TestUtil.Test/Core.Common.Gui.TestUtil.Test.csproj (.../Core.Common.Gui.TestUtil.Test.csproj) (revision f3e15928caffd4336c97f5fa3de495a5a05bf6b8) +++ Core/Common/test/Core.Common.Gui.TestUtil.Test/Core.Common.Gui.TestUtil.Test.csproj (.../Core.Common.Gui.TestUtil.Test.csproj) (revision c67344d2d2fd13f652e674a391c6fbb5e188cd26) @@ -38,6 +38,10 @@ ..\..\..\..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll True + + ..\..\..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll + True + @@ -53,6 +57,7 @@ Code + Index: Core/Common/test/Core.Common.Gui.TestUtil.Test/Settings/UseCustomSettingsHelperTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.TestUtil.Test/Settings/UseCustomSettingsHelperTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.TestUtil.Test/Settings/UseCustomSettingsHelperTest.cs (revision c67344d2d2fd13f652e674a391c6fbb5e188cd26) @@ -0,0 +1,74 @@ +// 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 Lesser 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser 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 Core.Common.Gui.Settings; +using Core.Common.Gui.TestUtil.Settings; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Common.Gui.TestUtil.Test.Settings +{ + [TestFixture] + public class UseCustomSettingsHelperTest + { + [Test] + public void GivenSettingsHelperInstance_WhenNewSettingsHelper_ThenSingletonInstanceTemporarilyChanged() + { + // Given + ISettingsHelper originalHelper = SettingsHelper.Instance; + + var mocks = new MockRepository(); + var helper = mocks.Stub(); + mocks.ReplayAll(); + + // When + using (new UseCustomSettingsHelper(helper)) + { + // Then + Assert.AreSame(helper, SettingsHelper.Instance); + } + Assert.AreSame(originalHelper, SettingsHelper.Instance); + mocks.VerifyAll(); + } + + [Test] + public void Dispose_AlreadyDisposed_DoesNotThrowException() + { + // Setup + var mocks = new MockRepository(); + var helper = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => + { + using (var control = new UseCustomSettingsHelper(helper)) + { + control.Dispose(); + } + }; + + // Assert + Assert.DoesNotThrow(call); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.TestUtil.Test/packages.config =================================================================== diff -u -r6a5d7b40b7ba4dcb73e393075338352d194e97c2 -rc67344d2d2fd13f652e674a391c6fbb5e188cd26 --- Core/Common/test/Core.Common.Gui.TestUtil.Test/packages.config (.../packages.config) (revision 6a5d7b40b7ba4dcb73e393075338352d194e97c2) +++ Core/Common/test/Core.Common.Gui.TestUtil.Test/packages.config (.../packages.config) (revision c67344d2d2fd13f652e674a391c6fbb5e188cd26) @@ -23,4 +23,5 @@ --> + \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.TestUtil/Core.Common.Gui.TestUtil.csproj =================================================================== diff -u -rf3e15928caffd4336c97f5fa3de495a5a05bf6b8 -rc67344d2d2fd13f652e674a391c6fbb5e188cd26 --- Core/Common/test/Core.Common.Gui.TestUtil/Core.Common.Gui.TestUtil.csproj (.../Core.Common.Gui.TestUtil.csproj) (revision f3e15928caffd4336c97f5fa3de495a5a05bf6b8) +++ Core/Common/test/Core.Common.Gui.TestUtil/Core.Common.Gui.TestUtil.csproj (.../Core.Common.Gui.TestUtil.csproj) (revision c67344d2d2fd13f652e674a391c6fbb5e188cd26) @@ -88,6 +88,7 @@ + Index: Core/Common/test/Core.Common.Gui.TestUtil/Settings/TestSettingsHelper.cs =================================================================== diff -u -r3a1d4488d68236efe6eccbd60be3484735aa689b -rc67344d2d2fd13f652e674a391c6fbb5e188cd26 --- Core/Common/test/Core.Common.Gui.TestUtil/Settings/TestSettingsHelper.cs (.../TestSettingsHelper.cs) (revision 3a1d4488d68236efe6eccbd60be3484735aa689b) +++ Core/Common/test/Core.Common.Gui.TestUtil/Settings/TestSettingsHelper.cs (.../TestSettingsHelper.cs) (revision c67344d2d2fd13f652e674a391c6fbb5e188cd26) @@ -36,6 +36,7 @@ /// /// Creates a new instance of . /// + /// public TestSettingsHelper() { ExpectedApplicationLocalUserSettingsDirectory = TestHelper.GetScratchPadPath(); Index: Core/Common/test/Core.Common.Gui.TestUtil/Settings/UseCustomSettingsHelper.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.TestUtil/Settings/UseCustomSettingsHelper.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.TestUtil/Settings/UseCustomSettingsHelper.cs (revision c67344d2d2fd13f652e674a391c6fbb5e188cd26) @@ -0,0 +1,63 @@ +// 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 Lesser 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser 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.Gui.Settings; + +namespace Core.Common.Gui.TestUtil.Settings +{ + /// + /// Configures to temporarily use a different + /// instance. + /// + public sealed class UseCustomSettingsHelper : IDisposable + { + private readonly ISettingsHelper originalHelper; + private bool disposed; + + /// + /// Creates a new instance of . + /// + /// The temporary helper to be used. + public UseCustomSettingsHelper(ISettingsHelper settingsHelper) + { + originalHelper = SettingsHelper.Instance; + SettingsHelper.Instance = settingsHelper; + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (disposed) + { + return; + } + + SettingsHelper.Instance = originalHelper; + disposed = true; + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.TestUtil/packages.config =================================================================== diff -u -r6a5d7b40b7ba4dcb73e393075338352d194e97c2 -rc67344d2d2fd13f652e674a391c6fbb5e188cd26 --- Core/Common/test/Core.Common.Gui.TestUtil/packages.config (.../packages.config) (revision 6a5d7b40b7ba4dcb73e393075338352d194e97c2) +++ Core/Common/test/Core.Common.Gui.TestUtil/packages.config (.../packages.config) (revision c67344d2d2fd13f652e674a391c6fbb5e188cd26) @@ -23,5 +23,4 @@ --> - \ No newline at end of file Index: Core/Components/test/Core.Components.DotSpatial.TestUtil.Test/Core.Components.DotSpatial.TestUtil.Test.csproj =================================================================== diff -u -rf02614d781e389e05b9b481e8d165286e6baad4d -rc67344d2d2fd13f652e674a391c6fbb5e188cd26 --- Core/Components/test/Core.Components.DotSpatial.TestUtil.Test/Core.Components.DotSpatial.TestUtil.Test.csproj (.../Core.Components.DotSpatial.TestUtil.Test.csproj) (revision f02614d781e389e05b9b481e8d165286e6baad4d) +++ Core/Components/test/Core.Components.DotSpatial.TestUtil.Test/Core.Components.DotSpatial.TestUtil.Test.csproj (.../Core.Components.DotSpatial.TestUtil.Test.csproj) (revision c67344d2d2fd13f652e674a391c6fbb5e188cd26) @@ -55,12 +55,6 @@ - - - - - - @@ -72,7 +66,6 @@ - @@ -86,10 +79,6 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base - - {30E4C2AE-719E-4D70-9FA9-668A9767FBFA} - Core.Common.Gui - {d749ee4c-ce50-4c17-bf01-9a953028c126} Core.Common.TestUtil Fisheye: Tag c67344d2d2fd13f652e674a391c6fbb5e188cd26 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.DotSpatial.TestUtil.Test/UseCustomSettingsHelperTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Components/test/Core.Components.DotSpatial.TestUtil/Core.Components.DotSpatial.TestUtil.csproj =================================================================== diff -u -rf02614d781e389e05b9b481e8d165286e6baad4d -rc67344d2d2fd13f652e674a391c6fbb5e188cd26 --- Core/Components/test/Core.Components.DotSpatial.TestUtil/Core.Components.DotSpatial.TestUtil.csproj (.../Core.Components.DotSpatial.TestUtil.csproj) (revision f02614d781e389e05b9b481e8d165286e6baad4d) +++ Core/Components/test/Core.Components.DotSpatial.TestUtil/Core.Components.DotSpatial.TestUtil.csproj (.../Core.Components.DotSpatial.TestUtil.csproj) (revision c67344d2d2fd13f652e674a391c6fbb5e188cd26) @@ -59,7 +59,6 @@ - @@ -68,10 +67,6 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base - - {30E4C2AE-719E-4D70-9FA9-668A9767FBFA} - Core.Common.Gui - {aa47e858-a2a7-470e-8b2d-c76ae8ed9ccd} Core.Components.DotSpatial Fisheye: Tag c67344d2d2fd13f652e674a391c6fbb5e188cd26 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.DotSpatial.TestUtil/UseCustomSettingsHelper.cs'. Fisheye: No comparison available. Pass `N' to diff?