private static void SetPropertyAndVerifyNotificationsAndOutputForCalculation( Action <UseForeshoreProperties> setProperty, TestUseForeshore input) { // Setup var mocks = new MockRepository(); var observable = mocks.StrictMock <IObservable>(); observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] { observable }); var properties = new UseForeshoreProperties(input, handler); // Call setProperty(properties); // Assert Assert.IsTrue(handler.Called); mocks.VerifyAll(); }
public void GetProperties_ValidUseForeshore_ExpectedValues() { // Setup var mocks = new MockRepository(); var handler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var geometry = new[] { new Point2D(1, 1) }; var useForeshoreData = new TestUseForeshore { ForeshoreGeometry = new RoundedPoint2DCollection(2, geometry), UseForeshore = true }; // Call var properties = new UseForeshoreProperties(useForeshoreData, handler); // Assert Assert.IsTrue(properties.UseForeshore); Assert.AreEqual(geometry, properties.Coordinates); }
public void Constructor_WithDataWithoutForeshoreGeometry_CoordinatesNull() { // Setup var mocks = new MockRepository(); var handler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var useForeshoreData = new TestUseForeshore(); // Call var properties = new UseForeshoreProperties(useForeshoreData, handler); // Assert Assert.IsFalse(properties.UseForeshore); Assert.IsNull(properties.Coordinates); }
public void Constructor_HandlerNull_ThrowsArgumentNullException() { // Setup var testUseForeshore = new TestUseForeshore(); var mocks = new MockRepository(); mocks.ReplayAll(); // Call TestDelegate test = () => new UseForeshoreProperties(testUseForeshore, null); // Assert string paramName = Assert.Throws <ArgumentNullException>(test).ParamName; Assert.AreEqual("handler", paramName); }
public void Constructor_ValidData_ExpectedValues() { // Setup var mocks = new MockRepository(); var handler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var useForeshoreData = new TestUseForeshore { UseForeshore = true }; // Call var properties = new UseForeshoreProperties(useForeshoreData, handler); // Assert Assert.IsTrue(properties.UseForeshore); Assert.IsNull(properties.Coordinates); Assert.IsEmpty(properties.ToString()); }
public void Constructor_WithDataWithForeshoreGeometryVariousNumberOfElements_ReturnExpectedValues(int numberOfPoint2D, bool isEnabled) { // Setup var mocks = new MockRepository(); var handler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var useForeshoreData = new TestUseForeshore { ForeshoreGeometry = new RoundedPoint2DCollection( 0, Enumerable.Repeat(new Point2D(0, 0), numberOfPoint2D).ToArray()) }; // Call var properties = new UseForeshoreProperties(useForeshoreData, handler); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(2, dynamicProperties.Count); PropertyDescriptor useForeshoreProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(useForeshoreProperty, "Misc", "Gebruik", "Moet de voorlandgeometrie worden gebruikt tijdens de berekening?", !isEnabled); PropertyDescriptor coordinatesProperty = dynamicProperties[1]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(coordinatesProperty, "Misc", "Coördinaten [m]", "Lijst met punten in lokale coördinaten.", true); }