Example #1
0
        private async Task AndCheckIfWatcherExistsInDatabase()
        {
            var watcher = await _sut.Get(_teamId, _ticketId, _user.Id);

            var result = watcher as OkObjectResult;

            Assert.NotNull(result?.Value);
        }
        public UserAccountLogged()
        {
            _userController         = (Application.Current as App).UserController;
            _doctorController       = (Application.Current as App).DoctorController;
            _drugController         = (Application.Current as App).DrugController;
            _notificationController = (Application.Current as App).NotificationController;
            InitializeComponent();

            User user = _userController.GetLoggedUser();

            nameTextBox.Text    = user.Name;
            surnameTextBox.Text = user.Surname;
            emailTextBox.Text   = user.Email;
            idLabel.Content     = user.Id.ToString();

            userTypeLabel.Content = user.GetType().Name;

            Doctor doctor = _doctorController.Get(user.Id);

            if (doctor != null)
            {
                notificationDataGrid.Visibility = Visibility.Visible;

                List <Notification> notifications = new List <Notification>();

                foreach (var notificationId in doctor.Notification)
                {
                    notifications.Add(_notificationController.Get(notificationId));
                }

                notificationDataGrid.ItemsSource = notifications;
            }
        }
        public async Task GetAll_ReturnsCorrectNumberOfWatchers_IfDataExists()
        {
            var teamId       = Guid.NewGuid();
            var ticketId     = Guid.NewGuid();
            var testWatchers = new List <UserDto> {
                new UserDto(), new UserDto()
            };

            _notificationServiceMock
            .Setup(service => service.GetAllWatchersAsync(teamId, ticketId))
            .ReturnsAsync(testWatchers);

            var result = await _sut.Get(teamId, ticketId);

            var watchers = (result as OkObjectResult)?.Value as List <UserApiModel>;

            Assert.Equal(watchers?.Count, testWatchers.Count);
        }
Example #4
0
        private async Task AndCheckIfWatcherAddedToTicket()
        {
            var watcher = await _sut.Get(_teamId, _ticketId, _user.Id);

            var result = watcher as OkObjectResult;

            var addedWatcher = result?.Value as UserApiModel;

            Assert.NotNull(addedWatcher);
        }
Example #5
0
        private async Task AndCheckThatWatcherOfThisTicketExists()
        {
            var watcherFromDb = await _sut.Get(_teamId, _ticketId, _user.Id);

            var result = watcherFromDb as OkObjectResult;

            var watcher = result?.Value as UserApiModel;

            Assert.NotNull(watcher);

            Assert.Equal(_user.Id, watcher.Id);
        }
Example #6
0
        private async Task AndCheckThatListOfWatchersHasOneElement()
        {
            var watchers = await _sut.Get(_teamId, _ticketId);

            var result = watchers as OkObjectResult;

            var watchersList = result?.Value as IEnumerable <UserApiModel>;

            Assert.NotNull(watchersList);

            Assert.Equal(1, watchersList.Count());
        }
        private void Row_MouseDoubleClick_ApproveDrug(object sender, MouseButtonEventArgs e)
        {
            var          data         = (DataGrid)sender;
            Notification notification = (Notification)data.SelectedValue;

            if (notification == null)
            {
                return;
            }
            var drugId = Regex.Match(notification.Text, @"\d+").Value;

            Drug drug = _drugController.Get(Int32.Parse(drugId));

            if (drug != null)
            {
                User   user   = _userController.GetLoggedUser();
                Doctor doctor = _doctorController.Get(user.Id);

                drug = _drugController.Approve(drug.Id, doctor.Id);

                if (drug != null)
                {
                    doctor.Notification.Remove(notification.Id);
                    doctor = _doctorController.Update(doctor);

                    List <Notification> notifications = new List <Notification>();

                    foreach (var notificationId in doctor.Notification)
                    {
                        notifications.Add(_notificationController.Get(notificationId));
                    }

                    notificationDataGrid.ItemsSource = notifications;
                }
            }
        }