public void Convert_ValidTreeNodeRootWithUnsupportedTreeNodeDataChildren_ThrowsIllustrationPointConversionException() { // Setup var hydraRingFaultTreeIllustrationPoint = new TestHydraRingFaultTreeIllustrationPoint(); var hydraRingIllustrationPointTreeNode = new HydraRingIllustrationPointTreeNode(hydraRingFaultTreeIllustrationPoint); var nestedUnsupportedIllustrationPointData = new HydraRingIllustrationPointTreeNode(new TestHydraRingIllustrationPointData()); var nestedUnsupportedIllustrationPointData2 = new HydraRingIllustrationPointTreeNode(new TestHydraRingIllustrationPointData()); hydraRingIllustrationPointTreeNode.SetChildren(new[] { nestedUnsupportedIllustrationPointData, nestedUnsupportedIllustrationPointData2 }); IllustrationPointNode illustrationPointNode = null; // Call void Call() => illustrationPointNode = IllustrationPointNodeConverter.Convert(hydraRingIllustrationPointTreeNode); // Assert Assert.IsNull(illustrationPointNode); var exception = Assert.Throws <IllustrationPointConversionException>(Call); string expectedMessage = $"An illustration point containing a Hydra-Ring data type of {typeof(TestHydraRingIllustrationPointData)} is not supported."; Assert.AreEqual(expectedMessage, exception.Message); string expectedMessageInnerException = $"Cannot convert {typeof(TestHydraRingIllustrationPointData)}."; Exception innerException = exception.InnerException; Assert.IsInstanceOf <NotSupportedException>(innerException); Assert.AreEqual(expectedMessageInnerException, innerException.Message); }
public void Convert_TreeNodeWithChildren_ReturnIllustrationPointNode() { // Setup var nestedHydraRingIllustrationPointTreeNodes = new HydraRingIllustrationPointTreeNode(new TestHydraRingFaultTreeIllustrationPoint()); nestedHydraRingIllustrationPointTreeNodes.SetChildren(new[] { new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint("Point A")), new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint("Point B")) }); var hydraRingIllustrationPointRootTreeNode = new HydraRingIllustrationPointTreeNode(new TestHydraRingFaultTreeIllustrationPoint()); hydraRingIllustrationPointRootTreeNode.SetChildren(new[] { new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint("Point C")), nestedHydraRingIllustrationPointTreeNodes }); // Call IllustrationPointNode illustrationPointNode = IllustrationPointNodeConverter.Convert(hydraRingIllustrationPointRootTreeNode); // Assert IllustrationPointNode[] children = illustrationPointNode.Children.ToArray(); Assert.AreEqual(2, children.Length); Assert.IsInstanceOf <SubMechanismIllustrationPoint>(children[0].Data); Assert.IsInstanceOf <FaultTreeIllustrationPoint>(children[1].Data); CollectionAssert.IsEmpty(children[0].Children); Assert.AreEqual(2, children[1].Children.Count()); }