Exemplo n.º 1
0
        private static void SetPropertyAndVerifyNotificationsForCalculation(Action <MacroStabilityInwardsLocationInputOffsetProperties> setProperty)
        {
            // Setup
            var mocks      = new MockRepository();
            var observable = mocks.StrictMock <IObservable>();

            observable.Expect(o => o.NotifyObservers());
            mocks.ReplayAll();

            var input = new TestMacroStabilityInwardsLocationInput();

            var handler = new SetPropertyValueAfterConfirmationParameterTester(new[]
            {
                observable
            });

            var properties = new MacroStabilityInwardsLocationInputOffsetProperties(input, handler);

            // Call
            setProperty(properties);

            // Assert
            Assert.IsTrue(handler.Called);
            mocks.VerifyAll();
        }
Exemplo n.º 2
0
        public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnInput()
        {
            // Given
            var calculation = new MacroStabilityInwardsCalculationScenario();
            var input       = new TestMacroStabilityInwardsLocationInput();

            var handler    = new ObservablePropertyChangeHandler(calculation, calculation.InputParameters);
            var properties = new MacroStabilityInwardsLocationInputOffsetProperties(input, handler);

            var    random            = new Random(21);
            bool   useDefaultOffsets = random.NextBoolean();
            double phreaticLineOffsetBelowDikeTopAtRiver     = random.NextDouble();
            double phreaticLineOffsetBelowDikeTopAtPolder    = random.NextDouble();
            double phreaticLineOffsetBelowShoulderBaseInside = random.NextDouble();
            double phreaticLineOffsetBelowDikeToeAtPolder    = random.NextDouble();

            // When
            properties.UseDefaultOffsets = useDefaultOffsets;
            properties.PhreaticLineOffsetBelowDikeTopAtRiver     = (RoundedDouble)phreaticLineOffsetBelowDikeTopAtRiver;
            properties.PhreaticLineOffsetBelowDikeTopAtPolder    = (RoundedDouble)phreaticLineOffsetBelowDikeTopAtPolder;
            properties.PhreaticLineOffsetBelowShoulderBaseInside = (RoundedDouble)phreaticLineOffsetBelowShoulderBaseInside;
            properties.PhreaticLineOffsetBelowDikeToeAtPolder    = (RoundedDouble)phreaticLineOffsetBelowDikeToeAtPolder;

            // Then
            Assert.AreEqual(useDefaultOffsets, input.UseDefaultOffsets);
            Assert.AreEqual(phreaticLineOffsetBelowDikeTopAtRiver, input.PhreaticLineOffsetBelowDikeTopAtRiver,
                            input.PhreaticLineOffsetBelowDikeTopAtRiver.GetAccuracy());
            Assert.AreEqual(phreaticLineOffsetBelowDikeTopAtPolder, input.PhreaticLineOffsetBelowDikeTopAtPolder,
                            input.PhreaticLineOffsetBelowDikeTopAtPolder.GetAccuracy());
            Assert.AreEqual(phreaticLineOffsetBelowShoulderBaseInside, input.PhreaticLineOffsetBelowShoulderBaseInside,
                            input.PhreaticLineOffsetBelowShoulderBaseInside.GetAccuracy());
            Assert.AreEqual(phreaticLineOffsetBelowDikeToeAtPolder, input.PhreaticLineOffsetBelowDikeToeAtPolder,
                            input.PhreaticLineOffsetBelowDikeToeAtPolder.GetAccuracy());
        }
Exemplo n.º 3
0
        public void ToString_Always_ReturnEmptyString()
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            var input      = new TestMacroStabilityInwardsLocationInput();
            var properties = new MacroStabilityInwardsLocationInputOffsetProperties(input, changeHandler);

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

            // Assert
            Assert.AreEqual(string.Empty, toString);
        }
Exemplo n.º 4
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            var input = new TestMacroStabilityInwardsLocationInput();

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

            // Assert
            Assert.IsInstanceOf <ObjectProperties <MacroStabilityInwardsLocationInputBase> >(properties);
            Assert.AreSame(input, properties.Data);
            mocks.VerifyAll();
        }
Exemplo n.º 5
0
        public void DynamicReadOnlyValidationMethod_Always_DependsUseDefaultOffsets(bool useDefaultOffsets)
        {
            // Setup
            var mocks   = new MockRepository();
            var handler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            var input = new TestMacroStabilityInwardsLocationInput
            {
                UseDefaultOffsets = useDefaultOffsets
            };

            var properties = new MacroStabilityInwardsLocationInputOffsetProperties(input, handler);

            // Call
            bool result = properties.DynamicReadOnlyValidationMethod("");

            // Assert
            Assert.AreEqual(useDefaultOffsets, result);
        }
Exemplo n.º 6
0
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            var input = new TestMacroStabilityInwardsLocationInput();

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

            // Assert
            Assert.AreEqual(input.UseDefaultOffsets, properties.UseDefaultOffsets);
            Assert.AreEqual(input.PhreaticLineOffsetBelowDikeTopAtRiver, properties.PhreaticLineOffsetBelowDikeTopAtRiver);
            Assert.AreEqual(input.PhreaticLineOffsetBelowDikeTopAtPolder, properties.PhreaticLineOffsetBelowDikeTopAtPolder);
            Assert.AreEqual(input.PhreaticLineOffsetBelowShoulderBaseInside, properties.PhreaticLineOffsetBelowShoulderBaseInside);
            Assert.AreEqual(input.PhreaticLineOffsetBelowDikeToeAtPolder, properties.PhreaticLineOffsetBelowDikeToeAtPolder);
            mocks.VerifyAll();
        }
Exemplo n.º 7
0
        public void Constructor_ValidData_PropertiesHaveExpectedAttributesValues(bool useDefaultOffsets)
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            var input = new TestMacroStabilityInwardsLocationInput
            {
                UseDefaultOffsets = useDefaultOffsets
            };

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

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

            Assert.AreEqual(5, dynamicProperties.Count);

            const string offsetCategory = "Offsets PL 1";

            PropertyDescriptor useDefaultOffsetsProperty = dynamicProperties[expectedUseDefaultOffsetsPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                useDefaultOffsetsProperty,
                offsetCategory,
                "Gebruik default waarden voor offsets van PL 1",
                "Gebruik standaard waterstandsverschillen voor het bepalen van de freatische lijn?");

            PropertyDescriptor phreaticLineOffsetBelowDikeTopAtRiverProperty = dynamicProperties[expectedPhreaticLineOffsetBelowDikeTopAtRiverPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                phreaticLineOffsetBelowDikeTopAtRiverProperty,
                offsetCategory,
                "PL 1 offset onder buitenkruin [m]",
                "Verschil tussen de waterstand en de freatische lijn onder kruin buitentalud.",
                useDefaultOffsets);

            PropertyDescriptor phreaticLineOffsetBelowDikeTopAtPolderProperty = dynamicProperties[expectedPhreaticLineOffsetBelowDikeTopAtPolderPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                phreaticLineOffsetBelowDikeTopAtPolderProperty,
                offsetCategory,
                "PL 1 offset onder binnenkruin [m]",
                "Verschil tussen de waterstand en de freatische lijn onder kruin binnentalud.",
                useDefaultOffsets);

            PropertyDescriptor phreaticLineOffsetBelowShoulderBaseInsideProperty = dynamicProperties[expectedPhreaticLineOffsetBelowShoulderBaseInsidePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                phreaticLineOffsetBelowShoulderBaseInsideProperty,
                offsetCategory,
                "PL 1 offset onder insteek binnenberm [m]",
                "Waterstandsverschil tussen het maaiveld en de freatische lijn onder insteek binnenberm.",
                useDefaultOffsets);

            PropertyDescriptor phreaticLineOffsetBelowDikeToeAtPolderProperty = dynamicProperties[expectedPhreaticLineOffsetBelowDikeToeAtPolderPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                phreaticLineOffsetBelowDikeToeAtPolderProperty,
                offsetCategory,
                "PL 1 offset onder teen dijk binnenwaarts [m]",
                "Waterstandsverschil tussen het maaiveld en de freatische lijn onder teen dijk binnenwaarts.",
                useDefaultOffsets);

            mocks.VerifyAll();
        }