public void Provides_end_point_actually_being_listened_on() { // provide the endpoint which is 'listen on any IP address and any port' var endPoint = new IPEndPoint(IPAddress.Any, 0); StompServer server = new StompServer(); server.ListenOn(endPoint); // Want to know the actual port being listened on var listenEndPoint = (IPEndPoint) server.EndPoints.First(); Assert.IsTrue(listenEndPoint.Port > 0, "Should be endpoint actually being listened to"); server.Dispose(); }
public void Server_can_listen_on_multiple_endpoints() { // provide the endpoint which is 'listen on any IP address and any port' var endPoint = new IPEndPoint(IPAddress.Any, 0); StompServer server = new StompServer(); server.ListenOn(endPoint); server.ListenOn(endPoint); Assert.AreEqual(2, server.EndPoints.Count); // Want to know the actual port being listened on var listenEndPoint1 = (IPEndPoint)server.EndPoints.First(); var listenEndPoint2 = (IPEndPoint) server.EndPoints.Last(); Assert.AreNotSame(listenEndPoint1, listenEndPoint2); Assert.IsTrue(listenEndPoint1.Port > 0, "Should be endpoint actually being listened to"); Assert.IsTrue(listenEndPoint2.Port > 0, "Should be endpoint actually being listened to"); Assert.AreNotEqual(listenEndPoint1.Port, listenEndPoint2.Port); server.Dispose(); }