public void DynamicReadOnlyValidationMethod_WithCreateZonesAndZoningBoundariesDeterminationType_ReturnsExpectedValues(
            bool createZones,
            MacroStabilityInwardsZoningBoundariesDeterminationType zoningBoundariesDeterminationType,
            bool expectedDeterminationTypeReadOnly,
            bool expectedZoneBoundariesReadOnly)
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties())
            {
                CreateZones = createZones,
                ZoningBoundariesDeterminationType = zoningBoundariesDeterminationType
            };

            var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler);

            // Call
            bool isZoningBoundariesDeterminationTypeReadOnly = properties.DynamicReadOnlyValidationMethod(nameof(properties.ZoningBoundariesDeterminationType));
            bool isZoneBoundaryLeftReadOnly  = properties.DynamicReadOnlyValidationMethod(nameof(properties.ZoneBoundaryLeft));
            bool isZoneBoundaryRightReadOnly = properties.DynamicReadOnlyValidationMethod(nameof(properties.ZoneBoundaryRight));

            // Assert
            Assert.AreEqual(expectedDeterminationTypeReadOnly, isZoningBoundariesDeterminationTypeReadOnly);
            Assert.AreEqual(expectedZoneBoundariesReadOnly, isZoneBoundaryLeftReadOnly);
            Assert.AreEqual(expectedZoneBoundariesReadOnly, isZoneBoundaryRightReadOnly);
        }
コード例 #2
0
        public void ConvertFrom_InvalidMacroStabilityInwardsZoningBoundariesDeterminationType_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            const MacroStabilityInwardsZoningBoundariesDeterminationType invalidValue = (MacroStabilityInwardsZoningBoundariesDeterminationType)9999;
            var converter = new ConfigurationZoningBoundariesDeterminationTypeConverter();

            // Call
            TestDelegate call = () => converter.ConvertFrom(invalidValue);

            // Assert
            string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(MacroStabilityInwardsZoningBoundariesDeterminationType)}'.";
            string parameterName   = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName;

            Assert.AreEqual("value", parameterName);
        }
コード例 #3
0
        public void Validate_ZoningBoundariesDeterminationTypeManualOrCreateZonesFalse_ReturnsEmpty(
            MacroStabilityInwardsZoningBoundariesDeterminationType determinationType,
            bool createZones)
        {
            // Setup
            input.ZoneBoundaryLeft  = (RoundedDouble)1;
            input.ZoneBoundaryRight = (RoundedDouble)0.6;
            input.ZoningBoundariesDeterminationType = determinationType;
            input.CreateZones = createZones;

            // Call
            IEnumerable <string> messages = MacroStabilityInwardsInputValidator.Validate(input,
                                                                                         AssessmentSectionTestHelper.GetTestAssessmentLevel()).ToArray();

            // Assert
            CollectionAssert.IsEmpty(messages);
        }
        public void Constructor_ValidData_PropertiesHaveExpectedAttributesValues(
            bool createZones,
            MacroStabilityInwardsZoningBoundariesDeterminationType zoningBoundariesDeterminationType,
            bool expectedDeterminationTypeReadOnly,
            bool expectedZoneBoundariesReadOnly)
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties())
            {
                CreateZones = createZones,
                ZoningBoundariesDeterminationType = zoningBoundariesDeterminationType
            };

            // Call
            var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler);

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

            Assert.AreEqual(4, dynamicProperties.Count);

            const string category = "Zonering glijvlak";

            PropertyDescriptor createZonesProperty = dynamicProperties[expectedCreateZonesPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                createZonesProperty,
                category,
                "Bepaling",
                "Gebruik zoneringsgrenzen bij het bepalen van het intredepunt van het glijvlak?");

            PropertyDescriptor zoningBoundariesDeterminationTypeProperty = dynamicProperties[expectedZoningBoundariesDeterminationTypePropertyIndex];

            TestHelper.AssertTypeConverter <MacroStabilityInwardsSlipPlaneSettingsProperties, EnumTypeConverter>(nameof(properties.ZoningBoundariesDeterminationType));
            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                zoningBoundariesDeterminationTypeProperty,
                category,
                "Methode",
                "Zoneringsgrenzen automatisch bepalen of handmatig invoeren?",
                expectedDeterminationTypeReadOnly);

            PropertyDescriptor zoneBoundaryLeftProperty = dynamicProperties[expectedZoneBoundayrLeftPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                zoneBoundaryLeftProperty,
                category,
                "Zoneringsgrens links",
                "Linker grens voor bepaling intredepunt van het glijvlak.",
                expectedZoneBoundariesReadOnly);

            PropertyDescriptor zoneBoundaryRightProperty = dynamicProperties[expectedZoneBoundaryRightPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                zoneBoundaryRightProperty,
                category,
                "Zoneringsgrens rechts",
                "Rechter grens voor bepaling intredepunt van het glijvlak.",
                expectedZoneBoundariesReadOnly);

            mocks.VerifyAll();
        }