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(); }
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(); }
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(); }