using System.Collections.Generic; using System.IO; using Deltares.Dam.Data; using Deltares.Standard; using Deltares.Standard.EventPublisher; using Deltares.Standard.TestUtils; using NUnit.Framework; namespace Deltares.Dam.Tests { [TestFixture] public class DamCalculationWtiComparisonTests { private TextWriter textWriter; [TestFixtureSetUp] public void TestFixtureSetup() { ComparisonTestRunner.Tolerances = new DamIntegrationTestTolerance(); ComparisonTestRunner.DataPath = ComparisonTestRunner.GetDataPath(); ComparisonTestRunner.PropertiesToCheck = new[] { "SafetyFactor", "Zone1EntryPointX", "Zone1EntryPointZ", "Zone1ExitPointX", "Zone1ExitPointZ" }; ComparisonTestRunner.DamWtiTestReportsDir= Path.Combine(ComparisonTestRunner.GetBinReleasePath(), "DamWtiBenchmarkTestReports"); string wtiDamComparisonTxTFullPath = Path.Combine(ComparisonTestRunner.DamWtiTestReportsDir,"wti_dam_comparison.txt"); if (File.Exists(wtiDamComparisonTxTFullPath)) { File.Delete(wtiDamComparisonTxTFullPath); } textWriter = new StreamWriter(wtiDamComparisonTxTFullPath, true); } [TestFixtureTearDown] public void TearDown() { textWriter.Flush(); textWriter.Dispose(); textWriter = null; } [Test, Ignore("Use this for comparing kernels")] public void CompareTutorialDesign() { Parallel.Abort(); // Select which kernels to calculate var kernelsToCalculate = new List() { //StabilityKernelType.DamClassic, //StabilityKernelType.DamClassicDotNet, StabilityKernelType.DamClassicWti }; string projectFilename = Path.Combine(ComparisonTestRunner.DataPath, @"DAM\Benchmarks\KernelComparison\Dam Tutorial Design\DAM Tutorial Design.damx"); Assert.IsTrue(File.Exists(projectFilename), "Projectfile exists"); var runner = new ComparisonTestRunner(); // Define which locations to calculate; if locationIds == null then all locations will be calculated var locationIds = new List { "DWP_1", "DWP_9" }; // Just calculate 2 locations DataEventPublisher.InvokeWithoutPublishingEvents(() => { List testMessagesNotOk = runner.RunStabilityComparisonTest(projectFilename, locationIds, kernelsToCalculate, textWriter); Assert.AreEqual(10, testMessagesNotOk.Count, "One or more comparison tests failed."); }); } [Test, Category(Categories.Slow)] public void CompareWtiTestBench() { Parallel.Abort(); var kernelsToCalculate = new List() { //StabilityKernelType.DamClassic, //StabilityKernelType.DamClassicDotNet, StabilityKernelType.DamClassicWti }; string projectFilename = Path.Combine(ComparisonTestRunner.DataPath, @"DAM\Benchmarks\KernelComparison\WTITestbench\03 Mean (marine undrained) - 2014.damx"); Assert.IsTrue(File.Exists(projectFilename), "Projectfile exists"); var runner = new ComparisonTestRunner(); var locationIds = new List { "16_AW184_191" }; // Just calculate 2 locations //locationIds = null; // Force all locations to be calculated (comment this line out to calculate just the above specified 2 locations) DataEventPublisher.InvokeWithoutPublishingEvents(() => { List testMessagesNotOk = runner.RunStabilityComparisonTest(projectFilename, locationIds, kernelsToCalculate, textWriter); // Assert.AreEqual(10, testMessagesNotOk.Count, "One or more comparison tests failed."); }); } } }