public void SettingAssignProjectColoursToSameValueDoesNotRaisePropertyChanged()
        {
            // Arrange

            const bool assignProjectColours  = true;
            var        preferences           = new UserPreferencesModel();
            var        propertyChangedRaised = false;

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                propertyChangedRaised = true;
            });

            preferences.AssignProjectColours = assignProjectColours;
            preferences.PropertyChanged     += handler;

            // Act

            preferences.AssignProjectColours = assignProjectColours;
            preferences.PropertyChanged     -= handler;

            // Assert

            Assert.IsFalse(propertyChangedRaised);
        }
        public void SettingShowSearchBarToSameValueDoesNotRaisePropertyChanged()
        {
            // Arrange

            const bool showSearchBar         = true;
            var        preferences           = new UserPreferencesModel();
            var        propertyChangedRaised = false;

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                propertyChangedRaised = true;
            });

            preferences.ShowSearchBar    = showSearchBar;
            preferences.PropertyChanged += handler;

            // Act

            preferences.ShowSearchBar    = showSearchBar;
            preferences.PropertyChanged -= handler;

            // Assert

            Assert.IsFalse(propertyChangedRaised);
        }
Example #3
0
        public async Task <IHttpActionResult> SavePreferences(UserPreferencesModel model)
        {
            var entity = await _db.UserPreferences.FindAsync(User.Identity.GetUserId()) ?? new AppUserPreferences();

            entity.Id = User.Identity.GetUserId();
            entity.ChartPreferences = new ChartPreferences
            {
                LegendShowen   = model.ChartPreferences.ShowLegend,
                XLineVisible   = model.ChartPreferences.XLineVisible,
                YLineVisible   = model.ChartPreferences.YLineVisible,
                PointSize      = model.ChartPreferences.PointSize,
                FontSize       = model.ChartPreferences.FontSize,
                FontFamilyName = model.ChartPreferences.FontFamilyName,
                PaletteColors  = model.ChartPreferences.PaletteColors.Select(item => item.Color).ToArray()
            };

            if (_db.Entry(entity).State == EntityState.Detached)
            {
                _db.UserPreferences.Add(entity);
            }

            await _db.SaveChangesAsync();

            _cacheProvider.Clear();
            return(Ok());
        }
        public void SettingHighlightFileNameToSameValueDoesNotRaisePropertyChanged()
        {
            // Arrange

            const bool highlightFileName     = true;
            var        preferences           = new UserPreferencesModel();
            var        propertyChangedRaised = false;

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                propertyChangedRaised = true;
            });

            preferences.HighlightFileName = highlightFileName;
            preferences.PropertyChanged  += handler;

            // Act

            preferences.HighlightFileName = highlightFileName;
            preferences.PropertyChanged  -= handler;

            // Assert

            Assert.IsFalse(propertyChangedRaised);
        }
        public void SettingSelectedDocumentSortOptionToSameValueDoesNotRaisePropertyChanged()
        {
            // Arrange

            const string sortOptionName        = "SortOptionName";
            var          preferences           = new UserPreferencesModel();
            var          propertyChangedRaised = false;

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                propertyChangedRaised = true;
            });

            preferences.DocumentSortOptionName = sortOptionName;
            preferences.PropertyChanged       += handler;

            // Act

            preferences.DocumentSortOptionName = sortOptionName;
            preferences.PropertyChanged       -= handler;

            // Assert

            Assert.IsFalse(propertyChangedRaised);
        }
        public void SettingPathSegmentCountToSameValueDoesNotRaisePropertyChanged()
        {
            // Arrange

            const int pathSegmentCount      = 7;
            var       preferences           = new UserPreferencesModel();
            var       propertyChangedRaised = false;

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                propertyChangedRaised = true;
            });

            preferences.PathSegmentCount = pathSegmentCount;
            preferences.PropertyChanged += handler;

            // Act

            preferences.PathSegmentCount = pathSegmentCount;
            preferences.PropertyChanged -= handler;

            // Assert

            Assert.IsFalse(propertyChangedRaised);
        }
        public void SettingGroupByProjectToSameValueDoesNotRaisePropertyChanged()
        {
            // Arrange

            const bool groupByProject        = true;
            var        preferences           = new UserPreferencesModel();
            var        propertyChangedRaised = false;

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                propertyChangedRaised = true;
            });

            preferences.GroupByProject   = groupByProject;
            preferences.PropertyChanged += handler;

            // Act

            preferences.GroupByProject   = groupByProject;
            preferences.PropertyChanged -= handler;

            // Assert

            Assert.IsFalse(propertyChangedRaised);
        }
        public void SettingShowSearchBarToDifferentValueRaisesPropertyChanged()
        {
            // Arrange

            var preferences = new UserPreferencesModel
            {
                ShowSearchBar = false
            };

            var propertyChangedRaised = false;

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                propertyChangedRaised = true;
            });

            preferences.PropertyChanged += handler;

            // Act

            preferences.ShowSearchBar    = true;
            preferences.PropertyChanged -= handler;

            // Assert

            Assert.IsTrue(propertyChangedRaised);
        }
Example #9
0
        public void UpdatePreferences()
        {
            this.TestWrapper(async(MixerClient client) =>
            {
                UserModel user = await UsersServiceUnitTests.GetCurrentUser(client);

                UserPreferencesModel preferences = await client.Users.GetPreferences(user);

                Assert.IsNotNull(preferences);

                preferences.chatLurkMode = !preferences.chatLurkMode;

                UserPreferencesModel newPreferences = await client.Users.UpdatePreferences(user, preferences);

                Assert.IsNotNull(preferences);
                Assert.AreEqual(preferences.chatLurkMode, newPreferences.chatLurkMode);

                preferences.chatLurkMode = !preferences.chatLurkMode;

                newPreferences = await client.Users.UpdatePreferences(user, preferences);

                Assert.IsNotNull(preferences);
                Assert.AreEqual(preferences.chatLurkMode, newPreferences.chatLurkMode);
            });
        }
Example #10
0
        public async Task <IActionResult> SaveUserPreferences(
            UserPreferencesModel userPreferencesModel,
            CancellationToken cancellationToken)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest());
            }

            var employee = await this.userEmployeeSearch.FindOrDefaultAsync(this.User, cancellationToken);

            var response = await this.userPreferencesService.SaveUserPreferences(
                employee.Metadata.EmployeeId,
                userPreferencesModel,
                cancellationToken);

            switch (response)
            {
            case SaveUserPreferencesMessage.Response _:
                return(this.NoContent());

            default:
                return(this.StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
        public void SettingUnityRefreshDelayToSameValueDoesNotRaisePropertyChanged()
        {
            // Arrange

            const int unityRefreshDelay     = 100;
            var       preferences           = new UserPreferencesModel();
            var       propertyChangedRaised = false;

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                propertyChangedRaised = true;
            });

            preferences.UnityRefreshDelay = unityRefreshDelay;
            preferences.PropertyChanged  += handler;

            // Act

            preferences.UnityRefreshDelay = unityRefreshDelay;
            preferences.PropertyChanged  -= handler;

            // Assert

            Assert.IsFalse(propertyChangedRaised);
        }
 public AppPresentationView(UserPreferencesModel preferences)
 {
     InitializeComponent();
     InitializeUI(preferences);
     InitializeBitmaps();
     DisplayNextImage();
     //TODO quand on arrive au bout, si on ferme avec le bouton close, ça ne prend pas en compte qu'on a tout vu, mais on ne peut pas définir DIalogResult pendant la fermeture.
 }
Example #13
0
 public ApplicationExitCommand(ApplicationExitEventArgs args, LayoutIOModel layoutIO, SelectedProfileModel selectedProfile,
                               Database database, UserPreferencesModel preferences)
 {
     this.args            = args;
     this.layoutIO        = layoutIO;
     this.selectedProfile = selectedProfile;
     this.database        = database;
     this.preferences     = preferences;
 }
Example #14
0
 public SelectBackgroundCommand(MenuButtonEventArgs args, ScreenModel screenModel, CollectionModel <BackgroundModel> backgroundCollection,
                                PlaceHolderCollectionModel placeholderCollection, UserPreferencesModel preferences, Database database)
 {
     this.args                  = args;
     this.screenModel           = screenModel;
     this.backgroundCollection  = backgroundCollection;
     this.placeholderCollection = placeholderCollection;
     this.preferences           = preferences;
     this.database              = database;
 }
        public void ShowSearchBarDefaultsToTrue()
        {
            // Arrange, Act

            var preferences = new UserPreferencesModel();

            // Assert

            Assert.IsTrue(preferences.ShowSearchBar);
        }
Example #16
0
        public void GetPreferences()
        {
            this.TestWrapper(async(MixerClient client) =>
            {
                UserModel user = await UsersServiceUnitTests.GetCurrentUser(client);

                UserPreferencesModel preferences = await client.Users.GetPreferences(user);

                Assert.IsNotNull(preferences);
            });
        }
        public void GetPreferences()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                UserModel user = await UsersServiceUnitTests.GetCurrentUser(connection);

                UserPreferencesModel preferences = await connection.Users.GetPreferences(user);

                Assert.IsNotNull(preferences);
            });
        }
        private void InitializeUI(UserPreferencesModel preferences)
        {
            alreadyWatched = preferences.UserWatchedPresentation;
            endButtonName  = alreadyWatched ? "Close" : "Thanks ! :)";
            minImageIndex  = alreadyWatched ? 1 : 0;

            prevButton.IsEnabled = false;

            nextButton.Click += OnNextClicked;
            prevButton.Click += OnPrevClicked;
        }
Example #19
0
        public OptionsPage()
        {
            _preferencesModel = ViewModelService.UserPreferencesModelFactory
                                .CreateModel();

            var optionsPageControl = ViewModelService.OptionsPageControlFactory
                                     .CreateControl();

            optionsPageControl.DataContext = _preferencesModel;

            Child = optionsPageControl;
        }
        public Task <SaveUserPreferencesMessage.Response> SaveUserPreferences(
            string employeeId,
            UserPreferencesModel userPreferencesModel,
            CancellationToken cancellationToken)
        {
            var userPreferences = new UserPreferences
            {
                EmailNotifications = userPreferencesModel.EmailNotifications,
                PushNotifications  = userPreferencesModel.PushNotifications
            };

            return(this.userPreferencesActor.Ask <SaveUserPreferencesMessage.Response>(new SaveUserPreferencesMessage(employeeId, userPreferences)));
        }
        public Task <SaveUserPreferencesMessage.Response> SaveUserPreferences(
            string userId,
            UserPreferencesModel userPreferencesModel,
            CancellationToken cancellationToken)
        {
            var userPreferences = new UserPreferences
            {
                EmailNotifications = userPreferencesModel.EmailNotifications,
                PushNotifications  = userPreferencesModel.PushNotifications,
                DependentDepartmentsPendingActions = userPreferencesModel.DependentDepartmentsPendingActions
            };

            return(this.userPreferencesActor.Ask <SaveUserPreferencesMessage.Response>(new SaveUserPreferencesMessage(userId, userPreferences)));
        }
Example #22
0
        public void LoadPreferences(UserPreferencesModel model)
        {
            using (SQLiteConnection db = new SQLiteConnection(dbArgs))
            {
                db.Open();
                using (SQLiteDataReader reader = new SQLiteCommand("SELECT * from userPreferences", db).ExecuteReader())
                {
                    while (reader.Read())
                    {
                        PreferenceType prefType = (PreferenceType)reader.GetInt32(0);

                        switch (prefType)
                        {
                        case PreferenceType.PROMPT_OUTSIDE_PLACEHOLDER:
                            model.PromptOutsidePlaceholders = (OutsidePlaceholdersPrefType)reader.GetInt32(1);
                            break;

                        case PreferenceType.PROMPT_SAVE_PROFILE_LAYOUT_CHANGE:
                        case PreferenceType.PROMPT_SAVE_PROFILE_APP_EXIT:
                        case PreferenceType.PROMPT_APPLY_LAYOUT_LAYOUT_CHANGE:
                        case PreferenceType.PROMPT_APPLY_LAYOUT_APP_EXIT:
                            model.SetPromptPreference(prefType, Convert.ToBoolean(reader.GetInt32(1)));
                            break;

                        case PreferenceType.USER_WATCHED_PRESENTATION:
                            model.UserWatchedPresentation = Convert.ToBoolean(reader.GetInt32(1));
                            break;

                        case PreferenceType.LAST_PROFILE:
                            model.LastProfileId = reader.GetInt32(1);
                            break;

                        case PreferenceType.USE_INVARIANT_CULTURE:
                            model.UseInvariantCulture = Convert.ToBoolean(reader.GetInt32(1));
                            break;
                        }
                    }
                    reader.Close();
                }
                db.Close();
            }
        }
Example #23
0
        private void InitializeUI(UserPreferencesModel preferences)
        {
            promptOutsidePlaceholder.IsChecked  = preferences.PromptOutsidePlaceholders == OutsidePlaceholdersPrefType.PROMPT;
            promptOutsidePlaceholder.Visibility = promptOutsidePlaceholder.IsChecked == true ? Visibility.Collapsed : Visibility.Visible;

            promptUnsavedProfiledLayout.IsChecked = preferences.GetSavePromptPreference(PreferenceType.PROMPT_SAVE_PROFILE_LAYOUT_CHANGE);
            promptUnsavedLayoutLayout.IsChecked   = preferences.GetSavePromptPreference(PreferenceType.PROMPT_APPLY_LAYOUT_LAYOUT_CHANGE);
            promptUnsavedProfiledExit.IsChecked   = preferences.GetSavePromptPreference(PreferenceType.PROMPT_SAVE_PROFILE_APP_EXIT);
            promptUnsavedLayoutExit.IsChecked     = preferences.GetSavePromptPreference(PreferenceType.PROMPT_APPLY_LAYOUT_APP_EXIT);

            useInvariantCulture.IsChecked = preferences.UseInvariantCulture;

            promptCheckBoxes = new Dictionary <PreferenceType, CheckBox>
            {
                { PreferenceType.PROMPT_SAVE_PROFILE_LAYOUT_CHANGE, promptUnsavedProfiledLayout },
                { PreferenceType.PROMPT_APPLY_LAYOUT_LAYOUT_CHANGE, promptUnsavedLayoutLayout },
                { PreferenceType.PROMPT_SAVE_PROFILE_APP_EXIT, promptUnsavedProfiledExit },
                { PreferenceType.PROMPT_APPLY_LAYOUT_APP_EXIT, promptUnsavedLayoutExit },
            };

            applyButton.Click += ApplyClicked;
        }
        public void SettingHighlightFileNameToDifferentValueRaisesPropertyChanged()
        {
            // Arrange

            var preferences           = new UserPreferencesModel();
            var propertyChangedRaised = false;

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                propertyChangedRaised = true;
            });

            preferences.PropertyChanged += handler;

            // Act

            preferences.HighlightFileName = true;
            preferences.PropertyChanged  -= handler;

            // Assert

            Assert.IsTrue(propertyChangedRaised);
        }
Example #25
0
        public void ShowSearchBarIsRestoredWhenLoadingUserPreferencesModel()
        {
            // Arrange

            const bool showSearchBar = true;

            var settingsRepository = Mock.Of <IStoredSettingsRepository>(s =>
                                                                         s.GetShowSearchBar() == showSearchBar);

            var preferencesModelRepository = new UserPreferencesModelRepository(
                settingsRepository);

            var preferences = new UserPreferencesModel();

            // Act

            preferencesModelRepository.LoadInto(preferences);

            // Assert

            Mock.Get(settingsRepository).Verify(s => s.GetShowSearchBar());
            Assert.That(preferences.ShowSearchBar, Is.EqualTo(showSearchBar));
        }
Example #26
0
        public void GroupByProjectIsRestoredWhenLoadingUserPreferencesModel()
        {
            // Arrange

            const bool groupByProject = true;

            var settingsRepository = Mock.Of <IStoredSettingsRepository>(s =>
                                                                         s.GetGroupByProject() == groupByProject);

            var preferencesModelRepository = new UserPreferencesModelRepository(
                settingsRepository);

            var preferences = new UserPreferencesModel();

            // Act

            preferencesModelRepository.LoadInto(preferences);

            // Assert

            Mock.Get(settingsRepository).Verify(s => s.GetGroupByProject());
            Assert.That(preferences.GroupByProject, Is.EqualTo(groupByProject));
        }
        public void SettingAssignProjectColoursToDifferentValueRaisesPropertyChanged()
        {
            // Arrange

            var preferences           = new UserPreferencesModel();
            var propertyChangedRaised = false;

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                propertyChangedRaised = true;
            });

            preferences.PropertyChanged += handler;

            // Act

            preferences.AssignProjectColours = true;
            preferences.PropertyChanged     -= handler;

            // Assert

            Assert.IsTrue(propertyChangedRaised);
        }
        public void SettingPathSegmentCountToDifferentValueRaisesPropertyChanged()
        {
            // Arrange

            var preferences           = new UserPreferencesModel();
            var propertyChangedRaised = false;

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                propertyChangedRaised = true;
            });

            preferences.PropertyChanged += handler;

            // Act

            preferences.PathSegmentCount = 7;
            preferences.PropertyChanged -= handler;

            // Assert

            Assert.IsTrue(propertyChangedRaised);
        }
Example #29
0
        public async Task <IActionResult> SaveUserPreferences(
            UserPreferencesModel userPreferencesModel,
            CancellationToken cancellationToken)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest());
            }

            var response = await this.userPreferencesService.SaveUserPreferences(
                this.User.Identity.Name,
                userPreferencesModel,
                cancellationToken);

            switch (response)
            {
            case SaveUserPreferencesMessage.Response _:
                return(this.NoContent());

            default:
                return(this.StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
        public void SettingUnityRefreshDelayToDifferentValueRaisesPropertyChanged()
        {
            // Arrange

            var preferences           = new UserPreferencesModel();
            var propertyChangedRaised = false;

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                propertyChangedRaised = true;
            });

            preferences.PropertyChanged += handler;

            // Act

            preferences.UnityRefreshDelay = 100;
            preferences.PropertyChanged  -= handler;

            // Assert

            Assert.IsTrue(propertyChangedRaised);
        }