Ejemplo n.º 1
0
        public void TestAddingSingleUser(string userId, string connectionId, string groupName)
        {
            var hubUser = new FakeHubUser(userId, connectionId, groupName).Build();

            _manageHubUser.AddUser(hubUser);
            //_manageHubUser.AddUser(hubUser);

            var userInDb            = _hubUserContext.ConnectedUsers.Where(u => u.ConnectionId == hubUser.ConnectionId).Single();
            var connectedUsersCount = _hubUserContext.ConnectedUsers.ToList().Count();
            var waitingUsersCount   = _hubUserContext.WaitingUsers.ToList().Count();

            Assert.Equal(userInDb.UserId, hubUser.UserId);
            Assert.Equal(userInDb.ConnectionId, hubUser.ConnectionId);
            Assert.Equal(userInDb.GroupName, hubUser.GroupName);
            Assert.Equal(1, connectedUsersCount);
            Assert.Equal(0, waitingUsersCount);
        }
Ejemplo n.º 2
0
        public async void CheckQueueOccupied()
        {
            var repo          = new FakeRepo(_context);
            var fakeUser      = repo.FakeSingleUser();
            var fakeQueue     = repo.FakeSingleQueue();
            var expectedQueue = _mapper.Map <WebApp.Models.Queue>(fakeQueue);

            //put user in empty groud -> will go to ConnectedUsers list
            _hubUser.AddUser(new FakeHubUser("234", "12345", "12").Build());

            var connection = MakeHubConnection();

            MakeNotifyQueueOccupied(connection);

            await connection.StartAsync();

            await connection.InvokeAsync("RegisterDoctor", fakeUser.Id, fakeUser.RoomNo);

            var expectedMessage = StaticDetails.QueueOccupiedMessage;

            Assert.Equal(expectedMessage, HubResponse.ReceiveQueueOccupied);
        }