Exemplo n.º 1
0
        public async void CheckUserDisconnected()
        {
            var repo      = new FakeRepo(_context);
            var fakeUser  = repo.FakeSingleUser();
            var fakeQueue = repo.FakeSingleQueue();

            var connection = MakeHubConnection();

            await connection.StartAsync();

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

            await connection.StopAsync();

            await Task.Delay(5000);

            fakeQueue = _context.Queue.FindByCondition(q => q.Id == fakeQueue.Id).SingleOrDefault();

            bool result         = false;
            var  connectedUsers = _hubUser.GetConnectedUserById(fakeUser.Id);

            if (connectedUsers == null)
            {
                result = true;
            }

            Assert.True(!fakeQueue.IsActive);
            Assert.True(result);
        }
Exemplo n.º 2
0
        public async Task CheckRegisterNewDoctor()
        {
            //System.Diagnostics.Debugger.Launch();
            var repo     = new FakeRepo(_context);
            var fakeUser = repo.FakeSingleUser();

            var fakeQueue     = repo.FakeSingleQueue();
            var expectedQueue = _mapper.Map <WebApp.Models.Queue>(fakeQueue);

            var connection = MakeHubConnection();

            MakeDoctorFullNameReceive(connection);
            MakeQueueNoReceive(connection);
            MakeQueueAdditionalMessageReceive(connection);

            await connection.StartAsync();

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

            fakeQueue = _context.Queue.FindByCondition(q => q.UserId == fakeUser.Id).SingleOrDefault();

            string expected = QueueHelper.GetDoctorFullName(fakeUser);

            Assert.True(fakeQueue.IsActive);

            Assert.Equal(expected, HubResponse.ReceiveDoctorFullName);
            Assert.Equal(fakeUser.Id, HubResponse.ReceiveUserId);

            Assert.Equal(expectedQueue.QueueNoMessage, HubResponse.ReceiveQueueNo);
            Assert.Equal(expectedQueue.AdditionalMessage, HubResponse.ReceiveAdditionalMessage);

            await connection.DisposeAsync();
        }
Exemplo n.º 3
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);
        }