public void CtorValidNoThrowExceptions() { var server = new EchoRoomServer(TimeSpan.FromMilliseconds(1)); Assert.AreEqual(0, server.RoomsCount); Assert.AreEqual(0, server.GetMessagesToSendCount()); Assert.IsNull(server.GetMessageToSend()); }
public void SameClientIdEnterToMultipleRoomsLeavesPrevRoomTestMethod() { var server = new EchoRoomServer(TimeSpan.FromMilliseconds(1000)); var networkId1 = new object(); var networkId2 = new object(); var client1 = server.EnterInRoom("client", networkId1, "room1"); var client2 = server.EnterInRoom("client", networkId2, "room2"); Assert.AreEqual(3, server.GetMessagesToSendCount()); }
public void EnterTestMethod() { var server = new EchoRoomServer(TimeSpan.FromMilliseconds(1000)); var networkId = new object(); var client = server.EnterInRoom("client", networkId, "room"); Assert.IsNotNull(client); Assert.AreEqual("client", client.Id); Assert.AreSame(networkId, client.NetworkId); Assert.AreEqual(1, server.GetMessagesToSendCount()); }
public void EnterToExpiredRoomTestMethod() { var server = new EchoRoomServer(TimeSpan.FromMilliseconds(50)); var networkId1 = new object(); var networkId2 = new object(); var client1 = server.EnterInRoom("client1", networkId1, "room"); Thread.Sleep(100); var client2 = server.EnterInRoom("client2", networkId2, "room"); Assert.AreEqual(2, server.GetMessagesToSendCount()); }