Exemplo n.º 1
0
        public void VisibleProperties_WithSoilProfile1D_ExpectedAttributesValues()
        {
            // Setup
            var layer = new MacroStabilityInwardsSoilLayer1D(-2);
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.142, new MacroStabilityInwardsSoilProfile1D("<some name>", -5.0, new[]
            {
                layer
            }));

            // Call
            var properties = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

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

            Assert.AreEqual(5, dynamicProperties.Count);

            PropertyDescriptor nameProperty = dynamicProperties[0];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
                                                                            generalCategoryName,
                                                                            "Naam",
                                                                            "De naam van de ondergrondschematisatie.",
                                                                            true);

            PropertyDescriptor contributionProperty = dynamicProperties[1];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(contributionProperty,
                                                                            generalCategoryName,
                                                                            "Aandeel [%]",
                                                                            "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel.",
                                                                            true);

            PropertyDescriptor layersProperty = dynamicProperties[2];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(layersProperty,
                                                                            generalCategoryName,
                                                                            "Grondlagen",
                                                                            "",
                                                                            true);

            PropertyDescriptor bottomProperty = dynamicProperties[3];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(bottomProperty,
                                                                            generalCategoryName,
                                                                            "Bodemniveau",
                                                                            "Het niveau van de onderkant van de ondergrondschematisatie.",
                                                                            true);

            PropertyDescriptor typeProperty = dynamicProperties[4];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(typeProperty,
                                                                            generalCategoryName,
                                                                            "Type",
                                                                            "Het type van de ondergrondschematisatie.",
                                                                            true);
        }
Exemplo n.º 2
0
        public void VisibleProperties_WithSoilProfile2D_ExpectedAttributesValues()
        {
            // Setup
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.142, new MacroStabilityInwardsSoilProfile2D("<some name>", new[]
            {
                CreateMacroStabilityInwardsSoilLayer2D()
            }, Enumerable.Empty <MacroStabilityInwardsPreconsolidationStress>()));

            // Call
            var properties = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

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

            Assert.AreEqual(5, dynamicProperties.Count);

            PropertyDescriptor nameProperty = dynamicProperties[0];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
                                                                            generalCategoryName,
                                                                            "Naam",
                                                                            "De naam van de ondergrondschematisatie.",
                                                                            true);

            PropertyDescriptor contributionProperty = dynamicProperties[1];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(contributionProperty,
                                                                            generalCategoryName,
                                                                            "Aandeel [%]",
                                                                            "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel.",
                                                                            true);

            PropertyDescriptor layersProperty = dynamicProperties[2];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(layersProperty,
                                                                            generalCategoryName,
                                                                            "Grondlagen",
                                                                            "",
                                                                            true);

            PropertyDescriptor typeProperty = dynamicProperties[3];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(typeProperty,
                                                                            generalCategoryName,
                                                                            "Type",
                                                                            "Het type van de ondergrondschematisatie.",
                                                                            true);

            PropertyDescriptor preconsolidationProperty = dynamicProperties[4];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(preconsolidationProperty,
                                                                            generalCategoryName,
                                                                            "Grensspanningen",
                                                                            "De grensspanningen in de ondergrondschematisatie.",
                                                                            true);
        }
Exemplo n.º 3
0
        public void DynamicVisibleValidationMethod_AnyOtherProperty_ReturnsFalse()
        {
            // Setup
            var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", -5.0, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(-2)
            });
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfile);
            var properties            = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

            // Call
            bool otherVisible = properties.DynamicVisibleValidationMethod(string.Empty);

            // Assert
            Assert.IsFalse(otherVisible);
        }
Exemplo n.º 4
0
        public void GetProperties_WithSoilProfile2D_ReturnExpectedValues()
        {
            // Setup
            var    random      = new Random(21);
            double probability = random.NextDouble();

            MacroStabilityInwardsSoilLayer2D layerOne = CreateMacroStabilityInwardsSoilLayer2D();
            MacroStabilityInwardsSoilLayer2D layerTwo = CreateMacroStabilityInwardsSoilLayer2D();

            MacroStabilityInwardsSoilLayer2D[] layers =
            {
                layerOne,
                layerTwo
            };

            MacroStabilityInwardsPreconsolidationStress[] stresses =
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress()
            };

            var soilProfile           = new MacroStabilityInwardsSoilProfile2D("<some name>", layers, stresses);
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(probability, soilProfile);

            // Call
            var properties = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

            // Assert
            Assert.AreEqual(soilProfile.Name, properties.Name);
            Assert.AreEqual(soilProfile.Name, properties.ToString());

            Assert.AreEqual(layers.Length, properties.Layers2D.Length);
            Assert.AreSame(layerOne, properties.Layers2D[0].Data);
            Assert.AreSame(layerTwo, properties.Layers2D[1].Data);

            CollectionAssert.IsEmpty(properties.Layers1D);
            Assert.AreEqual(double.NaN, properties.Bottom);
            Assert.AreEqual(2, properties.Probability.NumberOfDecimalPlaces);
            Assert.AreEqual(probability * 100, properties.Probability, properties.Probability.GetAccuracy());
            Assert.AreEqual("2D profiel", properties.Type);

            Assert.AreEqual(stresses.Length, properties.PreconsolidationStresses.Length);
            Assert.AreSame(stresses[0], properties.PreconsolidationStresses[0].Data);
        }
Exemplo n.º 5
0
        public void Constructor_ValidStochasticSoilProfile_ExpectedValues()
        {
            // Setup
            MacroStabilityInwardsSoilProfile1D soilProfile = MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D();
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(1.0, soilProfile);

            // Call
            var properties = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

            // Assert
            Assert.IsInstanceOf <ObjectProperties <MacroStabilityInwardsStochasticSoilProfile> >(properties);
            TestHelper.AssertTypeConverter <MacroStabilityInwardsStochasticSoilProfileProperties, ExpandableObjectConverter>();
            TestHelper.AssertTypeConverter <MacroStabilityInwardsStochasticSoilProfileProperties,
                                            ExpandableArrayConverter>(nameof(MacroStabilityInwardsStochasticSoilProfileProperties.Layers1D));
            TestHelper.AssertTypeConverter <MacroStabilityInwardsStochasticSoilProfileProperties,
                                            ExpandableArrayConverter>(nameof(MacroStabilityInwardsStochasticSoilProfileProperties.Layers2D));
            TestHelper.AssertTypeConverter <MacroStabilityInwardsStochasticSoilProfileProperties,
                                            ExpandableArrayConverter>(nameof(MacroStabilityInwardsStochasticSoilProfileProperties.PreconsolidationStresses));
            Assert.AreSame(stochasticSoilProfile, properties.Data);
        }
Exemplo n.º 6
0
        public void GetProperties_WithUnsupportedSoilProfile_ThrowsNotSupportedException()
        {
            // Setup
            var soilProfile           = new UnsupportedSoilProfile();
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfile);

            var properties = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

            string type = null;

            // Call
            TestDelegate call = () => type = properties.Type;

            // Assert
            var    exception       = Assert.Throws <NotSupportedException>(call);
            string expectedMessage = $"{soilProfile.GetType()} is not supported. Supported types: " +
                                     $"{nameof(MacroStabilityInwardsSoilProfile1D)} and {nameof(MacroStabilityInwardsSoilProfile2D)}.";

            Assert.AreEqual(expectedMessage, exception.Message);
        }
Exemplo n.º 7
0
        public void GetProperties_WithSoilProfile1D_ReturnExpectedValues()
        {
            // Setup
            var    random      = new Random(21);
            double bottom      = random.NextDouble();
            double probability = random.NextDouble();

            var layerOne = new MacroStabilityInwardsSoilLayer1D(4);
            var layerTwo = new MacroStabilityInwardsSoilLayer1D(2);
            IEnumerable <MacroStabilityInwardsSoilLayer1D> layers = new[]
            {
                layerOne,
                layerTwo
            };

            var soilProfile           = new MacroStabilityInwardsSoilProfile1D("<some name>", bottom, layers);
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(probability, soilProfile);

            // Call
            var properties = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

            // Assert
            Assert.AreEqual(soilProfile.Name, properties.Name);
            Assert.AreEqual(soilProfile.Name, properties.ToString());

            Assert.AreEqual(2, properties.Layers1D.Length);
            Assert.AreSame(layerOne, properties.Layers1D[0].Data);
            Assert.AreSame(layerTwo, properties.Layers1D[1].Data);

            CollectionAssert.IsEmpty(properties.Layers2D);
            Assert.AreEqual(2, properties.Bottom.NumberOfDecimalPlaces);
            Assert.AreEqual(bottom, properties.Bottom, properties.Bottom.GetAccuracy());
            Assert.AreEqual(2, properties.Probability.NumberOfDecimalPlaces);
            Assert.AreEqual(probability * 100, properties.Probability, properties.Probability.GetAccuracy());
            Assert.AreEqual("1D profiel", properties.Type);
        }
Exemplo n.º 8
0
        public void DynamicVisibleValidationMethod_WithSoilProfile2D_Only2DPropertiesVisible()
        {
            // Setup
            IEnumerable <MacroStabilityInwardsSoilLayer2D> layers = new[]
            {
                CreateMacroStabilityInwardsSoilLayer2D()
            };

            var soilProfile           = new MacroStabilityInwardsSoilProfile2D("name", layers, Enumerable.Empty <MacroStabilityInwardsPreconsolidationStress>());
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfile);
            var properties            = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

            // Call
            bool bottomVisible   = properties.DynamicVisibleValidationMethod("Bottom");
            bool layers1DVisible = properties.DynamicVisibleValidationMethod("Layers1D");
            bool layers2DVisible = properties.DynamicVisibleValidationMethod("Layers2D");
            bool preconsolidationStressesVisible = properties.DynamicVisibleValidationMethod("PreconsolidationStresses");

            // Assert
            Assert.IsFalse(bottomVisible);
            Assert.IsFalse(layers1DVisible);
            Assert.IsTrue(layers2DVisible);
            Assert.IsTrue(preconsolidationStressesVisible);
        }