private static void SetPropertyAndVerifyNotificationsForCalculation(Action <MacroStabilityInwardsGridProperties> setProperty,
                                                                            MacroStabilityInwardsCalculation calculation)
        {
            // Setup
            var mocks      = new MockRepository();
            var observable = mocks.StrictMock <IObservable>();

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

            MacroStabilityInwardsGrid grid = calculation.InputParameters.LeftGrid;

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

            var properties = new MacroStabilityInwardsGridProperties(grid, handler, false);

            // Call
            setProperty(properties);

            // Assert
            Assert.IsTrue(handler.Called);
            mocks.VerifyAll();
        }
        public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnGrid()
        {
            // Given
            var calculation = new MacroStabilityInwardsCalculationScenario();
            MacroStabilityInwardsInput input = calculation.InputParameters;
            MacroStabilityInwardsGrid  grid  = input.LeftGrid;

            var handler    = new ObservablePropertyChangeHandler(calculation, input);
            var properties = new MacroStabilityInwardsGridProperties(grid, handler, false);

            var           random  = new Random(21);
            RoundedDouble xLeft   = random.NextRoundedDouble();
            var           xRight  = (RoundedDouble)(1 + random.NextDouble());
            var           zTop    = (RoundedDouble)(1 + random.NextDouble());
            RoundedDouble zBottom = random.NextRoundedDouble();
            int           numberOfHorizontalPoints = random.Next(1, 100);
            int           numberOfVerticalPoints   = random.Next(1, 100);

            // When
            properties.XLeft   = xLeft;
            properties.XRight  = xRight;
            properties.ZTop    = zTop;
            properties.ZBottom = zBottom;
            properties.NumberOfHorizontalPoints = numberOfHorizontalPoints;
            properties.NumberOfVerticalPoints   = numberOfVerticalPoints;

            // Then
            Assert.AreEqual(xLeft, grid.XLeft, grid.XLeft.GetAccuracy());
            Assert.AreEqual(xRight, grid.XRight, grid.XRight.GetAccuracy());
            Assert.AreEqual(zTop, grid.ZTop, grid.ZTop.GetAccuracy());
            Assert.AreEqual(zBottom, grid.ZBottom, grid.ZBottom.GetAccuracy());
            Assert.AreEqual(numberOfHorizontalPoints, grid.NumberOfHorizontalPoints);
            Assert.AreEqual(numberOfVerticalPoints, grid.NumberOfVerticalPoints);
        }
        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 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();
        }
        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();
        }
        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();
        }