public void ToString_DifferentClosingSituations_ReturnsCombinationOfWindDirectionAndClosingSituation() { // Setup string illustrationPointName = string.Empty; var subMechanismIllustrationPoint = new SubMechanismIllustrationPoint(illustrationPointName, 3, Enumerable.Empty <SubMechanismIllustrationPointStochast>(), Enumerable.Empty <IllustrationPointResult>()); const string closingSituation = "direction"; WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); var context = new TopLevelSubMechanismIllustrationPoint(windDirection, closingSituation, subMechanismIllustrationPoint); // Call var properties = new TopLevelSubMechanismIllustrationPointProperties( context, new[] { closingSituation, closingSituation, "Different situation" }); // Assert string expectedStringValue = $"{windDirection.Name} ({closingSituation})"; Assert.AreEqual(expectedStringValue, properties.ToString()); }
public void GetIllustrationPointControlItems_ViewWithData_ReturnsExpectedControlItems() { // Setup var topLevelIllustrationPoints = new[] { new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), "Regular", new TestSubMechanismIllustrationPoint()) }; var generalResult = new TestGeneralResultSubMechanismIllustrationPoint(topLevelIllustrationPoints); var output = new TestHydraulicBoundaryLocationCalculationOutput(generalResult); var calculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()) { Output = output }; var calculations = new ObservableList <HydraulicBoundaryLocationCalculation> { calculation }; TestHydraulicBoundaryCalculationsView view = ShowTestHydraulicBoundaryCalculationsView(calculations); // Call IEnumerable <IllustrationPointControlItem> actualControlItems = view.PublicGetIllustrationPointControlItems(); // Assert IEnumerable <IllustrationPointControlItem> expectedControlItems = CreateControlItems(generalResult); CollectionAssert.AreEqual(expectedControlItems, actualControlItems, new IllustrationPointControlItemComparer()); }
public void Constructor_ChildStochastsNotEqualToTopLevelIllustrationPointStochasts_ThrowArgumentException() { // Setup WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); var illustrationPointNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint(new[] { new Stochast("Stochast 2", 0, 0) })); IEnumerable <TopLevelIllustrationPointBase> topLevelIllustrationPoints = new List <TopLevelIllustrationPointBase> { new TopLevelFaultTreeIllustrationPoint(windDirection, "closing", illustrationPointNode) }; IEnumerable <Stochast> stochasts = new[] { new Stochast("Stochast 1", 0, 0) }; // Call TestDelegate test = () => new GeneralResult <TopLevelIllustrationPointBase>(windDirection, stochasts, topLevelIllustrationPoints); // Assert const string expectedMessage = "De stochasten van een illustratiepunt bevatten niet dezelfde stochasten als in de onderliggende illustratiepunten."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(test, expectedMessage); }
public void Clone_Always_ReturnNewInstanceWithCopiedValues() { // Setup var random = new Random(21); var original = new GeneralResult <TopLevelIllustrationPointBase>(WindDirectionTestFactory.CreateTestWindDirection(), new[] { new Stochast("Random name 1", random.NextDouble(), random.NextDouble()), new Stochast("Random name 2", random.NextDouble(), random.NextDouble()) }, new[] { new TestTopLevelIllustrationPoint("situation 1"), new TestTopLevelIllustrationPoint("situation 2") }); // Call object clone = original.Clone(); // Assert CoreCloneAssert.AreObjectClones(original, clone, CommonCloneAssert.AreClones); }
public void WaveHeightCalculationsView_CalculationUpdated_IllustrationPointsControlCorrectlyUpdated() { // Setup IObservableEnumerable <HydraulicBoundaryLocationCalculation> hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); ShowFullyConfiguredWaveHeightCalculationsView(hydraulicBoundaryLocationCalculations, testForm); IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); calculationsDataGridViewControl.SetCurrentCell(calculationsDataGridViewControl.GetCell(2, 0)); // Precondition CollectionAssert.IsEmpty(illustrationPointsControl.Data); var topLevelIllustrationPoints = new[] { new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), "Regular", new TestSubMechanismIllustrationPoint()) }; var generalResult = new TestGeneralResultSubMechanismIllustrationPoint(topLevelIllustrationPoints); var output = new TestHydraulicBoundaryLocationCalculationOutput(generalResult); // Call HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation = hydraulicBoundaryLocationCalculations.ElementAt(2); hydraulicBoundaryLocationCalculation.Output = output; hydraulicBoundaryLocationCalculation.NotifyObservers(); // Assert IEnumerable <IllustrationPointControlItem> expectedControlItems = CreateControlItems(generalResult); CollectionAssert.AreEqual(expectedControlItems, illustrationPointsControl.Data, new IllustrationPointControlItemComparer()); }
public void Constructor_StochastNamesNotUnique_ThrowArgumentException() { // Setup var random = new Random(21); WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); var stochasts = new[] { new Stochast("unique", random.NextDouble(), random.NextDouble()), new Stochast("non-unique", random.NextDouble(), random.NextDouble()), new Stochast("non-unique", random.NextDouble(), random.NextDouble()), new Stochast("nonunique", random.NextDouble(), random.NextDouble()), new Stochast("nonunique", random.NextDouble(), random.NextDouble()) }; IEnumerable <TopLevelIllustrationPointBase> topLevelIllustrationPoints = Enumerable.Empty <TopLevelIllustrationPointBase>(); // Call TestDelegate test = () => new GeneralResult <TopLevelIllustrationPointBase>(windDirection, stochasts, topLevelIllustrationPoints); // Assert const string expectedMessage = "Een of meerdere stochasten hebben dezelfde naam."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(test, expectedMessage); }
public void GivenControlWithData_WhenDataSetToNull_ThenPointedTreeGraphUpdated() { // Given using (var control = new IllustrationPointsFaultTreeControl()) { var rootNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint()); rootNode.SetChildren(new[] { new IllustrationPointNode(new TestSubMechanismIllustrationPoint("A")), new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B")) }); control.Data = new TopLevelFaultTreeIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "closing situation", rootNode); PointedTreeGraph graph = GetPointedTreeGraph(control); // Precondition Assert.AreEqual(4, graph.VertexCount); Assert.AreEqual(3, graph.EdgeCount); // When control.Data = null; // Then graph = GetPointedTreeGraph(control); Assert.IsNull(control.Selection); Assert.AreEqual(0, graph.VertexCount); Assert.AreEqual(0, graph.EdgeCount); } }
public void GivenControlWithData_WhenVertexSelected_SelectionSetToCorrespondingIllustrationPointNodeSelectionChangedFired() { // Given using (var control = new IllustrationPointsFaultTreeControl()) { var illustrationPointNode = new IllustrationPointNode(new TestSubMechanismIllustrationPoint()); var rootNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint("A")); rootNode.SetChildren(new[] { illustrationPointNode, new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B")) }); control.Data = new TopLevelFaultTreeIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "closing situation", rootNode); var selectionChanged = 0; control.SelectionChanged += (sender, args) => selectionChanged++; PointedTreeElementVertex selectedVertex = GetPointedTreeGraph(control).Vertices.ElementAt(2); // When selectedVertex.IsSelected = true; // Then object selection = control.Selection; Assert.AreSame(illustrationPointNode, selection); Assert.AreEqual(1, selectionChanged); } }
public void GivenControl_WhenDataSetWithInvalidIllustrationPointChildType_ThenThrowsNotSupportedException() { // Given using (var control = new IllustrationPointsFaultTreeControl()) { var rootNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint()); rootNode.SetChildren(new[] { new IllustrationPointNode(new TestIllustrationPoint()), new IllustrationPointNode(new TestSubMechanismIllustrationPoint()) }); var topLevelFaultTreeIllustrationPoint = new TopLevelFaultTreeIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "closing situation", rootNode); // When TestDelegate test = () => control.Data = topLevelFaultTreeIllustrationPoint; // Then var exception = Assert.Throws <NotSupportedException>(test); Assert.AreEqual($"IllustrationPointNode of type {nameof(TestIllustrationPoint)} is not supported. " + $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}", exception.Message); } }
private static GeneralResult <TestTopLevelIllustrationPoint> GetGeneralResultWithoutTopLevelIllustrationPoints() { return(new GeneralResult <TestTopLevelIllustrationPoint>( WindDirectionTestFactory.CreateTestWindDirection(), Enumerable.Empty <Stochast>(), Enumerable.Empty <TestTopLevelIllustrationPoint>())); }
public void CreateGeneralResultSubMechanismIllustrationPointEntity_ValidGeneralResultWithIllustrationPoints_ReturnsEntityWithTopLevelSubMechanismIllustrationPointEntities() { // Setup var random = new Random(21); var generalResult = new GeneralResult <TopLevelSubMechanismIllustrationPoint>( new WindDirection("SSE", random.NextDouble()), Enumerable.Empty <SubMechanismIllustrationPointStochast>(), new[] { new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), "IllustrationPointOne", new TestSubMechanismIllustrationPoint()), new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), "IllustrationPointTwo", new TestSubMechanismIllustrationPoint()) }); // Call GeneralResultSubMechanismIllustrationPointEntity entity = generalResult.CreateGeneralResultSubMechanismIllustrationPointEntity(); // Assert AssertGeneralResultSubMechanismIllustrationPointEntity(generalResult, entity); }
public void Constructor_WithoutClosingSituation_ThrowsArgumentNullException() { // Call void Call() => new WindDirectionClosingSituation(WindDirectionTestFactory.CreateWindDirection(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("closingSituation", exception.ParamName); }
private static GeneralResult <TestTopLevelIllustrationPoint> GetGeneralResultWithTwoTopLevelIllustrationPoints() { return(new GeneralResult <TestTopLevelIllustrationPoint>(WindDirectionTestFactory.CreateTestWindDirection(), Enumerable.Empty <Stochast>(), new[] { new TestTopLevelIllustrationPoint("Closing situation 1"), new TestTopLevelIllustrationPoint("Closing situation 2") })); }
public void Constructor_ValidArgumentValues_DoesNotThrowException() { // Call var properties = new TopLevelSubMechanismIllustrationPointProperties( new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), string.Empty, new TestSubMechanismIllustrationPoint()), Enumerable.Empty <string>()); // Assert Assert.IsInstanceOf <ObjectProperties <TopLevelSubMechanismIllustrationPoint> >(properties); }
public void Constructor_ClosingSituationNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => new TestTopLevelIllustrationPointBase( WindDirectionTestFactory.CreateTestWindDirection(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(call); Assert.AreEqual("closingSituation", exception.ParamName); }
private static GeneralResult <TopLevelFaultTreeIllustrationPoint> GetGeneralResultWithTopLevelIllustrationPointsOfNotSupportedType() { return(new GeneralResult <TopLevelFaultTreeIllustrationPoint>(WindDirectionTestFactory.CreateTestWindDirection(), Enumerable.Empty <Stochast>(), new[] { new TopLevelFaultTreeIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "Closing situation 2", new IllustrationPointNode(new TestIllustrationPoint())) })); }
public void Clone_Always_ReturnNewInstanceWithCopiedValues() { // Setup var original = new TestTopLevelIllustrationPointBase(WindDirectionTestFactory.CreateTestWindDirection(), "Random closing situation"); // Call object clone = original.Clone(); // Assert CoreCloneAssert.AreObjectClones(original, clone, CommonCloneAssert.AreClones); }
private TestCalculationsView ShowFullyConfiguredTestCalculatableView() { TestCalculationsView view = ShowTestCalculatableView(); view.Data = new[] { new TestCalculatableObject { GeneralResult = new GeneralResult <TopLevelSubMechanismIllustrationPoint>( WindDirectionTestFactory.CreateTestWindDirection(), Enumerable.Empty <Stochast>(), new[] { new TopLevelSubMechanismIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "Regular", new SubMechanismIllustrationPoint("Point 1", 0.9, Enumerable.Empty <SubMechanismIllustrationPointStochast>(), Enumerable.Empty <IllustrationPointResult>())), new TopLevelSubMechanismIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "Open", new SubMechanismIllustrationPoint("Point 2", 0.7, Enumerable.Empty <SubMechanismIllustrationPointStochast>(), Enumerable.Empty <IllustrationPointResult>())) }) }, new TestCalculatableObject { GeneralResult = new GeneralResult <TopLevelSubMechanismIllustrationPoint>( WindDirectionTestFactory.CreateTestWindDirection(), Enumerable.Empty <Stochast>(), new[] { new TopLevelSubMechanismIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "Regular", new SubMechanismIllustrationPoint("Point 1", 0.9, Enumerable.Empty <SubMechanismIllustrationPointStochast>(), Enumerable.Empty <IllustrationPointResult>())), new TopLevelSubMechanismIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "Open", new SubMechanismIllustrationPoint("Point 2", 0.7, Enumerable.Empty <SubMechanismIllustrationPointStochast>(), Enumerable.Empty <IllustrationPointResult>())), new TopLevelSubMechanismIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "Closed", new SubMechanismIllustrationPoint("Point 3", 0.8, Enumerable.Empty <SubMechanismIllustrationPointStochast>(), Enumerable.Empty <IllustrationPointResult>())) }) } }; return(view); }
public void Constructor_IllustrationPointsNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => new GeneralResult(0, WindDirectionTestFactory.CreateWindDirection(), Enumerable.Empty <Stochast>(), null); // Assert string paramName = Assert.Throws <ArgumentNullException>(call).ParamName; Assert.AreEqual("illustrationPoints", paramName); }
public void Constructor_ValidArguments_ReturnExpectedValues() { // Setup WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); const string closingSituation = "closing situation"; // Call var topLevelIllustrationPoint = new TestTopLevelIllustrationPointBase(windDirection, closingSituation); // Assert Assert.IsInstanceOf <ICloneable>(topLevelIllustrationPoint); Assert.AreSame(windDirection, topLevelIllustrationPoint.WindDirection); Assert.AreEqual(closingSituation, topLevelIllustrationPoint.ClosingSituation); }
public void Constructor_SubMechanismIllustrationPointNull_ThrowsArgumentNullException() { // Setup WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); // Call TestDelegate call = () => new TopLevelSubMechanismIllustrationPoint(windDirection, "closing situation", null); // Assert var exception = Assert.Throws <ArgumentNullException>(call); Assert.AreEqual("subMechanismIllustrationPoint", exception.ParamName); }
public void Convert_SubMechanismIllustrationPointNull_ThrowsArgumentNullException() { // Setup HydraRingWindDirection hydraRingWindDirection = WindDirectionTestFactory.CreateWindDirection(); // Call void Call() => TopLevelSubMechanismIllustrationPointConverter.Convert(new HydraRingWindDirectionClosingSituation(hydraRingWindDirection, string.Empty), null); // Assert string paramName = Assert.Throws <ArgumentNullException>(Call).ParamName; Assert.AreEqual("hydraRingSubMechanismIllustrationPoint", paramName); }
public void Constructor_WithParameters_ReturnNewInstance() { // Setup var closingSituation = string.Empty; WindDirection windDirection = WindDirectionTestFactory.CreateWindDirection(); // Call var instance = new WindDirectionClosingSituation(windDirection, closingSituation); // Assert Assert.NotNull(instance); Assert.AreEqual(closingSituation, instance.ClosingSituation); Assert.AreSame(windDirection, instance.WindDirection); }
public void Constructor_StochastsNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => new GeneralResult(0, WindDirectionTestFactory.CreateWindDirection(), null, new Dictionary < WindDirectionClosingSituation, IllustrationPointTreeNode>()); // Assert string paramName = Assert.Throws <ArgumentNullException>(call).ParamName; Assert.AreEqual("stochasts", paramName); }
public void Constructor_ClosingSituationsNull_ThrowsArgumentNullException() { // Setup var data = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), string.Empty, new TestSubMechanismIllustrationPoint()); // Call void Call() => new TopLevelSubMechanismIllustrationPointProperties(data, null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("closingSituations", exception.ParamName); }
public void Constructor_TopLevelIllustrationPointsNull_ThrowsArgumentNullException() { // Setup WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); // Call TestDelegate call = () => new GeneralResult <TopLevelIllustrationPointBase>(windDirection, Enumerable.Empty <Stochast>(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(call); Assert.AreEqual("topLevelIllustrationPoints", exception.ParamName); }
public void Constructor_ClosingSituationNull_ThrowsArgumentNullException() { // Setup WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); var faultTreeNode = new IllustrationPointNode(new TestIllustrationPoint()); // Call TestDelegate call = () => new TopLevelFaultTreeIllustrationPoint(windDirection, null, faultTreeNode); // Assert var exception = Assert.Throws <ArgumentNullException>(call); Assert.AreEqual("closingSituation", exception.ParamName); }
public void Constructor_ValidArguments_ReturnsExpectedProperties() { // Setup const string closingScenario = "closing scenario"; WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); var subMechanismIllustrationPoint = new TestSubMechanismIllustrationPoint(); // Call var windDirectionClosingScenarioIllustrationPoint = new TopLevelSubMechanismIllustrationPoint(windDirection, closingScenario, subMechanismIllustrationPoint); // Assert Assert.IsInstanceOf <TopLevelIllustrationPointBase>(windDirectionClosingScenarioIllustrationPoint); Assert.AreEqual(closingScenario, windDirectionClosingScenarioIllustrationPoint.ClosingSituation); Assert.AreSame(windDirection, windDirectionClosingScenarioIllustrationPoint.WindDirection); Assert.AreSame(subMechanismIllustrationPoint, windDirectionClosingScenarioIllustrationPoint.SubMechanismIllustrationPoint); }
public void Constructor_ValidArguments_ReturnsExpectedProperties() { // Setup WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); const string closingSituation = "closing situation"; var faultTreeNode = new IllustrationPointNode(new TestIllustrationPoint()); // Call var illustrationPoint = new TopLevelFaultTreeIllustrationPoint(windDirection, closingSituation, faultTreeNode); // Assert Assert.IsInstanceOf <TopLevelIllustrationPointBase>(illustrationPoint); Assert.AreSame(windDirection, illustrationPoint.WindDirection); Assert.AreEqual(closingSituation, illustrationPoint.ClosingSituation); Assert.AreSame(faultTreeNode, illustrationPoint.FaultTreeNodeRoot); }
public void Constructor_ValidArguments_ReturnsNewInstance() { // Setup var random = new Random(123); double beta = random.NextDouble(); WindDirection governingWind = WindDirectionTestFactory.CreateWindDirection(); IEnumerable <Stochast> stochasts = Enumerable.Empty <Stochast>(); var illustrationPoints = new Dictionary <WindDirectionClosingSituation, IllustrationPointTreeNode>(); // Call var result = new GeneralResult(beta, governingWind, stochasts, illustrationPoints); // Assert Assert.AreEqual(beta, result.Beta); Assert.AreSame(governingWind, result.GoverningWindDirection); Assert.AreSame(stochasts, result.Stochasts); Assert.AreSame(illustrationPoints, result.IllustrationPoints); }