public void ExplicitLeaveRoom() { // Carol: One of her connections leaveRoom _hub.Context = _carolContext; _hub.LeaveRoom(Resources.English.RoomId); // Evaluate Assert.AreEqual(0, _events.Count); // Carol: her other connection leaveRoom _hub.Context = _carolContextBis; _hub.LeaveRoom(Resources.English.RoomId); // Ack all messagess _hub.Context = _bobContext; //_hub.Ack(14); // Evaluate Assert.AreEqual($"{_carolUserId} left '{Resources.English.RoomId}'", _events.Dequeue()); Assert.AreEqual(0, _events.Count); }
public async Task ReJoinPrivateChat() { _hub.Context = _aliceContext; //Alice leaves private room _hub.LeaveRoom(privateRoomId); //Bob recieves notification Assert.AreEqual($"{_aliceUserId} left '{privateRoomId}'", _events.Dequeue()); _hub.Context = _bobContext; var bobMessage = "Get back, Alice!"; await _hub.PostTo(privateRoomId, bobMessage); Assert.AreEqual($"{Resources.Bob.FirstName} said '{bobMessage}' in '{privateRoomId}'", _events.Dequeue()); //_hub.Ack(8); _hub.Context = _aliceContext; //_hub.Ack(10); //Alice joins room second time _hub.JoinRoom(privateRoomId); //Bob got notification that Alice joined Assert.AreEqual($"{_aliceUserId} joined '{privateRoomId}'", _events.Dequeue()); //Alice gets data from server Assert.AreEqual($"1 initial user(s) added to '{privateRoomId}'", _events.Dequeue()); //_hub.Ack(11); Assert.AreEqual("Initial Messages Added", _events.Dequeue()); //_hub.Ack(12); //Ack Bob message _hub.Context = _bobContext; //_hub.Ack(9); //Should be empty Assert.AreEqual(0, _events.Count); }