public void CanConnect_Should_ReturnFalse_WhenDirectionsIncorrect() { var graph = new GraphModel(GraphTypeWithConnections); var node1 = new NodeModel(Substitute.For <INodeType>()); var portIn1 = PortModel.Create <int>("In", PortDirection.Input); var portOut1 = PortModel.Create <int>("Out", PortDirection.Output); node1.AddPort(portIn1); node1.AddPort(portOut1); var node2 = new NodeModel(Substitute.For <INodeType>()); var portIn2 = PortModel.Create <int>("In", PortDirection.Input); var portOut2 = PortModel.Create <int>("Out", PortDirection.Output); node2.AddPort(portIn2); node2.AddPort(portOut2); graph.AddNode(node1); graph.AddNode(node2); Assert.That(graph.CanConnect(portIn1, portIn2), Is.False); // input input Assert.That(graph.CanConnect(portOut1, portOut2), Is.False); // output output Assert.That(graph.CanConnect(portIn1, portOut2), Is.False); // input output }
public void CanConnect_Should_ReturnFalse_WhenPortsNotInGraph() { var graph = new GraphModel(GraphTypeWithConnections); var nodeType = Substitute.For <INodeType>(); var node1 = new NodeModel(nodeType); var node2 = new NodeModel(nodeType); var port1 = PortModel.Create <string>("Out", PortDirection.Output); var port2 = PortModel.Create <string>("In", PortDirection.Input); Assert.That(graph.CanConnect(port1, port2), Is.False); node1.AddPort(port1); node2.AddPort(port2); Assert.That(graph.CanConnect(port1, port2), Is.False); }
public void CanConnect_Should_ReturnFalse_WhenSameNode() { var graph = new GraphModel(GraphTypeWithConnections); var node1 = new NodeModel(Substitute.For <INodeType>()); var port1 = PortModel.Create <string>("1", PortDirection.Output); var port2 = PortModel.Create <string>("2", PortDirection.Input); node1.AddPort(port1); node1.AddPort(port2); graph.AddNode(node1); Assert.That(graph.CanConnect(port1, port2), Is.False); }