public void DisconnectAndRelease(Topology.Connection connection) => Connections.DisconnectAndRelease(ref Nodes, connection);
public void MessageConnectionsMade_CausesConnectionTable_ToBePopulatedCorrectly_AndSubsequentlyRemoved(ConnectionAPI meansOfConnection) { using (var set = new NodeSet()) { NodeHandle <NodeWithAllTypesOfPorts> a = set.Create <NodeWithAllTypesOfPorts>(), b = set.Create <NodeWithAllTypesOfPorts>(); NodeHandle untypedA = a, untypedB = b; Assert.AreEqual(0, set.GetTopologyDatabase().CountEstablishedConnections(), "There are valid connections in a new set with zero connections"); if (meansOfConnection == ConnectionAPI.StronglyTyped) { set.Connect(a, NodeWithAllTypesOfPorts.SimulationPorts.MessageOut, b, NodeWithAllTypesOfPorts.SimulationPorts.MessageIn); } else { set.Connect(a, set.GetDefinition(a).GetPortDescription(a).Outputs[0], b, set.GetDefinition(b).GetPortDescription(b).Inputs[0]); } Assert.AreEqual(1, set.GetTopologyDatabase().CountEstablishedConnections(), "There isn't exactly one valid edge in a new set with one connection"); var madeConnection = new Topology.Connection(); Assert.IsFalse(madeConnection.Valid, "Default constructed connection is valid"); int indexHandleCounter = 0, foundIndexHandle = 0; for (int i = 0; i < set.GetTopologyDatabase().TotalConnections; ++i) { if (set.GetTopologyDatabase()[i].Valid) { madeConnection = set.GetTopologyDatabase()[i]; foundIndexHandle = indexHandleCounter; } indexHandleCounter++; } Assert.IsTrue(madeConnection.Valid, "Could not find the made connection"); Assert.NotZero(foundIndexHandle, "Found connection cannot be the invalid slot"); // check the connection is as it should be Assert.AreEqual((uint)PortDescription.Category.Message, madeConnection.TraversalFlags); Assert.AreEqual(untypedB, madeConnection.Destination.ToPublicHandle()); Assert.AreEqual(untypedA, madeConnection.Source.ToPublicHandle()); Assert.AreEqual(NodeWithAllTypesOfPorts.SimulationPorts.MessageOut.Port, madeConnection.SourceOutputPort); Assert.AreEqual(NodeWithAllTypesOfPorts.SimulationPorts.MessageIn.Port, madeConnection.DestinationInputPort.PortID); Assert.AreEqual(foundIndexHandle, madeConnection.HandleToSelf.Index); if (meansOfConnection == ConnectionAPI.StronglyTyped) { set.Disconnect(a, NodeWithAllTypesOfPorts.SimulationPorts.MessageOut, b, NodeWithAllTypesOfPorts.SimulationPorts.MessageIn); } else { set.Disconnect(a, set.GetDefinition(a).GetPortDescription(a).Outputs[0], b, set.GetDefinition(b).GetPortDescription(b).Inputs[0]); } Assert.AreEqual(0, set.GetTopologyDatabase().CountEstablishedConnections(), "There are valid connections in a new set with zero connections"); set.Destroy(a, b); } }