Beispiel #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);
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            MacroStabilityInwardsGrid   leftGrid     = MacroStabilityInwardsGridTestFactory.Create();
            MacroStabilityInwardsGrid   rightGrid    = MacroStabilityInwardsGridTestFactory.Create();
            IEnumerable <RoundedDouble> tangentLines = new[]
            {
                (RoundedDouble)3.4567,
                (RoundedDouble)0.1294
            };

            // Call
            var result = new MacroStabilityInwardsSlipPlaneUpliftVan(leftGrid, rightGrid, tangentLines);

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

            Assert.AreSame(leftGrid, result.LeftGrid);
            Assert.AreSame(rightGrid, result.RightGrid);
            CollectionAssert.AreEqual(new[]
            {
                2,
                2
            }, result.TangentLines.Select(tl => tl.NumberOfDecimalPlaces));
            CollectionAssert.AreEqual(tangentLines.Select(tl => tl.Value), result.TangentLines.Select(tl => tl.Value), new DoubleWithToleranceComparer(1e-2));
        }
        public void Constructor_HandlerNull_ThrowsArgumentNullException()
        {
            // Setup
            MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create();

            // Call
            TestDelegate call = () => new MacroStabilityInwardsGridProperties(grid, null, false);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(call);

            Assert.AreEqual("handler", exception.ParamName);
        }
        public void Constructor_RightGridNull_ThrowsArgumentNullException()
        {
            // Setup
            MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create();

            // Call
            TestDelegate call = () => new MacroStabilityInwardsSlipPlaneUpliftVan(grid, null, Enumerable.Empty <RoundedDouble>());

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(call);

            Assert.AreEqual("rightGrid", exception.ParamName);
        }
        public void Constructor_TangentLinesNull_ThrowsArgumentNullException()
        {
            // Setup
            MacroStabilityInwardsGrid leftGrid  = MacroStabilityInwardsGridTestFactory.Create();
            MacroStabilityInwardsGrid rightGrid = MacroStabilityInwardsGridTestFactory.Create();

            // Call
            TestDelegate call = () => new MacroStabilityInwardsSlipPlaneUpliftVan(leftGrid, rightGrid, null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(call);

            Assert.AreEqual("tangentLines", exception.ParamName);
        }
Beispiel #6
0
        public void Constructor_SlidingCurveNull_ThrowsArgumentNullException()
        {
            // Setup
            var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(MacroStabilityInwardsGridTestFactory.Create(),
                                                                        MacroStabilityInwardsGridTestFactory.Create(),
                                                                        new RoundedDouble[0]);

            // Call
            TestDelegate call = () => new MacroStabilityInwardsOutput(null, slipPlane, new MacroStabilityInwardsOutput.ConstructionProperties());

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(call);

            Assert.AreEqual("slidingCurve", exception.ParamName);
        }
        public void DynamicReadOnly_isReadOnly_ReturnsExpectedResult(bool isReadOnly)
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create();
            var properties = new MacroStabilityInwardsGridProperties(grid, changeHandler, isReadOnly);

            // Call
            bool result = properties.DynamicReadOnlyValidationMethod(string.Empty);

            // Assert
            Assert.AreEqual(isReadOnly, result);
        }
        public void ToString_Always_ReturnEmptyString()
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create();
            var properties = new MacroStabilityInwardsGridProperties(grid, changeHandler, false);

            // Call
            string toString = properties.ToString();

            // Assert
            Assert.AreEqual(string.Empty, toString);
        }
        public void Clone_Always_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            var random   = new Random(21);
            var original = new MacroStabilityInwardsSlipPlaneUpliftVan(MacroStabilityInwardsGridTestFactory.Create(),
                                                                       MacroStabilityInwardsGridTestFactory.Create(),
                                                                       new[]
            {
                random.NextRoundedDouble()
            });

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

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, MacroStabilityInwardsCloneAssert.AreClones);
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create();

            // Call
            var properties = new MacroStabilityInwardsGridProperties(grid, changeHandler, false);

            // Assert
            Assert.IsInstanceOf <ObjectProperties <MacroStabilityInwardsGrid> >(properties);
            Assert.AreSame(grid, properties.Data);
            mocks.VerifyAll();
        }
Beispiel #11
0
        public void Constructor_ConstructionPropertiesWithoutValuesSet_PropertiesAreDefault()
        {
            // Setup
            var slidingCurve = new MacroStabilityInwardsSlidingCurve(MacroStabilityInwardsSlidingCircleTestFactory.Create(),
                                                                     MacroStabilityInwardsSlidingCircleTestFactory.Create(),
                                                                     new MacroStabilityInwardsSlice[0], 0, 0);

            var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(MacroStabilityInwardsGridTestFactory.Create(),
                                                                        MacroStabilityInwardsGridTestFactory.Create(),
                                                                        new RoundedDouble[0]);

            // Call
            var output = new MacroStabilityInwardsOutput(slidingCurve, slipPlane, new MacroStabilityInwardsOutput.ConstructionProperties());

            // Assert
            Assert.IsNaN(output.FactorOfStability);
            Assert.IsNaN(output.ForbiddenZonesXEntryMin);
            Assert.IsNaN(output.ForbiddenZonesXEntryMax);
        }
        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 GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create();

            // Call
            var properties = new MacroStabilityInwardsGridProperties(grid, changeHandler, false);

            // Assert
            Assert.AreEqual(grid.XLeft, properties.XLeft);
            Assert.AreEqual(grid.XRight, properties.XRight);
            Assert.AreEqual(grid.ZTop, properties.ZTop);
            Assert.AreEqual(grid.ZBottom, properties.ZBottom);
            Assert.AreEqual(grid.NumberOfHorizontalPoints, properties.NumberOfHorizontalPoints);
            Assert.AreEqual(grid.NumberOfVerticalPoints, properties.NumberOfVerticalPoints);
            mocks.VerifyAll();
        }
Beispiel #14
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var slidingCurve = new MacroStabilityInwardsSlidingCurve(MacroStabilityInwardsSlidingCircleTestFactory.Create(),
                                                                     MacroStabilityInwardsSlidingCircleTestFactory.Create(),
                                                                     new MacroStabilityInwardsSlice[0], 0, 0);

            var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(MacroStabilityInwardsGridTestFactory.Create(),
                                                                        MacroStabilityInwardsGridTestFactory.Create(),
                                                                        new RoundedDouble[0]);

            var    random            = new Random(21);
            double factorOfStability = random.NextDouble();
            double zValue            = random.NextDouble();
            double xEntryMin         = random.NextDouble();
            double xEntryMax         = random.NextDouble();

            var properties = new MacroStabilityInwardsOutput.ConstructionProperties
            {
                FactorOfStability       = factorOfStability,
                ForbiddenZonesXEntryMin = xEntryMin,
                ForbiddenZonesXEntryMax = xEntryMax
            };

            // Call
            var output = new MacroStabilityInwardsOutput(slidingCurve, slipPlane, properties);

            // Assert
            Assert.IsInstanceOf <CloneableObservable>(output);
            Assert.IsInstanceOf <ICalculationOutput>(output);

            Assert.AreSame(slidingCurve, output.SlidingCurve);
            Assert.AreSame(slipPlane, output.SlipPlane);

            Assert.AreEqual(factorOfStability, output.FactorOfStability);
            Assert.AreEqual(xEntryMin, output.ForbiddenZonesXEntryMin);
            Assert.AreEqual(xEntryMax, output.ForbiddenZonesXEntryMax);
        }
        public void Constructor_ValidData_PropertiesHaveExpectedAttributesValues(bool isReadOnly)
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create();

            // Call
            var properties = new MacroStabilityInwardsGridProperties(grid, changeHandler, isReadOnly);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(6, dynamicProperties.Count);

            const string gridCategory = "Grid";

            PropertyDescriptor xLeftProperty = dynamicProperties[expectedXLeftPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                xLeftProperty,
                gridCategory,
                "X links [m]",
                "Horizontale coördinaat van de linker kant van het rekengrid.",
                isReadOnly);

            PropertyDescriptor xRightProperty = dynamicProperties[expectedXRightPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                xRightProperty,
                gridCategory,
                "X rechts [m]",
                "Horizontale coördinaat van de rechter kant van het rekengrid.",
                isReadOnly);

            PropertyDescriptor zTopProperty = dynamicProperties[expectedZTopPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                zTopProperty,
                gridCategory,
                "Z boven [m+NAP]",
                "Verticale coördinaat van de bovenkant van het rekengrid.",
                isReadOnly);

            PropertyDescriptor zBottomProperty = dynamicProperties[expectedZBottomPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                zBottomProperty,
                gridCategory,
                "Z onder [m+NAP]",
                "Verticale coördinaat van de onderkant van het rekengrid.",
                isReadOnly);

            PropertyDescriptor numberOfHorizontalPointsProperty = dynamicProperties[expectedNumberOfHorizontalPointsPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                numberOfHorizontalPointsProperty,
                gridCategory,
                "Aantal horizontale punten",
                "Aantal punten waarmee het grid wordt samengesteld in horizontale richting.",
                isReadOnly);

            PropertyDescriptor numberOfVerticalPointsProperty = dynamicProperties[expectedNumberOfVerticalPointsPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                numberOfVerticalPointsProperty,
                gridCategory,
                "Aantal verticale punten",
                "Aantal punten waarmee het grid wordt samengesteld in verticale richting.",
                isReadOnly);

            mocks.VerifyAll();
        }