private static IEnumerable <TestCaseData> GetUnequalTestCases() { MacroStabilityInwardsSoilLayer2D baseLayer = CreateRandomLayer(21); yield return(new TestCaseData(new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing(30), baseLayer.Data, baseLayer.NestedLayers)) .SetName("OuterRing")); yield return(new TestCaseData(new MacroStabilityInwardsSoilLayer2D(baseLayer.OuterRing, new MacroStabilityInwardsSoilLayerData(), baseLayer.NestedLayers)) .SetName("Data")); yield return(new TestCaseData(new MacroStabilityInwardsSoilLayer2D(baseLayer.OuterRing, baseLayer.Data, new[] { baseLayer.NestedLayers.First(), new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing(21)) })) .SetName("Nested Layer Count")); yield return(new TestCaseData(new MacroStabilityInwardsSoilLayer2D(baseLayer.OuterRing, baseLayer.Data, new[] { new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing(30)) })) .SetName("Nested Layer content")); }
private static MacroStabilityInwardsSoilLayerTwoDEntity CreateMacroStabilityInwardsSoilLayerTwoDEntity() { var random = new Random(31); var entity = new MacroStabilityInwardsSoilLayerTwoDEntity { IsAquifer = Convert.ToByte(random.NextBoolean()), Color = Color.FromKnownColor(random.NextEnumValue <KnownColor>()).ToInt64(), MaterialName = random.Next().ToString(), AbovePhreaticLevelMean = random.NextDouble(2.0, 3.0), AbovePhreaticLevelCoefficientOfVariation = random.NextDouble(), AbovePhreaticLevelShift = random.NextDouble(0.0, 1.0), BelowPhreaticLevelMean = random.NextDouble(2.0, 3.0), BelowPhreaticLevelCoefficientOfVariation = random.NextDouble(), BelowPhreaticLevelShift = random.NextDouble(0.0, 1.0), CohesionMean = random.NextDouble(), CohesionCoefficientOfVariation = random.NextDouble(), FrictionAngleMean = random.NextDouble(), FrictionAngleCoefficientOfVariation = random.NextDouble(), ShearStrengthRatioMean = random.NextDouble(), ShearStrengthRatioCoefficientOfVariation = random.NextDouble(), StrengthIncreaseExponentMean = random.NextDouble(), StrengthIncreaseExponentCoefficientOfVariation = random.NextDouble(), PopMean = random.NextDouble(), PopCoefficientOfVariation = random.NextDouble(), OuterRingXml = new Point2DCollectionXmlSerializer().ToXml(RingTestFactory.CreateRandomRing().Points) }; return(entity); }
private static MacroStabilityInwardsSoilProfile2D CreateMacroStabilityInwardsSoilProfile2D(string name) { var layers = new Collection <MacroStabilityInwardsSoilLayer2D> { new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing()) }; return(new MacroStabilityInwardsSoilProfile2D(name, layers, Enumerable.Empty <MacroStabilityInwardsPreconsolidationStress>())); }
private static MacroStabilityInwardsSoilLayer2D CreateMacroStabilityInwardsSoilLayer2D() { var random = new Random(14); return(new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing()) { Data = { IsAquifer = random.NextBoolean(), MaterialName = "MaterialName", Color = Color.FromKnownColor(random.NextEnumValue <KnownColor>()), UsePop = random.NextBoolean(), ShearStrengthModel = random.NextEnumValue <MacroStabilityInwardsShearStrengthModel>(), AbovePhreaticLevel = { Mean = random.NextRoundedDouble(2.0, 3.0), CoefficientOfVariation = random.NextRoundedDouble(), Shift = random.NextRoundedDouble(0.0, 1.0) }, BelowPhreaticLevel = { Mean = random.NextRoundedDouble(2.0, 3.0), CoefficientOfVariation = random.NextRoundedDouble(), Shift = random.NextRoundedDouble(0.0, 1.0) }, Cohesion = { Mean = random.NextRoundedDouble(), CoefficientOfVariation = random.NextRoundedDouble() }, FrictionAngle = { Mean = random.NextRoundedDouble(), CoefficientOfVariation = random.NextRoundedDouble() }, StrengthIncreaseExponent = { Mean = random.NextRoundedDouble(), CoefficientOfVariation = random.NextRoundedDouble() }, ShearStrengthRatio = { Mean = random.NextRoundedDouble(), CoefficientOfVariation = random.NextRoundedDouble() }, Pop = { Mean = random.NextRoundedDouble(), CoefficientOfVariation = random.NextRoundedDouble() } } }); }
public void Constructor_WithOuterRing_ReturnsNewInstance() { // Setup Ring outerRing = RingTestFactory.CreateRandomRing(); // Call var layer = new MacroStabilityInwardsSoilLayer2D(outerRing); // Assert Assert.IsInstanceOf <IMacroStabilityInwardsSoilLayer>(layer); Assert.AreSame(outerRing, layer.OuterRing); Assert.IsNotNull(layer.Data); Assert.IsEmpty(layer.NestedLayers); }
private static MacroStabilityInwardsSoilLayer2D CreateRandomLayer(int randomSeed) { var random = new Random(randomSeed); return(new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing(randomSeed), new MacroStabilityInwardsSoilLayerData { Color = Color.FromKnownColor(random.NextEnumValue <KnownColor>()) }, new[] { new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing(randomSeed)) })); }
public void Constructor_NestedLayersNull_ThrowsArgumentNullException() { // Setup Ring outerRing = RingTestFactory.CreateRandomRing(); // Call void Call() => new MacroStabilityInwardsSoilLayer2D(outerRing, new MacroStabilityInwardsSoilLayerData(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("nestedLayers", exception.ParamName); }
public void Constructor_DataNull_ThrowsArgumentNullException() { // Setup Ring outerRing = RingTestFactory.CreateRandomRing(); // Call void Call() => new MacroStabilityInwardsSoilLayer2D(outerRing, null, Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>()); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("data", exception.ParamName); }
public void Constructor_WithOuterRingDataAndNestedLayers_ReturnsNewInstance() { // Setup Ring outerRing = RingTestFactory.CreateRandomRing(); var data = new MacroStabilityInwardsSoilLayerData(); IEnumerable <MacroStabilityInwardsSoilLayer2D> nestedLayers = Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>(); // Call var layer = new MacroStabilityInwardsSoilLayer2D(outerRing, data, nestedLayers); // Assert Assert.IsInstanceOf <IMacroStabilityInwardsSoilLayer>(layer); Assert.AreSame(outerRing, layer.OuterRing); Assert.AreSame(data, layer.Data); Assert.AreSame(nestedLayers, layer.NestedLayers); }
public void Create_StringPropertiesDoNotShareReference() { // Setup const string materialName = "MaterialName"; var soilLayer = new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing()) { Data = { MaterialName = materialName } }; // Call MacroStabilityInwardsSoilLayerTwoDEntity entity = soilLayer.Create(0); // Assert TestHelper.AssertAreEqualButNotSame(materialName, entity.MaterialName); }
public void Read_WithNullValues_ReturnsMacroStabilityInwardsSoilLayer2DWithNaNValues() { // Setup var entity = new MacroStabilityInwardsSoilLayerTwoDEntity { MaterialName = nameof(MacroStabilityInwardsSoilLayerTwoDEntity), OuterRingXml = new Point2DCollectionXmlSerializer().ToXml(RingTestFactory.CreateRandomRing().Points) }; // Call MacroStabilityInwardsSoilLayer2D layer = entity.Read(); // Assert Assert.IsNotNull(layer); MacroStabilityInwardsSoilLayerData data = layer.Data; Assert.AreEqual(entity.MaterialName, data.MaterialName); Assert.IsNaN(data.AbovePhreaticLevel.Mean); Assert.IsNaN(data.AbovePhreaticLevel.CoefficientOfVariation); Assert.IsNaN(data.AbovePhreaticLevel.Shift); Assert.IsNaN(data.BelowPhreaticLevel.Mean); Assert.IsNaN(data.BelowPhreaticLevel.CoefficientOfVariation); Assert.IsNaN(data.BelowPhreaticLevel.Shift); Assert.IsNaN(data.Cohesion.Mean); Assert.IsNaN(data.Cohesion.CoefficientOfVariation); Assert.IsNaN(data.FrictionAngle.Mean); Assert.IsNaN(data.FrictionAngle.CoefficientOfVariation); Assert.IsNaN(data.ShearStrengthRatio.Mean); Assert.IsNaN(data.ShearStrengthRatio.CoefficientOfVariation); Assert.IsNaN(data.StrengthIncreaseExponent.Mean); Assert.IsNaN(data.StrengthIncreaseExponent.CoefficientOfVariation); Assert.IsNaN(data.Pop.Mean); Assert.IsNaN(data.Pop.CoefficientOfVariation); }
public void Convert_ValidShearStrengthModel_ReturnExpectedShearStrengthModel(MacroStabilityInwardsShearStrengthModel originalShearStrengthModel, ShearStrengthModel expectedShearStrengthModel) { // Setup var profile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(new[] { new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing()) { Data = { ShearStrengthModel = originalShearStrengthModel } } }, new MacroStabilityInwardsPreconsolidationStress[0]); // Call SoilProfile soilProfile = SoilProfileConverter.Convert(profile); // Assert Assert.AreEqual(expectedShearStrengthModel, soilProfile.Layers.First().ShearStrengthModel); }
public void Convert_InvalidShearStrengthModel_ThrowInvalidEnumArgumentException() { // Setup var profile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(new[] { new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing()) { Data = { ShearStrengthModel = (MacroStabilityInwardsShearStrengthModel)99 } } }, new MacroStabilityInwardsPreconsolidationStress[0]); // Call TestDelegate test = () => SoilProfileConverter.Convert(profile); // Assert const string message = "The value of argument 'shearStrengthModel' (99) is invalid for Enum type 'MacroStabilityInwardsShearStrengthModel'."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(test, message); }
private static MacroStabilityInwardsSoilLayer2D CreateRandomSoilLayer(int seed, IEnumerable <MacroStabilityInwardsSoilLayer2D> nestedLayers) { return(new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing(seed), CreateRandomSoilLayerData(seed), nestedLayers)); }
public void Read_WithCollector_ReturnsSoilProfileWithPropertiesSet() { // Setup Ring outerRingA = RingTestFactory.CreateRandomRing(32); Ring outerRingB = RingTestFactory.CreateRandomRing(33); var random = new Random(31); var preconsolidationStressEntity = new MacroStabilityInwardsPreconsolidationStressEntity { CoordinateX = random.NextDouble(), CoordinateZ = random.NextDouble(), PreconsolidationStressMean = random.NextDouble(), PreconsolidationStressCoefficientOfVariation = random.NextDouble(), Order = 1 }; var point2DXmlSerializer = new Point2DCollectionXmlSerializer(); var entity = new MacroStabilityInwardsSoilProfileTwoDEntity { Name = nameof(MacroStabilityInwardsSoilProfileTwoDEntity), MacroStabilityInwardsSoilLayerTwoDEntities = { new MacroStabilityInwardsSoilLayerTwoDEntity { MaterialName = "A", OuterRingXml = point2DXmlSerializer.ToXml(outerRingA.Points), Order = 1 }, new MacroStabilityInwardsSoilLayerTwoDEntity { MaterialName = "B", OuterRingXml = point2DXmlSerializer.ToXml(outerRingB.Points), Order = 0 } }, MacroStabilityInwardsPreconsolidationStressEntities = { preconsolidationStressEntity, new MacroStabilityInwardsPreconsolidationStressEntity { Order = 0 } } }; var collector = new ReadConversionCollector(); // Call MacroStabilityInwardsSoilProfile2D profile = entity.Read(collector); // Assert Assert.IsNotNull(profile); Assert.AreEqual(entity.Name, profile.Name); CollectionAssert.AreEqual(new[] { "B", "A" }, profile.Layers.Select(l => l.Data.MaterialName)); CollectionAssert.AreEqual(new[] { outerRingB, outerRingA }, profile.Layers.Select(l => l.OuterRing)); profile.Layers.Select(l => l.NestedLayers).ForEachElementDo(CollectionAssert.IsEmpty); CollectionAssert.AreEqual(new[] { new MacroStabilityInwardsPreconsolidationStress(new Point2D(0, 0), new VariationCoefficientLogNormalDistribution { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }), new MacroStabilityInwardsPreconsolidationStress(new Point2D(preconsolidationStressEntity.CoordinateX, preconsolidationStressEntity.CoordinateZ), new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble)preconsolidationStressEntity.PreconsolidationStressMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)preconsolidationStressEntity.PreconsolidationStressCoefficientOfVariation.ToNullAsNaN() }) }, profile.PreconsolidationStresses); }
public void Create_WithNaNProperties_ReturnsEntityWithPropertiesSetToNull() { // Setup var soilLayer = new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing()) { Data = { AbovePhreaticLevel = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN, Shift = RoundedDouble.NaN }, BelowPhreaticLevel = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN, Shift = RoundedDouble.NaN }, Cohesion = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, FrictionAngle = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, ShearStrengthRatio = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, StrengthIncreaseExponent = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, Pop = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN } } }; // Call MacroStabilityInwardsSoilLayerTwoDEntity entity = soilLayer.Create(0); // Assert Assert.IsNotNull(entity); Assert.IsNull(entity.AbovePhreaticLevelMean); Assert.IsNull(entity.AbovePhreaticLevelCoefficientOfVariation); Assert.IsNull(entity.AbovePhreaticLevelShift); Assert.IsNull(entity.BelowPhreaticLevelMean); Assert.IsNull(entity.BelowPhreaticLevelCoefficientOfVariation); Assert.IsNull(entity.BelowPhreaticLevelShift); Assert.IsNull(entity.CohesionMean); Assert.IsNull(entity.CohesionCoefficientOfVariation); Assert.IsNull(entity.FrictionAngleMean); Assert.IsNull(entity.FrictionAngleCoefficientOfVariation); Assert.IsNull(entity.ShearStrengthRatioMean); Assert.IsNull(entity.ShearStrengthRatioCoefficientOfVariation); Assert.IsNull(entity.StrengthIncreaseExponentMean); Assert.IsNull(entity.StrengthIncreaseExponentCoefficientOfVariation); Assert.IsNull(entity.PopMean); Assert.IsNull(entity.PopCoefficientOfVariation); }