Index: Application/Riskeer/test/Application.Riskeer.Test/AppTest.cs =================================================================== diff -u -r647a8cce76df2a2a9d15a5c8682b21177655db46 -r3c64407303b0747af9311ce346df9d8966971956 --- Application/Riskeer/test/Application.Riskeer.Test/AppTest.cs (.../AppTest.cs) (revision 647a8cce76df2a2a9d15a5c8682b21177655db46) +++ Application/Riskeer/test/Application.Riskeer.Test/AppTest.cs (.../AppTest.cs) (revision 3c64407303b0747af9311ce346df9d8966971956) @@ -24,7 +24,7 @@ using System.Linq; using Core.Common.TestUtil; using Core.Common.Util.Settings; -using NUnit.Framework; +using NUnit.Framework; using Riskeer.Integration.Forms; namespace Application.Riskeer.Test Index: Application/Riskeer/test/Application.Riskeer.Test/SetUpFixture.cs =================================================================== diff -u --- Application/Riskeer/test/Application.Riskeer.Test/SetUpFixture.cs (revision 0) +++ Application/Riskeer/test/Application.Riskeer.Test/SetUpFixture.cs (revision 3c64407303b0747af9311ce346df9d8966971956) @@ -0,0 +1,36 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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 Core.Common.TestUtil; +using NUnit.Framework; + +namespace Application.Riskeer.Test +{ + [SetUpFixture] + public class SetUpFixture + { + [OneTimeSetUp] + public void OneTimeSetUp() + { + SetUpFixtureHelper.SetupAssemblyResolver(); + } + } +} Index: Core/Common/src/Core.Common.Assembly/AssemblyResolver.cs =================================================================== diff -u -r7de32ec6e74184506339e3482ddb41f713079835 -r3c64407303b0747af9311ce346df9d8966971956 --- Core/Common/src/Core.Common.Assembly/AssemblyResolver.cs (.../AssemblyResolver.cs) (revision 7de32ec6e74184506339e3482ddb41f713079835) +++ Core/Common/src/Core.Common.Assembly/AssemblyResolver.cs (.../AssemblyResolver.cs) (revision 3c64407303b0747af9311ce346df9d8966971956) @@ -1,4 +1,25 @@ -using System; +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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 System.Collections.Generic; using System.IO; Index: Core/Common/test/Core.Common.Base.Test/SetUpFixture.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Base.Test/SetUpFixture.cs (revision 0) +++ Core/Common/test/Core.Common.Base.Test/SetUpFixture.cs (revision 3c64407303b0747af9311ce346df9d8966971956) @@ -0,0 +1,36 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.TestUtil; +using NUnit.Framework; + +namespace Core.Common.Base.Test +{ + [SetUpFixture] + public class SetUpFixture + { + [OneTimeSetUp] + public void OneTimeSetUp() + { + SetUpFixtureHelper.SetupAssemblyResolver(); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.TestUtil/Core.Common.TestUtil.csproj =================================================================== diff -u -r3083673498ce2fbe79e8c29c314b7fbdebdd4178 -r3c64407303b0747af9311ce346df9d8966971956 --- Core/Common/test/Core.Common.TestUtil/Core.Common.TestUtil.csproj (.../Core.Common.TestUtil.csproj) (revision 3083673498ce2fbe79e8c29c314b7fbdebdd4178) +++ Core/Common/test/Core.Common.TestUtil/Core.Common.TestUtil.csproj (.../Core.Common.TestUtil.csproj) (revision 3c64407303b0747af9311ce346df9d8966971956) @@ -20,6 +20,7 @@ + Index: Core/Common/test/Core.Common.TestUtil/SetUpFixtureHelper.cs =================================================================== diff -u --- Core/Common/test/Core.Common.TestUtil/SetUpFixtureHelper.cs (revision 0) +++ Core/Common/test/Core.Common.TestUtil/SetUpFixtureHelper.cs (revision 3c64407303b0747af9311ce346df9d8966971956) @@ -0,0 +1,85 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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 System.IO; +using System.Linq; +using Core.Common.Assembly; +using NUnit.Framework.Internal; + +namespace Core.Common.TestUtil +{ + /// + /// Helper that contains methods which can be used within classes. + /// + public static class SetUpFixtureHelper + { +#if DEBUG + private const string configuration = "Debug"; +#elif RELEASE + private const string configuration = "Release"; +#elif CREATEINSTALLER + private const string configuration = "CreateInstaller"; +#elif CREATEINSTALLERWITHDEMOPLUGIN + private const string configuration = "CreateInstallerWithDemoPlugin"; +#elif RELEASEFORCODECOVERAGE + private const string configuration = "ReleaseForCodeCoverage"; +#endif + + /// + /// Sets up the . + /// + public static void SetupAssemblyResolver() + { + string executingAssemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location; + string solutionRoot = GetSolutionRoot(Directory.GetParent(executingAssemblyLocation)); + string executableDirectory = Path.Combine(solutionRoot, "bin", configuration); + + System.Reflection.Assembly GetAssemblyResolver(object sender, ResolveEventArgs args) + { + return System.Reflection.Assembly.LoadFile( + Path.Combine(executableDirectory, "Application", "Built-in", + "Managed", "Core", "Common.Assembly.dll")); + } + + AppDomain.CurrentDomain.AssemblyResolve += GetAssemblyResolver; + + InitializeAssemblyResolver(executableDirectory); + + AppDomain.CurrentDomain.AssemblyResolve -= GetAssemblyResolver; + } + + private static string GetSolutionRoot(DirectoryInfo directory) + { + return directory.GetFiles().Any(f => f.Extension.Equals(".sln")) + ? directory.FullName + : GetSolutionRoot(directory.Parent); + } + + private static void InitializeAssemblyResolver(string assemblyDirectory) + { + if (AssemblyResolver.RequiresInitialization) + { + AssemblyResolver.Initialize(assemblyDirectory); + } + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Util.Test/Reflection/AssemblyUtilsTest.cs =================================================================== diff -u -r865f437368653d22dd3ee83c2b71e815dcde4b76 -r3c64407303b0747af9311ce346df9d8966971956 --- Core/Common/test/Core.Common.Util.Test/Reflection/AssemblyUtilsTest.cs (.../AssemblyUtilsTest.cs) (revision 865f437368653d22dd3ee83c2b71e815dcde4b76) +++ Core/Common/test/Core.Common.Util.Test/Reflection/AssemblyUtilsTest.cs (.../AssemblyUtilsTest.cs) (revision 3c64407303b0747af9311ce346df9d8966971956) @@ -21,7 +21,6 @@ using System; using System.IO; -using System.Reflection; using Core.Common.Util.Reflection; using NUnit.Framework; @@ -34,11 +33,11 @@ public void GetAssemblyInfo_AssemblyNull_ThrowArgumentNullException() { // Call - TestDelegate call = () => AssemblyUtils.GetAssemblyInfo(null); + void Call() => AssemblyUtils.GetAssemblyInfo(null); // Assert - string paramName = Assert.Throws(call).ParamName; - Assert.AreEqual(paramName, "assembly"); + var exception = Assert.Throws(Call); + Assert.AreEqual("assembly", exception.ParamName); } [Test] @@ -63,7 +62,7 @@ public void GetAssemblyInfo_ForThisTestProjectAssembly_ReturnAssemblyInfoWithExpectedValues() { // Setup - Assembly assembly = Assembly.GetAssembly(GetType()); + var assembly = System.Reflection.Assembly.GetAssembly(GetType()); // Call AssemblyUtils.AssemblyInfo assemblyInfo = AssemblyUtils.GetAssemblyInfo(assembly); @@ -80,7 +79,7 @@ public void GetExecutingAssemblyInfo_ReturnAssemblyInfoForAssemblyUtilsAssembly() { // Setup - Assembly assembly = Assembly.GetAssembly(typeof(AssemblyUtils)); + var assembly = System.Reflection.Assembly.GetAssembly(typeof(AssemblyUtils)); AssemblyUtils.AssemblyInfo assemblyInfo = AssemblyUtils.GetAssemblyInfo(assembly); // Call @@ -112,15 +111,15 @@ public void GetTypeByName_NameNull_ThrowArgumentNullException() { // Call - TestDelegate call = () => AssemblyUtils.GetTypeByName(null); + void Call() => AssemblyUtils.GetTypeByName(null); // Assert - string paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("name", paramName); + var exception = Assert.Throws(Call); + Assert.AreEqual("name", exception.ParamName); } [Test] - public void GetTypeByName_ForNonexistingClass_ReturnNull() + public void GetTypeByName_ForNonExistingClass_ReturnNull() { // Call Type returnedType = AssemblyUtils.GetTypeByName("I.Dont.Exist"); @@ -133,11 +132,11 @@ public void GetAssemblyResourceStream_AssemblyNull_ThrowArgumentNullException() { // Call - TestDelegate call = () => AssemblyUtils.GetAssemblyResourceStream(null, "nice.txt"); + void Call() => AssemblyUtils.GetAssemblyResourceStream(null, "nice.txt"); // Assert - string paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("assembly", paramName); + var exception = Assert.Throws(Call); + Assert.AreEqual("assembly", exception.ParamName); } [Test] @@ -157,22 +156,16 @@ public void GetAssemblyResourceStream_ForNonexistingEmbeddedResource_ThrowArgumentException() { // Call - TestDelegate call = () => AssemblyUtils.GetAssemblyResourceStream(GetType().Assembly, "I do not exist.txt"); + void Call() => AssemblyUtils.GetAssemblyResourceStream(GetType().Assembly, "I do not exist.txt"); // Assert - var exception = Assert.Throws(call); + var exception = Assert.Throws(Call); Assert.IsInstanceOf(exception.InnerException); } - private class MockedAssemblyWithoutLocation : Assembly + private class MockedAssemblyWithoutLocation : System.Reflection.Assembly { - public override string Location - { - get - { - return ""; - } - } + public override string Location => ""; } } } \ No newline at end of file Index: build/Source.targets =================================================================== diff -u -rfc20cbbb76a6534b9fec3420ebe3f81e4f87626e -r3c64407303b0747af9311ce346df9d8966971956 --- build/Source.targets (.../Source.targets) (revision fc20cbbb76a6534b9fec3420ebe3f81e4f87626e) +++ build/Source.targets (.../Source.targets) (revision 3c64407303b0747af9311ce346df9d8966971956) @@ -25,28 +25,28 @@ Release none true - TRACE;DEVELOPMENT + TRACE;DEVELOPMENT;RELEASE none false Release none true - TRACE + TRACE;CREATEINSTALLER none false Release none true - TRACE;DEVELOPMENT + TRACE;DEVELOPMENT;CREATEINSTALLERWITHDEMOPLUGIN none Release - TRACE + TRACE;RELEASEFORCODECOVERAGE true pdbonly