예제 #1
0
        public void N_SetValidValue_SetsValueAndUpdatesObserver(double value)
        {
            // Setup
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();

            failureMechanism.Attach(observer);
            var properties = new GrassCoverErosionInwardsFailureMechanismProperties(failureMechanism);

            // Call
            properties.N = (RoundedDouble)value;

            // Assert
            Assert.AreEqual(value, failureMechanism.GeneralInput.N, failureMechanism.GeneralInput.N.GetAccuracy());
            mocks.VerifyAll();
        }
예제 #2
0
        public void ApplyLengthEffectInSection_SetNewValue_NotifyObservers()
        {
            // Setup
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();

            failureMechanism.Attach(observer);

            var properties = new GrassCoverErosionInwardsFailureMechanismProperties(failureMechanism);

            // Call
            properties.ApplyLengthEffectInSection = true;

            // Assert
            Assert.IsTrue(failureMechanism.GeneralInput.ApplyLengthEffectInSection);
            mocks.VerifyAll();
        }
예제 #3
0
        public void N_SetInvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifications(double value)
        {
            // Setup
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            mocks.ReplayAll();

            var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();

            failureMechanism.Attach(observer);
            var properties = new GrassCoverErosionInwardsFailureMechanismProperties(failureMechanism);

            // Call
            void Call() => properties.N = (RoundedDouble)value;

            // Assert
            const string expectedMessage = "De waarde voor 'N' moet in het bereik [1,00, 20,00] liggen.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(Call, expectedMessage);
            mocks.VerifyAll();
        }