Index: DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/DikeTest.cs =================================================================== diff -u -r6436 -r6776 --- DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/DikeTest.cs (.../DikeTest.cs) (revision 6436) +++ DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/DikeTest.cs (.../DikeTest.cs) (revision 6776) @@ -63,13 +63,16 @@ { Name = "Segment1" }; - // this.dike.Segments.Add(this.segment1); // Locations location1 = new Location(); location1.Name = "Location1"; location1.Segment = segment1; dike.Locations.Add(location1); + + // Soil lists + dike.SoilList = new SoilList(); + dike.DamSoils = []; // Surface lines surfaceLine1 = new SurfaceLine2 @@ -131,9 +134,12 @@ // call using (var newDike = new Dike()) { - // assert - Assert.That(newDike.SurfaceLines2.Count, Is.EqualTo(0)); - Assert.That(newDike.Locations.Count, Is.EqualTo(0)); + Assert.Multiple(() => + { + // assert + Assert.That(newDike.SurfaceLines2, Is.Empty); + Assert.That(newDike.Locations, Is.Empty); + }); } } @@ -142,53 +148,62 @@ { Assert.That(dike, Is.Not.Null); - Assert.That(dike.Name, Is.EqualTo("Dike")); - //Assert.IsNotNull(this.dike.Segments); - Assert.That(dike.Locations, Is.Not.Null); - Assert.That(dike.SurfaceLines2, Is.Not.Null); - Assert.That(dike.SoilProfiles, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(dike.Name, Is.EqualTo("Dike")); + Assert.That(dike.Locations, Is.Not.Null); + Assert.That(dike.SurfaceLines2, Is.Not.Null); + Assert.That(dike.SoilProfiles, Is.Not.Null); + }); } -// [Test] -// public void TestDikeSegments() -// { -// Assert.IsNotNull(this.segment1); -// -// Assert.AreEqual(1, this.dike.Segments.Count); -// Assert.AreEqual(this.segment1, this.dike.Segments[0]); -// Assert.AreEqual("Segment1", this.segment1.Name); -// Assert.IsNotNull(this.segment1.GetMostProbableProfile(SegmentFailureMechanismType.Stability)); -// } - [Test] public void TestDikeLocations() { - Assert.That(location1, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(location1, Is.Not.Null); - Assert.That(dike.Locations.Count, Is.EqualTo(1)); - Assert.That(dike.Locations[0], Is.EqualTo(location1)); - Assert.That(location1.Name, Is.EqualTo("Location1")); + Assert.That(dike.Locations, Has.Count.EqualTo(1)); + }); + Assert.Multiple(() => + { + Assert.That(dike.Locations[0], Is.EqualTo(location1)); + Assert.That(location1.Name, Is.EqualTo("Location1")); + }); } [Test] public void TestDikeSurfaceLines() { Assert.That(surfaceLine1, Is.Not.Null); - Assert.That(surfaceLine1.Geometry.Points, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(surfaceLine1.Geometry.Points, Is.Not.Null); - Assert.That(dike.SurfaceLines2.Count, Is.EqualTo(1)); - Assert.That(dike.SurfaceLines2[0], Is.EqualTo(surfaceLine1)); - Assert.That(surfaceLine1.Name, Is.EqualTo("SurfaceLine1")); + Assert.That(dike.SurfaceLines2, Has.Count.EqualTo(1)); + }); + Assert.Multiple(() => + { + Assert.That(dike.SurfaceLines2[0], Is.EqualTo(surfaceLine1)); + Assert.That(surfaceLine1.Name, Is.EqualTo("SurfaceLine1")); + }); } [Test] public void TestDikeSoilProfiles() { - Assert.That(soilProfile, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(soilProfile, Is.Not.Null); - Assert.That(dike.SoilProfiles.Count, Is.EqualTo(1)); - Assert.That(dike.SoilProfiles[0], Is.EqualTo(soilProfile)); - Assert.That(soilProfile.Name, Is.EqualTo("SoilProfile1")); + Assert.That(dike.SoilProfiles, Has.Count.EqualTo(1)); + }); + Assert.Multiple(() => + { + Assert.That(dike.SoilProfiles[0], Is.EqualTo(soilProfile)); + Assert.That(soilProfile.Name, Is.EqualTo("SoilProfile1")); + }); } [Test] @@ -215,35 +230,39 @@ public void TestDikeSegmentsSurfaceLinePoints() { IList points = surfaceLine1.Geometry.Points; - Assert.That(points.Count, Is.EqualTo(6)); + Assert.That(points, Has.Count.EqualTo(6)); - Assert.That(points[0].X, Is.EqualTo(15.3)); - Assert.That(points[0].Z, Is.EqualTo(-3.52)); - Assert.That(points[1].X, Is.EqualTo(19.4)); - Assert.That(points[1].Z, Is.EqualTo(-1.46)); + Assert.Multiple(() => + { + Assert.That(points[0].X, Is.EqualTo(15.3)); + Assert.That(points[0].Z, Is.EqualTo(-3.52)); + Assert.That(points[1].X, Is.EqualTo(19.4)); + Assert.That(points[1].Z, Is.EqualTo(-1.46)); - Assert.That(surfaceLine1.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver), Is.EqualTo(points[1])); - Assert.That(surfaceLine1.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver), Is.EqualTo(points[2])); - Assert.That(surfaceLine1.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtPolder), Is.EqualTo(points[3])); - Assert.That(surfaceLine1.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder), Is.EqualTo(points[4])); + Assert.That(surfaceLine1.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver), Is.EqualTo(points[1])); + Assert.That(surfaceLine1.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver), Is.EqualTo(points[2])); + Assert.That(surfaceLine1.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtPolder), Is.EqualTo(points[3])); + Assert.That(surfaceLine1.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder), Is.EqualTo(points[4])); - Assert.That(surfaceLine1.GetCharacteristicPoints(points[0]).Count(cpt => cpt != CharacteristicPointType.None), Is.EqualTo(0)); - Assert.That(surfaceLine1.GetCharacteristicPoints(points[1]).First(), Is.EqualTo(CharacteristicPointType.DikeToeAtRiver)); + Assert.That(surfaceLine1.GetCharacteristicPoints(points[0]).Count(cpt => cpt != CharacteristicPointType.None), Is.EqualTo(0)); + Assert.That(surfaceLine1.GetCharacteristicPoints(points[1]).First(), Is.EqualTo(CharacteristicPointType.DikeToeAtRiver)); - Assert.That(surfaceLine1.HasDike(), Is.True); + Assert.That(surfaceLine1.HasDike(), Is.True); + }); } [Test] public void TestFillImportedCsvSoilsFromCsvFileWithoutSoilRecords_ThenNoDataBaseSoilsArePresent() { var newDike = new Dike(); newDike.FillImportedCsvSoilsFromCsvFile(new List()); - Assert.That(newDike.ImportedCsvSoils.Count, Is.Zero); + Assert.That(newDike.ImportedCsvSoils, Is.Empty); } [Test] public void TestFillImportedCsvSoilsFromCsvFileWithSoilRecords_ThenDataBaseSoilsAreFilled() { + const double percentageToFraction = 0.01; var newDike = new Dike(); var random = new Random(21); @@ -263,7 +282,8 @@ ShearStrengthModel = ShearStrengthModel.CPhi, StrengthIncreaseExponent = random.NextDouble(), RatioSuPc = random.NextDouble(), - Pop = random.NextDouble() + Pop = random.NextDouble(), + TrafficLoadDegreeOfConsolidation = random.NextDouble() }, new() { @@ -279,30 +299,82 @@ ShearStrengthModel = ShearStrengthModel.CuCalculated, StrengthIncreaseExponent = random.NextDouble(), RatioSuPc = random.NextDouble(), - Pop = random.NextDouble() + Pop = random.NextDouble(), + TrafficLoadDegreeOfConsolidation = random.NextDouble() } }; newDike.FillImportedCsvSoilsFromCsvFile(soilRecords); - Assert.That(newDike.ImportedCsvSoils.Count, Is.EqualTo(2)); + Assert.That(newDike.ImportedCsvSoils, Has.Count.EqualTo(2)); for (var i = 0; i < newDike.ImportedCsvSoils.Count; i++) { - Soil soil = newDike.ImportedCsvSoils[i]; + DamSoil soil = newDike.ImportedCsvSoils[i]; CsvImporterSoils.SoilRecord soilRecord = soilRecords[i]; - Assert.That(soil.Name, Is.EqualTo(soilRecord.SoilName)); - Assert.That(soil.Color, Is.EqualTo(soilRecord.SoilColor)); - Assert.That(soil.SoilType, Is.EqualTo(soilRecord.SoilType)); - Assert.That(soil.AbovePhreaticLevel, Is.EqualTo(soilRecord.UnsaturatedUnitWeight)); - Assert.That(soil.BelowPhreaticLevel, Is.EqualTo(soilRecord.SaturatedUnitWeight)); - Assert.That(soil.Cohesion, Is.EqualTo(soilRecord.Cohesion)); - Assert.That(soil.FrictionAngle, Is.EqualTo(soilRecord.FrictionAngle)); - Assert.That(soil.DiameterD70, Is.EqualTo(soilRecord.DiameterD70)); - Assert.That(soil.PermeabKx, Is.EqualTo(soilRecord.PermeabilityX)); - Assert.That(soil.ShearStrengthModel, Is.EqualTo(soilRecord.ShearStrengthModel)); - Assert.That(soil.StrengthIncreaseExponent, Is.EqualTo(soilRecord.StrengthIncreaseExponent)); - Assert.That(soil.RatioCuPc, Is.EqualTo(soilRecord.RatioSuPc)); - Assert.That(soil.POP, Is.EqualTo(soilRecord.Pop)); + Assert.Multiple(() => + { + Assert.That(soil.Name, Is.EqualTo(soilRecord.SoilName)); + Assert.That(soil.Color, Is.EqualTo(soilRecord.SoilColor)); + Assert.That(soil.SoilType, Is.EqualTo(soilRecord.SoilType)); + Assert.That(soil.AbovePhreaticLevel, Is.EqualTo(soilRecord.UnsaturatedUnitWeight)); + Assert.That(soil.BelowPhreaticLevel, Is.EqualTo(soilRecord.SaturatedUnitWeight)); + Assert.That(soil.Cohesion, Is.EqualTo(soilRecord.Cohesion)); + Assert.That(soil.FrictionAngle, Is.EqualTo(soilRecord.FrictionAngle)); + Assert.That(soil.DiameterD70, Is.EqualTo(soilRecord.DiameterD70)); + Assert.That(soil.PermeabKx, Is.EqualTo(soilRecord.PermeabilityX)); + Assert.That(soil.ShearStrengthModel, Is.EqualTo(soilRecord.ShearStrengthModel)); + Assert.That(soil.StrengthIncreaseExponent, Is.EqualTo(soilRecord.StrengthIncreaseExponent)); + Assert.That(soil.RatioCuPc, Is.EqualTo(soilRecord.RatioSuPc)); + Assert.That(soil.POP, Is.EqualTo(soilRecord.Pop)); + Assert.That(soil.TrafficLoadDegreeOfConsolidation, Is.EqualTo(soilRecord.TrafficLoadDegreeOfConsolidation * percentageToFraction)); + }); } } + + [Test] + public void GivenDamSoil_WhenAddingIt_ThenIsPresentInBothSoilLists() + { + var soil1 = new DamSoil(); + var soil2 = new DamSoil(); + + dike.AddDamSoil(soil1); + dike.AddDamSoil(soil2); + + Assert.Multiple(() => + { + Assert.That(dike.SoilList.Soils, Has.Count.EqualTo(2)); + Assert.That(dike.DamSoils, Has.Count.EqualTo(2)); + }); + Assert.Multiple(() => + { + Assert.That(dike.SoilList.Soils[0], Is.EqualTo(soil1)); + Assert.That(dike.SoilList.Soils[1], Is.EqualTo(soil2)); + Assert.That(dike.DamSoils[0], Is.EqualTo(soil1)); + Assert.That(dike.DamSoils[1], Is.EqualTo(soil2)); + }); + } + + [Test] + public void GivenDamSoil_WhenRemovingIt_ThenIsRemovedFromBothSoilLists() + { + var soil1 = new DamSoil(); + var soil2 = new DamSoil(); + dike.SoilList.Clear(); + dike.DamSoils.Clear(); + dike.AddDamSoil(soil1); + dike.AddDamSoil(soil2); + + dike.RemoveDamSoil(soil2); + + Assert.Multiple(() => + { + Assert.That(dike.SoilList.Soils, Has.Count.EqualTo(1)); + Assert.That(dike.DamSoils, Has.Count.EqualTo(1)); + }); + Assert.Multiple(() => + { + Assert.That(dike.SoilList.Soils[0], Is.EqualTo(soil1)); + Assert.That(dike.DamSoils[0], Is.EqualTo(soil1)); + }); + } } \ No newline at end of file