Index: DamClients/DamUI/trunk/src/Dam/Tests/DamEngineIo/FillXmlInputFromDamUiTests.cs =================================================================== diff -u -r2614 -r2615 --- DamClients/DamUI/trunk/src/Dam/Tests/DamEngineIo/FillXmlInputFromDamUiTests.cs (.../FillXmlInputFromDamUiTests.cs) (revision 2614) +++ DamClients/DamUI/trunk/src/Dam/Tests/DamEngineIo/FillXmlInputFromDamUiTests.cs (.../FillXmlInputFromDamUiTests.cs) (revision 2615) @@ -606,85 +606,44 @@ } [Test] - [ExpectedException(typeof(NullReferenceException), ExpectedMessage = "Location 'Location 1', scenario '1' has no river level")] public void RaiseExceptionWhenRiverLevelIsMissing() { // Given DataSet with undefined RiverLevel DamProjectData expectedDamProjectData = CreateExampleDamProjectData(); var scenario = expectedDamProjectData.WaterBoard.Dikes[0].Locations[0].Scenarios[0]; scenario.RiverLevel = null; - // When Writing Xml - Input input = FillXmlInputFromDamUi.CreateInput(expectedDamProjectData); - string xmlString = DamXmlSerialization.SaveInputAsXmlString(input); - - // Then Raise Exception With Clear Message() - input = DamXmlSerialization.LoadInputFromXmlString(xmlString); - DamProjectData actualDamProjectData = FillDamUiFromXmlInput.CreateDamProjectData(input); - CompareDamProjectData(actualDamProjectData, expectedDamProjectData); + // When Writing Xml, Then Raise Exception With Clear Message + var expectedMessage = "Location 'Location 1', scenario '1' has no river level"; + Assert.That(() => FillXmlInputFromDamUi.CreateInput(expectedDamProjectData), Throws.TypeOf(typeof(NullReferenceException)).With.Message.EqualTo(expectedMessage)); } [Test] - [TestCase(FailureMechanismSystemType.StabilityOutside)] - [ExpectedException(typeof(NullReferenceException), ExpectedMessage = "Location 'Location 1', scenario '1' has no river level low")] - public void RaiseExceptionWhenRiverLevelLowIsMissingForStabilityOutside(FailureMechanismSystemType failureMechanismSystemType) + [TestCase(FailureMechanismSystemType.StabilityOutside, "Location 'Location 1', scenario '1' has no river level low")] + [TestCase(FailureMechanismSystemType.StabilityInside, "")] + [TestCase(FailureMechanismSystemType.HorizontalBalance, "")] + [TestCase(FailureMechanismSystemType.FlowSlide, "")] + [TestCase(FailureMechanismSystemType.Piping, "")] + public void RaiseExceptionWhenRiverLevelLowIsMissingForStabilityOutside(FailureMechanismSystemType failureMechanismSystemType, string expectedMessage) { - // Given DataSet with undefined RiverLevelLow, for stability outside + // Given DataSet with undefined RiverLevelLow DamProjectData expectedDamProjectData = CreateExampleDamProjectData(); var scenario = expectedDamProjectData.WaterBoard.Dikes[0].Locations[0].Scenarios[0]; scenario.RiverLevelLow = null; var currentSpecification = expectedDamProjectData.DamProjectCalculationSpecification.CurrentSpecification; currentSpecification.FailureMechanismSystemType = failureMechanismSystemType; - // First set PipingModelType to default because it will be set to default when reading the xml back when FailureMechanismSystemType is not Piping - currentSpecification.PipingModelType = PipingModelType.Sellmeijer4Forces; - // Next line sets the CalculationModel to Bishop as well - currentSpecification.StabilityModelType = MStabModelType.Bishop; - // When Writing Xml - Input input = FillXmlInputFromDamUi.CreateInput(expectedDamProjectData); - string xmlString = DamXmlSerialization.SaveInputAsXmlString(input); - - // Then Raise Exception With Clear Message() - input = DamXmlSerialization.LoadInputFromXmlString(xmlString); - DamProjectData actualDamProjectData = FillDamUiFromXmlInput.CreateDamProjectData(input); - CompareDamProjectData(actualDamProjectData, expectedDamProjectData); - } - - [Test] - [TestCase(FailureMechanismSystemType.StabilityInside)] - [TestCase(FailureMechanismSystemType.HorizontalBalance)] - [TestCase(FailureMechanismSystemType.FlowSlide)] - [TestCase(FailureMechanismSystemType.Piping)] - public void DoNotRaiseExceptionWhenRiverLevelLowIsMissingForOtherTypeThanStabilityOutside(FailureMechanismSystemType failureMechanismSystemType) - { - // Given DataSet with undefined RiverLevelLow, for stability inside / horizontal balance / flow slide - DamProjectData expectedDamProjectData = CreateExampleDamProjectData(); - var scenario = expectedDamProjectData.WaterBoard.Dikes[0].Locations[0].Scenarios[0]; - scenario.RiverLevelLow = null; - var currentSpecification = expectedDamProjectData.DamProjectCalculationSpecification.CurrentSpecification; - currentSpecification.FailureMechanismSystemType = failureMechanismSystemType; - // First set PipingModelType to default because it will be set to default when reading the xml back when FailureMechanismSystemType is not Piping - currentSpecification.PipingModelType = PipingModelType.Sellmeijer4Forces; - // First set StabilityModelType to default because it will be set to default when reading the xml back when FailureMechanismSystemType is not Stability - currentSpecification.StabilityModelType = MStabModelType.Bishop; - if (failureMechanismSystemType == FailureMechanismSystemType.Piping) + // When Writing Xml, Then Raise Exception With Clear Message in case of Stability Outside + if (expectedMessage != string.Empty) { - currentSpecification.CalculationModel = currentSpecification.PipingModelType; + Assert.That(() => FillXmlInputFromDamUi.CreateInput(expectedDamProjectData), Throws.TypeOf(typeof(NullReferenceException)).With.Message.EqualTo(expectedMessage)); } else { - currentSpecification.CalculationModel = currentSpecification.StabilityModelType; + Assert.That(() => FillXmlInputFromDamUi.CreateInput(expectedDamProjectData), Throws.Nothing); } - - // When Writing Xml - Input input = FillXmlInputFromDamUi.CreateInput(expectedDamProjectData); - string xmlString = DamXmlSerialization.SaveInputAsXmlString(input); - - // Then Raise Exception With Clear Message() - input = DamXmlSerialization.LoadInputFromXmlString(xmlString); - DamProjectData actualDamProjectData = FillDamUiFromXmlInput.CreateDamProjectData(input); - CompareDamProjectData(actualDamProjectData, expectedDamProjectData); } + } }