Index: Ringtoets.sln =================================================================== diff -u -r01e8a3970f39975558bdf694df5ec66791ab95b9 -rb70eb58b18e2937e6c694b5ef1ba2d284596bfac --- Ringtoets.sln (.../Ringtoets.sln) (revision 01e8a3970f39975558bdf694df5ec66791ab95b9) +++ Ringtoets.sln (.../Ringtoets.sln) (revision b70eb58b18e2937e6c694b5ef1ba2d284596bfac) @@ -267,6 +267,10 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ringtoets.Piping.Calculation.TestUtil.Test", "Ringtoets\Piping\test\Ringtoets.Piping.Calculation.TestUtil.Test\Ringtoets.Piping.Calculation.TestUtil.Test.csproj", "{529C4919-27DE-4DDA-ABD6-537F21B3F223}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ringtoets.Piping.Service.TestUtil", "Ringtoets\Piping\test\Ringtoets.Piping.Service.TestUtil\Ringtoets.Piping.Service.TestUtil.csproj", "{C05B4F73-480E-46A4-B037-40954F8276DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ringtoets.Piping.Service.TestUtil.Test", "Ringtoets\Piping\test\Ringtoets.Piping.Service.TestUtil.Test\Ringtoets.Piping.Service.TestUtil.Test.csproj", "{63EAAA8C-51FE-48E1-81A5-753FB4A47898}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application.Ringtoets.Storage.TestUtil", "Application\Ringtoets\test\Application.Ringtoets.Storage.TestUtil\Application.Ringtoets.Storage.TestUtil.csproj", "{03DBE353-99F7-47D6-B826-60D694FFB9AC}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application.Ringtoets.Storage.TestUtil.Test", "Application\Ringtoets\test\Application.Ringtoets.Storage.TestUtil.Test\Application.Ringtoets.Storage.TestUtil.Test.csproj", "{3EDE00E5-C462-43EF-B8BC-E65D14D7FCF2}" @@ -1036,6 +1040,22 @@ {529C4919-27DE-4DDA-ABD6-537F21B3F223}.Release|x86.Build.0 = Release|x86 {529C4919-27DE-4DDA-ABD6-537F21B3F223}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86 {529C4919-27DE-4DDA-ABD6-537F21B3F223}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86 + {C05B4F73-480E-46A4-B037-40954F8276DC}.CreateInstaller|x86.ActiveCfg = Release|x86 + {C05B4F73-480E-46A4-B037-40954F8276DC}.CreateInstallerWithDemoProject|x86.ActiveCfg = Release|x86 + {C05B4F73-480E-46A4-B037-40954F8276DC}.Debug|x86.ActiveCfg = Debug|x86 + {C05B4F73-480E-46A4-B037-40954F8276DC}.Debug|x86.Build.0 = Debug|x86 + {C05B4F73-480E-46A4-B037-40954F8276DC}.Release|x86.ActiveCfg = Release|x86 + {C05B4F73-480E-46A4-B037-40954F8276DC}.Release|x86.Build.0 = Release|x86 + {C05B4F73-480E-46A4-B037-40954F8276DC}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86 + {C05B4F73-480E-46A4-B037-40954F8276DC}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86 + {63EAAA8C-51FE-48E1-81A5-753FB4A47898}.CreateInstaller|x86.ActiveCfg = Release|x86 + {63EAAA8C-51FE-48E1-81A5-753FB4A47898}.CreateInstallerWithDemoProject|x86.ActiveCfg = Release|x86 + {63EAAA8C-51FE-48E1-81A5-753FB4A47898}.Debug|x86.ActiveCfg = Debug|x86 + {63EAAA8C-51FE-48E1-81A5-753FB4A47898}.Debug|x86.Build.0 = Debug|x86 + {63EAAA8C-51FE-48E1-81A5-753FB4A47898}.Release|x86.ActiveCfg = Release|x86 + {63EAAA8C-51FE-48E1-81A5-753FB4A47898}.Release|x86.Build.0 = Release|x86 + {63EAAA8C-51FE-48E1-81A5-753FB4A47898}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86 + {63EAAA8C-51FE-48E1-81A5-753FB4A47898}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86 {03DBE353-99F7-47D6-B826-60D694FFB9AC}.CreateInstaller|x86.ActiveCfg = Release|x86 {03DBE353-99F7-47D6-B826-60D694FFB9AC}.CreateInstallerWithDemoProject|x86.ActiveCfg = Release|x86 {03DBE353-99F7-47D6-B826-60D694FFB9AC}.Debug|x86.ActiveCfg = Debug|x86 @@ -1124,6 +1144,8 @@ {813FFA92-1F3F-462B-B596-5919334007A9} = {1F0D20C2-7F04-431D-AF22-95A31FD53733} {35B78215-420B-4D7D-9959-9E9010601200} = {1F0D20C2-7F04-431D-AF22-95A31FD53733} {529C4919-27DE-4DDA-ABD6-537F21B3F223} = {1F0D20C2-7F04-431D-AF22-95A31FD53733} + {C05B4F73-480E-46A4-B037-40954F8276DC} = {1F0D20C2-7F04-431D-AF22-95A31FD53733} + {63EAAA8C-51FE-48E1-81A5-753FB4A47898} = {1F0D20C2-7F04-431D-AF22-95A31FD53733} {4A7D6720-4AA1-4F0B-A796-A0436DB3D7D7} = {39EB5D07-C076-484C-9621-B34C4E5BF64C} {3CCB05DB-C7B3-4EF7-B41D-22B6D2A3774E} = {39EB5D07-C076-484C-9621-B34C4E5BF64C} {50963F12-448C-41BA-A62C-CDB0AB8D21E0} = {39EB5D07-C076-484C-9621-B34C4E5BF64C} Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs =================================================================== diff -u -rbbca58832f24a62d39dc744c2db663ed696cfac1 -rb70eb58b18e2937e6c694b5ef1ba2d284596bfac --- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs (.../PipingCalculationService.cs) (revision bbca58832f24a62d39dc744c2db663ed696cfac1) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs (.../PipingCalculationService.cs) (revision b70eb58b18e2937e6c694b5ef1ba2d284596bfac) @@ -38,7 +38,7 @@ public static class PipingCalculationService { private static readonly ILog pipingCalculationLogger = LogManager.GetLogger(typeof(PipingCalculation)); - private static readonly IPipingSubCalculatorFactory subCalculatorFactory = new PipingSubCalculatorFactory(); + public static IPipingSubCalculatorFactory SubCalculatorFactory = new PipingSubCalculatorFactory(); /// /// Performs validation over the values on the given . Error and status information is logged during @@ -51,7 +51,7 @@ pipingCalculationLogger.Info(String.Format(Resources.Validation_Subject_0_started_Time_1_, calculation.Name, DateTimeService.CurrentTimeAsString)); - var validationResults = new PipingCalculator(CreateInputFromData(calculation.InputParameters), subCalculatorFactory).Validate(); + var validationResults = new PipingCalculator(CreateInputFromData(calculation.InputParameters), SubCalculatorFactory).Validate(); LogMessagesAsError(Resources.Error_in_piping_validation_0, validationResults.ToArray()); pipingCalculationLogger.Info(String.Format(Resources.Validation_Subject_0_ended_Time_1_, @@ -74,7 +74,7 @@ try { - var pipingResult = new PipingCalculator(CreateInputFromData(calculation.InputParameters), subCalculatorFactory).Calculate(); + var pipingResult = new PipingCalculator(CreateInputFromData(calculation.InputParameters), SubCalculatorFactory).Calculate(); calculation.Output = new PipingOutput(pipingResult.UpliftZValue, pipingResult.UpliftFactorOfSafety, @@ -115,7 +115,7 @@ /// public static double CalculateThicknessCoverageLayer(PipingInput input) { - return new PipingCalculator(CreateInputFromData(input), subCalculatorFactory).CalculateThicknessCoverageLayer(); + return new PipingCalculator(CreateInputFromData(input), SubCalculatorFactory).CalculateThicknessCoverageLayer(); } private static PipingCalculatorInput CreateInputFromData(PipingInput inputParameters) Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil.Test/PipingCalculationServiceConfigTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil.Test/PipingCalculationServiceConfigTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil.Test/PipingCalculationServiceConfigTest.cs (revision b70eb58b18e2937e6c694b5ef1ba2d284596bfac) @@ -0,0 +1,45 @@ +using System; +using NUnit.Framework; +using Ringtoets.Piping.Calculation.TestUtil.SubCalculator; + +namespace Ringtoets.Piping.Service.TestUtil.Test +{ + [TestFixture] + public class PipingCalculationServiceConfigTest + { + [Test] + public void Constructor_NewInstanceCanBeDisposed() + { + // Call + var factory = new PipingCalculationServiceConfig(); + + // Assert + Assert.IsInstanceOf(factory); + Assert.DoesNotThrow(() => factory.Dispose()); + } + + [Test] + public void Constructor_SetsTestFactoryForPipingCalculatorService() + { + // Call + using (new PipingCalculationServiceConfig()) + { + // Assert + Assert.IsInstanceOf(PipingCalculationService.SubCalculatorFactory); + } + } + + [Test] + public void Dispose_Always_ResetsFactoryToPreviousValue() + { + // Setup + var expectedFactory = PipingCalculationService.SubCalculatorFactory; + + // Call + using (new PipingCalculationServiceConfig()) { } + + // Assert + Assert.AreSame(expectedFactory, PipingCalculationService.SubCalculatorFactory); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil.Test/Properties/AssemblyInfo.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil.Test/Properties/AssemblyInfo.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil.Test/Properties/AssemblyInfo.cs (revision b70eb58b18e2937e6c694b5ef1ba2d284596bfac) @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ringtoets.Piping.Service.TestUtil.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Ringtoets.Piping.Service.TestUtil.Test")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("95326d6d-ccf6-484e-814b-3fd22aaff8ef")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil.Test/Ringtoets.Piping.Service.TestUtil.Test.csproj =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil.Test/Ringtoets.Piping.Service.TestUtil.Test.csproj (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil.Test/Ringtoets.Piping.Service.TestUtil.Test.csproj (revision b70eb58b18e2937e6c694b5ef1ba2d284596bfac) @@ -0,0 +1,80 @@ + + + + + Debug + x86 + {63EAAA8C-51FE-48E1-81A5-753FB4A47898} + Library + Properties + Ringtoets.Piping.Service.TestUtil.Test + Ringtoets.Piping.Service.TestUtil.Test + v4.0 + 512 + + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\Release\ + TRACE + true + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\ReleaseForCodeCoverage\ + x86 + TRACE + true + pdbonly + + + + ..\..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll + + + + + + + + + + + + + + {D64E4F0E-E341-496F-82B2-941AD202B4E3} + Ringtoets.Piping.Calculation + + + {10B8D63D-87E8-46DF-ACA9-A8CF22EE8FB5} + Ringtoets.Piping.Service + + + {27E0A5C9-3ABF-426A-A3DA-7D0B83A218C8} + Ringtoets.Piping.Calculation.TestUtil + + + {C05B4F73-480E-46A4-B037-40954F8276DC} + Ringtoets.Piping.Service.TestUtil + + + + + \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil.Test/packages.config =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil.Test/packages.config (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil.Test/packages.config (revision b70eb58b18e2937e6c694b5ef1ba2d284596bfac) @@ -0,0 +1,4 @@ + + + + \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil/PipingCalculationServiceConfig.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil/PipingCalculationServiceConfig.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil/PipingCalculationServiceConfig.cs (revision b70eb58b18e2937e6c694b5ef1ba2d284596bfac) @@ -0,0 +1,47 @@ +using System; +using Ringtoets.Piping.Calculation.SubCalculator; +using Ringtoets.Piping.Calculation.TestUtil.SubCalculator; + +namespace Ringtoets.Piping.Service.TestUtil +{ + /// + /// This class can be used to set a temporary + /// for while testing. + /// Disposing an instance of this class will revert the + /// . + /// + /// + /// The following is an example for how to use this class: + /// + /// using(new PipingCalculationServiceConfig()) { + /// var testFactory = (TestPipingSubCalculatorFactory) PipingCalculationService.SubCalculatorFactory; + /// + /// // Perform tests with testFactory + /// } + /// + /// + public class PipingCalculationServiceConfig : IDisposable + { + private readonly IPipingSubCalculatorFactory previousFactory; + + /// + /// Creates a new instance of . + /// Sets a to + /// + /// + public PipingCalculationServiceConfig() + { + previousFactory = PipingCalculationService.SubCalculatorFactory; + PipingCalculationService.SubCalculatorFactory = new TestPipingSubCalculatorFactory(); + } + + /// + /// Reverts the to the value + /// it had at time of construction of the . + /// + public void Dispose() + { + PipingCalculationService.SubCalculatorFactory = previousFactory; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil/Properties/AssemblyInfo.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil/Properties/AssemblyInfo.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil/Properties/AssemblyInfo.cs (revision b70eb58b18e2937e6c694b5ef1ba2d284596bfac) @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ringtoets.Piping.Service.TestUtil")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Ringtoets.Piping.Service.TestUtil")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("79bce67d-c659-4023-a0ee-073ca20622b7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil/Ringtoets.Piping.Service.TestUtil.csproj =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil/Ringtoets.Piping.Service.TestUtil.csproj (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.TestUtil/Ringtoets.Piping.Service.TestUtil.csproj (revision b70eb58b18e2937e6c694b5ef1ba2d284596bfac) @@ -0,0 +1,74 @@ + + + + + Debug + x86 + {C05B4F73-480E-46A4-B037-40954F8276DC} + Library + Properties + Ringtoets.Piping.Service.TestUtil + Ringtoets.Piping.Service.TestUtil + v4.0 + 512 + + + true + bin\Debug\ + 4 + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\Release\ + 4 + TRACE + true + none + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\ReleaseForCodeCoverage\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + + {D64E4F0E-E341-496F-82B2-941AD202B4E3} + Ringtoets.Piping.Calculation + + + {10B8D63D-87E8-46DF-ACA9-A8CF22EE8FB5} + Ringtoets.Piping.Service + + + {27E0A5C9-3ABF-426A-A3DA-7D0B83A218C8} + Ringtoets.Piping.Calculation.TestUtil + + + + + \ No newline at end of file