Exemple #1
0
        public void Clone_Always_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            var random       = new Random(21);
            var slidingCurve = new MacroStabilityInwardsSlidingCurve(MacroStabilityInwardsSlidingCircleTestFactory.Create(),
                                                                     MacroStabilityInwardsSlidingCircleTestFactory.Create(),
                                                                     new[]
            {
                MacroStabilityInwardsSliceTestFactory.CreateSlice()
            },
                                                                     random.NextDouble(),
                                                                     random.NextDouble());

            var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(MacroStabilityInwardsGridTestFactory.Create(),
                                                                        MacroStabilityInwardsGridTestFactory.Create(),
                                                                        new[]
            {
                random.NextRoundedDouble()
            });

            var properties = new MacroStabilityInwardsOutput.ConstructionProperties
            {
                FactorOfStability       = random.NextDouble(),
                ForbiddenZonesXEntryMin = random.NextDouble(),
                ForbiddenZonesXEntryMax = random.NextDouble()
            };

            var original = new MacroStabilityInwardsOutput(slidingCurve, slipPlane, properties);

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, MacroStabilityInwardsCloneAssert.AreClones);
        }
Exemple #2
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var random = new Random(21);
            MacroStabilityInwardsSlidingCircle rightCircle = MacroStabilityInwardsSlidingCircleTestFactory.Create();
            MacroStabilityInwardsSlidingCircle leftCircle  = MacroStabilityInwardsSlidingCircleTestFactory.Create();

            MacroStabilityInwardsSlice[] slices =
            {
                MacroStabilityInwardsSliceTestFactory.CreateSlice()
            };

            double nonIteratedHorizontalForce = random.NextDouble();
            double iteratedHorizontalForce    = random.NextDouble();

            // Call
            var curve = new MacroStabilityInwardsSlidingCurve(leftCircle, rightCircle, slices, nonIteratedHorizontalForce, iteratedHorizontalForce);

            // Assert
            Assert.IsInstanceOf <ICloneable>(curve);

            Assert.AreSame(leftCircle, curve.LeftCircle);
            Assert.AreSame(rightCircle, curve.RightCircle);
            Assert.AreEqual(nonIteratedHorizontalForce, curve.NonIteratedHorizontalForce);
            Assert.AreEqual(iteratedHorizontalForce, curve.IteratedHorizontalForce);
            Assert.AreSame(slices, curve.Slices);
        }
        public void Read_EntityWithValues_ReturnExpectedOutput()
        {
            // Setup
            var random = new Random(21);
            IEnumerable <MacroStabilityInwardsSlice> slices = new[]
            {
                MacroStabilityInwardsSliceTestFactory.CreateSlice()
            };
            IEnumerable <RoundedDouble> tangentLines = new[]
            {
                new RoundedDouble(2, random.NextDouble())
            };

            var entity = new MacroStabilityInwardsCalculationOutputEntity
            {
                FactorOfStability       = random.NextDouble(),
                ForbiddenZonesXEntryMin = random.NextDouble(),
                ForbiddenZonesXEntryMax = random.NextDouble(),
                SlidingCurveSliceXML    = new MacroStabilityInwardsSliceCollectionXmlSerializer().ToXml(slices),
                SlidingCurveNonIteratedHorizontalForce         = random.NextDouble(),
                SlidingCurveIteratedHorizontalForce            = random.NextDouble(),
                SlidingCurveLeftSlidingCircleCenterX           = random.NextDouble(),
                SlidingCurveLeftSlidingCircleCenterY           = random.NextDouble(),
                SlidingCurveLeftSlidingCircleRadius            = random.NextDouble(),
                SlidingCurveLeftSlidingCircleIsActive          = Convert.ToByte(random.NextBoolean()),
                SlidingCurveLeftSlidingCircleNonIteratedForce  = random.NextDouble(),
                SlidingCurveLeftSlidingCircleIteratedForce     = random.NextDouble(),
                SlidingCurveLeftSlidingCircleDrivingMoment     = random.NextDouble(),
                SlidingCurveLeftSlidingCircleResistingMoment   = random.NextDouble(),
                SlidingCurveRightSlidingCircleCenterX          = random.NextDouble(),
                SlidingCurveRightSlidingCircleCenterY          = random.NextDouble(),
                SlidingCurveRightSlidingCircleRadius           = random.NextDouble(),
                SlidingCurveRightSlidingCircleIsActive         = Convert.ToByte(random.NextBoolean()),
                SlidingCurveRightSlidingCircleNonIteratedForce = random.NextDouble(),
                SlidingCurveRightSlidingCircleIteratedForce    = random.NextDouble(),
                SlidingCurveRightSlidingCircleDrivingMoment    = random.NextDouble(),
                SlidingCurveRightSlidingCircleResistingMoment  = random.NextDouble(),
                SlipPlaneTangentLinesXml = new TangentLineCollectionXmlSerializer().ToXml(tangentLines),
                SlipPlaneLeftGridXLeft   = random.NextDouble(0.0, 1.0),
                SlipPlaneLeftGridXRight  = random.NextDouble(2.0, 3.0),
                SlipPlaneLeftGridNrOfHorizontalPoints = random.Next(1, 100),
                SlipPlaneLeftGridZTop                  = random.NextDouble(2.0, 3.0),
                SlipPlaneLeftGridZBottom               = random.NextDouble(0.0, 1.0),
                SlipPlaneLeftGridNrOfVerticalPoints    = random.Next(1, 100),
                SlipPlaneRightGridXLeft                = random.NextDouble(0.0, 1.0),
                SlipPlaneRightGridXRight               = random.NextDouble(2.0, 3.0),
                SlipPlaneRightGridNrOfHorizontalPoints = random.Next(1, 100),
                SlipPlaneRightGridZTop                 = random.NextDouble(2.0, 3.0),
                SlipPlaneRightGridZBottom              = random.NextDouble(0.0, 1.0),
                SlipPlaneRightGridNrOfVerticalPoints   = random.Next(1, 100)
            };

            // Call
            MacroStabilityInwardsOutput output = entity.Read();

            // Assert
            MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(output, entity);
        }
Exemple #4
0
        public void Clone_Always_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            var random = new Random(21);
            MacroStabilityInwardsSlidingCircle rightCircle = MacroStabilityInwardsSlidingCircleTestFactory.Create();
            MacroStabilityInwardsSlidingCircle leftCircle  = MacroStabilityInwardsSlidingCircleTestFactory.Create();

            MacroStabilityInwardsSlice[] slices =
            {
                MacroStabilityInwardsSliceTestFactory.CreateSlice()
            };
            var original = new MacroStabilityInwardsSlidingCurve(leftCircle, rightCircle, slices, random.NextDouble(), random.NextDouble());

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, MacroStabilityInwardsCloneAssert.AreClones);
        }
        public void SetData_NoDataAlreadySet_SetNewData()
        {
            // Setup
            using (var table = new MacroStabilityInwardsSlicesTable())
            {
                MacroStabilityInwardsSlice[] slices =
                {
                    MacroStabilityInwardsSliceTestFactory.CreateSlice(),
                    MacroStabilityInwardsSliceTestFactory.CreateSlice(),
                    MacroStabilityInwardsSliceTestFactory.CreateSlice()
                };

                // Call
                table.SetData(slices);

                // Assert
                Assert.AreEqual(slices.Length, table.Rows.Count);
            }
        }
        public void SetData_SetNullDataAfterDataAlreadySet_ClearsData()
        {
            // Setup
            using (var table = new MacroStabilityInwardsSlicesTable())
            {
                MacroStabilityInwardsSlice[] slices =
                {
                    MacroStabilityInwardsSliceTestFactory.CreateSlice(),
                    MacroStabilityInwardsSliceTestFactory.CreateSlice(),
                    MacroStabilityInwardsSliceTestFactory.CreateSlice()
                };
                table.SetData(slices);

                // Call
                table.SetData(null);

                // Assert
                Assert.AreEqual(0, table.Rows.Count);
            }
        }
        public void Create_WithValidValues_ReturnsEntityWithExpectedPropertiesSet()
        {
            // Setup
            var random = new Random(21);

            MacroStabilityInwardsSlidingCircle leftCircle = CreateSlidingCircle(13);
            MacroStabilityInwardsSlidingCircle rightCircle = CreateSlidingCircle(34);
            IEnumerable<MacroStabilityInwardsSlice> slices = new[]
            {
                MacroStabilityInwardsSliceTestFactory.CreateSlice()
            };
            var slidingCurve = new MacroStabilityInwardsSlidingCurve(leftCircle,
                                                                     rightCircle,
                                                                     slices,
                                                                     random.NextDouble(),
                                                                     random.NextDouble());

            MacroStabilityInwardsGrid leftGrid = MacroStabilityInwardsGridTestFactory.Create();
            MacroStabilityInwardsGrid rightGrid = MacroStabilityInwardsGridTestFactory.Create();
            RoundedDouble[] tangentLines =
            {
                random.NextRoundedDouble()
            };
            var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(leftGrid, rightGrid, tangentLines);

            var output = new MacroStabilityInwardsOutput(slidingCurve, slipPlane, new MacroStabilityInwardsOutput.ConstructionProperties
            {
                FactorOfStability = random.NextDouble(),
                ForbiddenZonesXEntryMax = random.NextDouble(),
                ForbiddenZonesXEntryMin = random.NextDouble()
            });

            // Call
            MacroStabilityInwardsCalculationOutputEntity entity = output.Create();

            // Assert
            Assert.IsNotNull(entity);
            MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(output, entity);
        }
        public void SetData_SetNewDataAfterDataAlreadySet_ClearDataAndAddNewData()
        {
            // Setup
            using (var table = new MacroStabilityInwardsSlicesTable())
            {
                table.SetData(new[]
                {
                    MacroStabilityInwardsSliceTestFactory.CreateSlice()
                });

                MacroStabilityInwardsSlice[] newSlices =
                {
                    MacroStabilityInwardsSliceTestFactory.CreateSlice(),
                    MacroStabilityInwardsSliceTestFactory.CreateSlice(),
                    MacroStabilityInwardsSliceTestFactory.CreateSlice()
                };

                // Call
                table.SetData(newSlices);

                // Assert
                Assert.AreEqual(newSlices.Length, table.Rows.Count);
            }
        }
        public void SetData_WithData_ExpectedValuesInTable()
        {
            // Setup
            using (var table = new MacroStabilityInwardsSlicesTable())
            {
                MacroStabilityInwardsSlice[] slices =
                {
                    MacroStabilityInwardsSliceTestFactory.CreateSlice(),
                    MacroStabilityInwardsSliceTestFactory.CreateSlice(),
                    MacroStabilityInwardsSliceTestFactory.CreateSlice()
                };

                // Call
                table.SetData(slices);

                // Assert
                Assert.AreEqual(slices.Length, table.Rows.Count);
                for (var i = 0; i < table.Rows.Count; i++)
                {
                    MacroStabilityInwardsSlice slice    = slices[i];
                    DataGridViewCellCollection rowCells = table.Rows[i].Cells;

                    Assert.AreEqual("Lamel " + (i + 1),
                                    rowCells[nameColumnIndex].Value);

                    var xCenter = (RoundedDouble)rowCells[xCenterColumnIndex].Value;
                    Assert.AreEqual((slice.TopLeftPoint.X + slice.TopRightPoint.X) / 2.0,
                                    xCenter,
                                    xCenter.GetAccuracy());

                    var zCenter = (RoundedDouble)rowCells[zCenterBottomColumnIndex].Value;
                    Assert.AreEqual(new Segment2D(slice.BottomLeftPoint, slice.BottomRightPoint).Interpolate(xCenter),
                                    zCenter,
                                    zCenter.GetAccuracy());

                    var width = (RoundedDouble)rowCells[widthColumnIndex].Value;
                    Assert.AreEqual(slice.TopRightPoint.X - slice.TopLeftPoint.X,
                                    width,
                                    width.GetAccuracy());

                    var arcLength = (RoundedDouble)rowCells[arcLengthColumnIndex].Value;
                    Assert.AreEqual(slice.BottomLeftPoint.GetEuclideanDistanceTo(slice.BottomRightPoint),
                                    arcLength,
                                    arcLength.GetAccuracy());

                    var bottomAngle = (RoundedDouble)rowCells[bottomAngleColumnIndex].Value;
                    Assert.AreEqual(Math2D.GetAngleBetween(slice.BottomLeftPoint, slice.BottomRightPoint),
                                    bottomAngle,
                                    bottomAngle.GetAccuracy());

                    var topAngle = (RoundedDouble)rowCells[topAngleColumnIndex].Value;
                    Assert.AreEqual(Math2D.GetAngleBetween(slice.TopLeftPoint, slice.TopRightPoint),
                                    topAngle,
                                    topAngle.GetAccuracy());

                    var frictionAngle = (RoundedDouble)rowCells[frictionAngleColumnIndex].Value;
                    Assert.AreEqual(slice.FrictionAngle,
                                    frictionAngle,
                                    frictionAngle.GetAccuracy());

                    var cohesion = (RoundedDouble)rowCells[cohesionColumnIndex].Value;
                    Assert.AreEqual(slice.Cohesion,
                                    cohesion,
                                    cohesion.GetAccuracy());

                    var effectiveStress = (RoundedDouble)rowCells[effectiveStressColumnIndex].Value;
                    Assert.AreEqual(slice.EffectiveStress,
                                    effectiveStress,
                                    effectiveStress.GetAccuracy());

                    var totalPorePressure = (RoundedDouble)rowCells[totalPorePressureColumnIndex].Value;
                    Assert.AreEqual(slice.TotalPorePressure,
                                    totalPorePressure,
                                    totalPorePressure.GetAccuracy());

                    var weight = (RoundedDouble)rowCells[weightColumnIndex].Value;
                    Assert.AreEqual(slice.Weight,
                                    weight,
                                    weight.GetAccuracy());

                    var piezometricPorePressure = (RoundedDouble)rowCells[piezometricPorePressureColumnIndex].Value;
                    Assert.AreEqual(slice.PiezometricPorePressure,
                                    piezometricPorePressure,
                                    piezometricPorePressure.GetAccuracy());

                    var porePressure = (RoundedDouble)rowCells[porePressureColumnIndex].Value;
                    Assert.AreEqual(slice.PorePressure,
                                    porePressure,
                                    porePressure.GetAccuracy());

                    var verticalPorePressure = (RoundedDouble)rowCells[verticalPorePressureColumnIndex].Value;
                    Assert.AreEqual(slice.VerticalPorePressure,
                                    verticalPorePressure,
                                    verticalPorePressure.GetAccuracy());

                    var horizontalPorePressure = (RoundedDouble)rowCells[horizontalPorePressureColumnIndex].Value;
                    Assert.AreEqual(slice.HorizontalPorePressure,
                                    horizontalPorePressure,
                                    horizontalPorePressure.GetAccuracy());

                    var ocr = (RoundedDouble)rowCells[overConsolidationRatioColumnIndex].Value;
                    Assert.AreEqual(slice.OverConsolidationRatio,
                                    ocr,
                                    ocr.GetAccuracy());

                    var pop = (RoundedDouble)rowCells[popColumnIndex].Value;
                    Assert.AreEqual(slice.Pop,
                                    pop,
                                    pop.GetAccuracy());

                    var normalStress = (RoundedDouble)rowCells[normalStressColumnIndex].Value;
                    Assert.AreEqual(slice.NormalStress,
                                    normalStress,
                                    normalStress.GetAccuracy());

                    var shearStress = (RoundedDouble)rowCells[shearStressColumnIndex].Value;
                    Assert.AreEqual(slice.ShearStress,
                                    shearStress,
                                    shearStress.GetAccuracy());

                    var loadStress = (RoundedDouble)rowCells[loadStressColumnIndex].Value;
                    Assert.AreEqual(slice.LoadStress,
                                    loadStress,
                                    loadStress.GetAccuracy());
                }
            }
        }