예제 #1
0
        public void IsLightThemeRadioButtonChecked_ShouldThemeToLight_WhenSuccessful()
        {
            // Arrange
            GeneralViewModel viewModel = null;
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.AreEqual("light", snd.GeneralSettings.Theme);
                return(0);
            };

            Func <string, int> SendRestartAdminIPCMessage    = msg => { return(0); };
            Func <string, int> SendCheckForUpdatesIPCMessage = msg => { return(0); };

            viewModel = new GeneralViewModel(
                "GeneralSettings_RunningAsAdminText",
                "GeneralSettings_RunningAsUserText",
                false,
                false,
                UpdateUIThemeMethod,
                SendMockIPCConfigMSG,
                SendRestartAdminIPCMessage,
                SendCheckForUpdatesIPCMessage,
                generalSettings_file_name);
            Assert.IsFalse(viewModel.IsLightThemeRadioButtonChecked);

            // act
            viewModel.IsLightThemeRadioButtonChecked = true;
        }
예제 #2
0
        public void Startup_ShouldEnableRunOnStartUp_WhenSuccessful()
        {
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.Startup);
                return(0);
            };

            // Arrange
            Func <string, int> SendRestartAdminIPCMessage    = msg => { return(0); };
            Func <string, int> SendCheckForUpdatesIPCMessage = msg => { return(0); };
            GeneralViewModel   viewModel = new GeneralViewModel(
                "GeneralSettings_RunningAsAdminText",
                "GeneralSettings_RunningAsUserText",
                false,
                false,
                UpdateUIThemeMethod,
                SendMockIPCConfigMSG,
                SendRestartAdminIPCMessage,
                SendCheckForUpdatesIPCMessage,
                generalSettings_file_name);

            Assert.IsFalse(viewModel.Startup);

            // act
            viewModel.Startup = true;
        }
예제 #3
0
        private int ColorPickerIsEnabledByDefault_IPC(string msg)
        {
            OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);

            Assert.IsTrue(snd.GeneralSettings.Enabled.ColorPicker);
            return(0);
        }
예제 #4
0
        public void IsLightThemeRadioButtonCheckedShouldThemeToLightWhenSuccessful()
        {
            // Arrange
            GeneralViewModel viewModel = null;

            // Assert
            Func <string, int> sendMockIPCConfigMSG = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.AreEqual("light", snd.GeneralSettings.Theme);
                return(0);
            };

            Func <string, int> sendRestartAdminIPCMessage    = msg => { return(0); };
            Func <string, int> sendCheckForUpdatesIPCMessage = msg => { return(0); };

            viewModel = new GeneralViewModel(
                settingsRepository: SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object),
                "GeneralSettings_RunningAsAdminText",
                "GeneralSettings_RunningAsUserText",
                false,
                false,
                UpdateUIThemeMethod,
                sendMockIPCConfigMSG,
                sendRestartAdminIPCMessage,
                sendCheckForUpdatesIPCMessage,
                GeneralSettingsFileName);
            Assert.AreNotEqual(1, viewModel.ThemeIndex);

            // act
            viewModel.ThemeIndex = 1;
        }
예제 #5
0
        public void IsDarkThemeRadioButtonCheckedShouldThemeToDarkWhenSuccessful()
        {
            // Arrange
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.AreEqual("dark", snd.GeneralSettings.Theme);
                return(0);
            };

            Func <string, int> SendRestartAdminIPCMessage    = msg => { return(0); };
            Func <string, int> SendCheckForUpdatesIPCMessage = msg => { return(0); };
            GeneralViewModel   viewModel = new GeneralViewModel(
                SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object),
                "GeneralSettings_RunningAsAdminText",
                "GeneralSettings_RunningAsUserText",
                false,
                false,
                UpdateUIThemeMethod,
                SendMockIPCConfigMSG,
                SendRestartAdminIPCMessage,
                SendCheckForUpdatesIPCMessage,
                generalSettingsFileName);

            Assert.IsFalse(viewModel.IsDarkThemeRadioButtonChecked);



            // act
            viewModel.IsDarkThemeRadioButtonChecked = true;
        }
예제 #6
0
        public void RunElevatedShouldEnableAlwaysRunElevatedWhenSuccessful()
        {
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.RunElevated);
                return(0);
            };

            Func <string, int> SendRestartAdminIPCMessage    = msg => { return(0); };
            Func <string, int> SendCheckForUpdatesIPCMessage = msg => { return(0); };

            // Arrange
            GeneralViewModel viewModel = new GeneralViewModel(
                SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object),
                "GeneralSettings_RunningAsAdminText",
                "GeneralSettings_RunningAsUserText",
                false,
                false,
                UpdateUIThemeMethod,
                SendMockIPCConfigMSG,
                SendRestartAdminIPCMessage,
                SendCheckForUpdatesIPCMessage,
                generalSettingsFileName);

            Assert.IsFalse(viewModel.RunElevated);

            // act
            viewModel.RunElevated = true;
        }
예제 #7
0
        public void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
        {
            // Notify UI of property change
            OnPropertyChanged(propertyName);
            OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(GeneralSettingsConfig);

            SendConfigMSG(outsettings.ToString());
        }
예제 #8
0
        public void RaisePropertyChanged([CallerMemberName] string propertyName = null)
        {
            // Notify UI of property change
            OnPropertyChanged(propertyName);

            OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(GeneralSettingsConfigs);

            ShellPage.DefaultSndMSGCallback(outsettings.ToString());
        }
예제 #9
0
        // callback function to launch the URL to check for updates.
        private void CheckForUpdatesClick()
        {
            GeneralSettingsConfig.CustomActionName = "check_for_updates";

            OutGoingGeneralSettings     outsettings  = new OutGoingGeneralSettings(GeneralSettingsConfig);
            GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);

            SendCheckForUpdatesConfigMSG(customaction.ToString());
        }
예제 #10
0
        public void RestartElevated()
        {
            GeneralSettingsConfig.CustomActionName = "restart_elevation";

            OutGoingGeneralSettings     outsettings  = new OutGoingGeneralSettings(GeneralSettingsConfig);
            GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);

            SendRestartAsAdminConfigMSG(customaction.ToString());
        }
예제 #11
0
        public void RequestUpdateCheckedDate()
        {
            GeneralSettingsConfig.CustomActionName = "request_update_state_date";

            OutGoingGeneralSettings     outsettings  = new OutGoingGeneralSettings(GeneralSettingsConfig);
            GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);

            SendCheckForUpdatesConfigMSG(customaction.ToString());
        }
예제 #12
0
        public void Restart_Elevated()
        {
            GeneralSettings settings = _settingsUtils.GetSettings <GeneralSettings>(_settingsConfigFileFolder);

            settings.CustomActionName = "restart_elevation";

            OutGoingGeneralSettings     outsettings  = new OutGoingGeneralSettings(settings);
            GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);

            SendRestartAsAdminConfigMSG(customaction.ToString());
        }
예제 #13
0
        // callback function to launch the URL to check for updates.
        private void CheckForUpdates_Click()
        {
            GeneralSettings settings = _settingsUtils.GetSettings <GeneralSettings>(_settingsConfigFileFolder);

            settings.CustomActionName = "check_for_updates";

            OutGoingGeneralSettings     outsettings  = new OutGoingGeneralSettings(settings);
            GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);

            SendCheckForUpdatesConfigMSG(customaction.ToString());
        }
예제 #14
0
        public void Restart_Elevated()
        {
            GeneralSettings settings = SettingsUtils.GetSettings <GeneralSettings>(string.Empty);

            settings.CustomActionName = "restart_elevation";

            OutGoingGeneralSettings     outsettings  = new OutGoingGeneralSettings(settings);
            GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);

            ShellPage.SndRestartAsAdminMsgCallback?.Invoke(customaction.ToString());
        }
예제 #15
0
        // callback function to launch the URL to check for updates.
        private void CheckForUpdates_Click()
        {
            GeneralSettings settings = SettingsUtils.GetSettings <GeneralSettings>(string.Empty);

            settings.CustomActionName = "check_for_updates";

            OutGoingGeneralSettings     outsettings  = new OutGoingGeneralSettings(settings);
            GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);

            ShellPage.CheckForUpdatesMsgCallback?.Invoke(customaction.ToString());
        }
예제 #16
0
        public void ColorPickerIsEnabledByDefault()
        {
            var viewModel = new ColorPickerViewModel();

            ShellPage.DefaultSndMSGCallback = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.Enabled.ColorPicker);
            };

            Assert.IsTrue(viewModel.IsEnabled);
        }
예제 #17
0
        public void IsEnabled_ShouldEnableModule_WhenSuccessful()
        {
            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel();

            // Assert
            ShellPage.DefaultSndMSGCallback = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.Enabled.ImageResizer);
            };

            // act
            viewModel.IsEnabled = true;
        }
예제 #18
0
        public void IsEnabledShouldEnableModuleWhenSuccessful()
        {
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.Enabled.ImageResizer);
                return(0);
            };

            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel(mockImgResizerSettingsUtils.Object, SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);

            // act
            viewModel.IsEnabled = true;
        }
예제 #19
0
        public void IsEnabled_ShouldEnableModule_WhenSuccessful()
        {
            // Arrange
            ShortcutGuideViewModel viewModel = new ShortcutGuideViewModel();

            // Assert
            // Initialize mock function of sending IPC message.
            ShellPage.DefaultSndMSGCallback = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.Enabled.ShortcutGuide);
            };

            // Act
            viewModel.IsEnabled = true;
        }
예제 #20
0
        public void IsEnabledShouldEnableModuleWhenSuccessful()
        {
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.Enabled.PowerRename);
                return(0);
            };

            // arrange
            PowerRenameViewModel viewModel = new PowerRenameViewModel(mockPowerRenamePropertiesUtils.Object, SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG, generalSettingsFileName);

            // act
            viewModel.IsEnabled = true;
        }
예제 #21
0
        public void IsEnabled_ShouldEnableModule_WhenSuccessful()
        {
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.Enabled.PowerRename);
                return(0);
            };

            // arrange
            PowerRenameViewModel viewModel = new PowerRenameViewModel(ISettingsUtilsMocks.GetStubSettingsUtils().Object, SendMockIPCConfigMSG, generalSettings_file_name);

            // act
            viewModel.IsEnabled = true;
        }
예제 #22
0
        public void IsEnabled_ShouldDisableModule_WhenSuccessful()
        {
            // arrange
            FancyZonesViewModel viewModel = new FancyZonesViewModel();
            Assert.IsTrue(viewModel.IsEnabled); // check if the module is enabled.

            // Assert
            ShellPage.DefaultSndMSGCallback = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize<OutGoingGeneralSettings>(msg);
                Assert.IsFalse(snd.GeneralSettings.Enabled.FancyZones);
            };

            // act
            viewModel.IsEnabled = false;
        }
예제 #23
0
        public void IsEnabled_ShouldEnableModule_WhenSuccessful()
        {
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.Enabled.ImageResizer);
                return(0);
            };

            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG);

            // act
            viewModel.IsEnabled = true;
        }
예제 #24
0
        public void IsEnabledShouldDisableModuleWhenSuccessful()
        {
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsFalse(snd.GeneralSettings.Enabled.FancyZones);
                return(0);
            };

            // arrange
            FancyZonesViewModel viewModel = new FancyZonesViewModel(SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository <FancyZonesSettings> .GetInstance(mockFancyZonesSettingsUtils.Object), SendMockIPCConfigMSG, FancyZonesTestFolderName);

            Assert.IsTrue(viewModel.IsEnabled); // check if the module is enabled.

            // act
            viewModel.IsEnabled = false;
        }
예제 #25
0
        public void RunElevated_ShouldEnableAlwaysRunElevated_WhenSuccessful()
        {
            // Arrange
            GeneralViewModel viewModel = new GeneralViewModel();

            Assert.IsFalse(viewModel.RunElevated);

            // Assert
            ShellPage.DefaultSndMSGCallback = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.RunElevated);
            };

            // act
            viewModel.RunElevated = true;
        }
예제 #26
0
        public void Startup_ShouldEnableRunOnStartUp_WhenSuccessful()
        {
            // Arrange
            GeneralViewModel viewModel = new GeneralViewModel();

            Assert.IsFalse(viewModel.Startup);

            // Assert
            ShellPage.DefaultSndMSGCallback = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.Startup);
            };

            // act
            viewModel.Startup = true;
        }
예제 #27
0
        public void IsDarkThemeRadioButtonChecked_ShouldThemeToDark_WhenSuccessful()
        {
            // Arrange
            GeneralViewModel viewModel = new GeneralViewModel();

            Assert.IsFalse(viewModel.IsDarkThemeRadioButtonChecked);

            // Assert
            ShellPage.DefaultSndMSGCallback = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.AreEqual("dark", snd.GeneralSettings.Theme);
            };

            // act
            viewModel.IsDarkThemeRadioButtonChecked = true;
        }
예제 #28
0
        public void AutoDownloadUpdates_ShouldEnableAutoDownloadUpdates_WhenSuccessful()
        {
            // Arrange
            GeneralViewModel viewModel = new GeneralViewModel();

            Assert.IsFalse(viewModel.AutoDownloadUpdates);

            // Assert
            ShellPage.DefaultSndMSGCallback = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.AutoDownloadUpdates);
            };

            // act
            viewModel.AutoDownloadUpdates = true;
        }
예제 #29
0
        public void IsEnabled_ShouldEnableModule_WhenSuccessful()
        {
            // Assert
            // Initialize mock function of sending IPC message.
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.Enabled.ShortcutGuide);
                return(0);
            };

            // Arrange
            ShortcutGuideViewModel viewModel = new ShortcutGuideViewModel(SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository <ShortcutGuideSettings> .GetInstance(mockShortcutGuideSettingsUtils.Object), SendMockIPCConfigMSG, ShortCutGuideTestFolderName);

            // Act
            viewModel.IsEnabled = true;
        }
예제 #30
0
        // callback function to launch the URL to check for updates.
        private void CheckForUpdatesClick()
        {
            IsNewVersionDownloading = string.IsNullOrEmpty(UpdatingSettingsConfig.DownloadedInstallerFilename);
            NotifyPropertyChanged(nameof(IsDownloadAllowed));

            if (_isNewVersionChecked)
            {
                _isNewVersionChecked = !IsNewVersionDownloading;
                NotifyPropertyChanged(nameof(IsNewVersionCheckedAndUpToDate));
            }

            GeneralSettingsConfig.CustomActionName = "check_for_updates";

            OutGoingGeneralSettings     outsettings  = new OutGoingGeneralSettings(GeneralSettingsConfig);
            GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);

            SendCheckForUpdatesConfigMSG(customaction.ToString());
        }