Пример #1
0
        public void DeleteImageSizeShouldDeleteImageSizeWhenSuccessful()
        {
            // arrange
            var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ImageResizerSettings>();
            Func <string, int>    sendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);

            viewModel.AddRow("New Size");
            int       sizeOfOriginalArray = viewModel.Sizes.Count;
            ImageSize deleteCandidate     = viewModel.Sizes.Where <ImageSize>(x => x.Id == 0).First();

            // act
            viewModel.DeleteImageSize(0);

            // Assert
            Assert.AreEqual(sizeOfOriginalArray - 1, viewModel.Sizes.Count);
            Assert.IsFalse(viewModel.Sizes.Contains(deleteCandidate));
        }
Пример #2
0
        public void HighlightOpacity_ShouldSetOpacityValueTo60_WhenSuccessful()
        {
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                FancyZonesSettingsIPCMessage snd = JsonSerializer.Deserialize <FancyZonesSettingsIPCMessage>(msg);
                Assert.AreEqual(60, snd.Powertoys.FancyZones.Properties.FancyzonesHighlightOpacity.Value);
                return(0);
            };

            // arrange
            FancyZonesViewModel viewModel = new FancyZonesViewModel(ISettingsUtilsMocks.GetStubSettingsUtils().Object, SendMockIPCConfigMSG, FancyZonesTestFolderName);

            Assert.AreEqual(50, viewModel.HighlightOpacity);

            // act
            viewModel.HighlightOpacity = 60;
        }
Пример #3
0
        public void OverrideSnapHotkeys_ShouldSetValue2True_WhenSuccessful()
        {
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                FancyZonesSettingsIPCMessage snd = JsonSerializer.Deserialize <FancyZonesSettingsIPCMessage>(msg);
                Assert.IsTrue(snd.Powertoys.FancyZones.Properties.FancyzonesOverrideSnapHotkeys.Value);
                return(0);
            };

            // arrange
            FancyZonesViewModel viewModel = new FancyZonesViewModel(ISettingsUtilsMocks.GetStubSettingsUtils().Object, SendMockIPCConfigMSG, FancyZonesTestFolderName);

            Assert.IsFalse(viewModel.OverrideSnapHotkeys); // check if value was initialized to false.

            // act
            viewModel.OverrideSnapHotkeys = true;
        }
Пример #4
0
        public void ExcludedApps_ShouldSetColorValue2White_WhenSuccessful()
        {
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                FancyZonesSettingsIPCMessage snd = JsonSerializer.Deserialize <FancyZonesSettingsIPCMessage>(msg);
                Assert.AreEqual("Sample", snd.Powertoys.FancyZones.Properties.FancyzonesExcludedApps.Value);
                return(0);
            };

            // arrange
            FancyZonesViewModel viewModel = new FancyZonesViewModel(ISettingsUtilsMocks.GetStubSettingsUtils().Object, SendMockIPCConfigMSG, FancyZonesTestFolderName);

            Assert.AreEqual(string.Empty, viewModel.ExcludedApps);

            // act
            viewModel.ExcludedApps = "Sample";
        }
Пример #5
0
        public void ZoneInActiveColor_ShouldSetColorValue2White_WhenSuccessful()
        {
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                FancyZonesSettingsIPCMessage snd = JsonSerializer.Deserialize <FancyZonesSettingsIPCMessage>(msg);
                Assert.AreEqual("#FFFFFF", snd.Powertoys.FancyZones.Properties.FancyzonesInActiveColor.Value);
                return(0);
            };

            // arrange
            FancyZonesViewModel viewModel = new FancyZonesViewModel(ISettingsUtilsMocks.GetStubSettingsUtils().Object, SendMockIPCConfigMSG, FancyZonesTestFolderName);

            Assert.AreEqual(ConfigDefaults.DefaultFancyZonesInActiveColor, viewModel.ZoneInActiveColor);

            // act
            viewModel.ZoneInActiveColor = "#FFFFFF";
        }
Пример #6
0
        public void UseCursorPosEditorStartupScreen_ShouldSetValue2False_WhenSuccessful()
        {
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                FancyZonesSettingsIPCMessage snd = JsonSerializer.Deserialize <FancyZonesSettingsIPCMessage>(msg);
                Assert.IsTrue(snd.Powertoys.FancyZones.Properties.UseCursorposEditorStartupscreen.Value);
                return(0);
            };

            // arrange
            FancyZonesViewModel viewModel = new FancyZonesViewModel(ISettingsUtilsMocks.GetStubSettingsUtils().Object, SendMockIPCConfigMSG, FancyZonesTestFolderName);

            Assert.IsTrue(viewModel.UseCursorPosEditorStartupScreen); // check if value was initialized to false.

            // act
            viewModel.UseCursorPosEditorStartupScreen = true;
        }
Пример #7
0
        public void ZoneSetChangeFlashZones_ShouldSetValue2False_WhenSuccessful()
        {
            // Assert
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                FancyZonesSettingsIPCMessage snd = JsonSerializer.Deserialize <FancyZonesSettingsIPCMessage>(msg);
                Assert.IsTrue(snd.Powertoys.FancyZones.Properties.FancyzonesMakeDraggedWindowTransparent.Value);
                return(0);
            };

            // arrange
            FancyZonesViewModel viewModel = new FancyZonesViewModel(ISettingsUtilsMocks.GetStubSettingsUtils().Object, SendMockIPCConfigMSG, FancyZonesTestFolderName);

            Assert.IsFalse(viewModel.MakeDraggedWindowsTransparent); // check if value was initialized to false.

            // act
            viewModel.MakeDraggedWindowsTransparent = true;
        }
Пример #8
0
        public void PressTime_ShouldSetPressTimeToOneHundred_WhenSuccessful()
        {
            // Assert
            // Initialize mock function of sending IPC message.
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                ShortcutGuideSettingsIPCMessage snd = JsonSerializer.Deserialize <ShortcutGuideSettingsIPCMessage>(msg);
                Assert.AreEqual(100, snd.Powertoys.ShortcutGuide.Properties.PressTime.Value);
                return(0);
            };

            // Arrange
            ShortcutGuideViewModel viewModel = new ShortcutGuideViewModel(ISettingsUtilsMocks.GetStubSettingsUtils().Object, SendMockIPCConfigMSG, ShortCutGuideTestFolderName);

            Assert.AreEqual(900, viewModel.PressTime);

            // Act
            viewModel.PressTime = 100;
        }
Пример #9
0
        public void NewlyAddedImageSizeHasCorrectValues()
        {
            // arrange
            var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ImageResizerSettings>();
            Func <string, int>    sendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);

            // act
            viewModel.AddRow("New size");

            // Assert
            ImageSize newTestSize = viewModel.Sizes.Where <ImageSize>(x => x.Id == 0).First();

            Assert.AreEqual(newTestSize.Name, "New size 1");
            Assert.AreEqual(newTestSize.Fit, (int)ResizeFit.Fit);
            Assert.AreEqual(newTestSize.Width, 854);
            Assert.AreEqual(newTestSize.Height, 480);
            Assert.AreEqual(newTestSize.Unit, (int)ResizeUnit.Pixel);
        }
Пример #10
0
        public void NameOfNewImageSizesIsIncrementedCorrectly()
        {
            // arrange
            var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ImageResizerSettings>();
            Func <string, int>    sendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);

            // act
            viewModel.AddRow("New size"); // Add: "New size 1"
            viewModel.AddRow("New size"); // Add: "New size 2"
            viewModel.AddRow("New size"); // Add: "New size 3"
            viewModel.DeleteImageSize(1); // Delete: "New size 2"
            viewModel.AddRow("New size"); // Add: "New Size 4"

            // Assert
            Assert.AreEqual(viewModel.Sizes[0].Name, "New size 1");
            Assert.AreEqual(viewModel.Sizes[1].Name, "New size 3");
            Assert.AreEqual(viewModel.Sizes[2].Name, "New size 4");
        }
Пример #11
0
        public void OverlayOpacity_ShouldSeOverlayOpacityToOneHundred_WhenSuccessful()
        {
            // Assert
            // Initialize mock function of sending IPC message.
            Func <string, int> SendMockIPCConfigMSG = msg =>
            {
                ShortcutGuideSettingsIPCMessage snd = JsonSerializer.Deserialize <ShortcutGuideSettingsIPCMessage>(msg);

                // Serialisation not working as expected in the test project:
                Assert.AreEqual(100, snd.Powertoys.ShortcutGuide.Properties.OverlayOpacity.Value);
                return(0);
            };

            // Arrange
            ShortcutGuideViewModel viewModel = new ShortcutGuideViewModel(ISettingsUtilsMocks.GetStubSettingsUtils().Object, SendMockIPCConfigMSG, ShortCutGuideTestFolderName);

            Assert.AreEqual(90, viewModel.OverlayOpacity);

            // Act
            viewModel.OverlayOpacity = 100;
        }
Пример #12
0
        public void SettingsRepositoryInstanceMustBeTheSameAcrossThreads()
        {
            // Multiple tasks try to access and initialize the settings repository class, however they must all access the same settings Repository object.

            // Arrange
            var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <GeneralSettings>();
            List <Task <SettingsRepository <GeneralSettings> > > settingsRepoTasks = new List <Task <SettingsRepository <GeneralSettings> > >();
            int numberOfTasks = 100;

            for (int i = 0; i < numberOfTasks; i++)
            {
                settingsRepoTasks.Add(GetSettingsRepository(mockSettingsUtils.Object));
            }

            // Act
            Task.WaitAll(settingsRepoTasks.ToArray());

            // Assert
            for (int i = 0; i < numberOfTasks - 1; i++)
            {
                Assert.IsTrue(object.ReferenceEquals(settingsRepoTasks[i].Result, settingsRepoTasks[i + 1].Result));
            }
        }
Пример #13
0
 public void SetUpStubSettingUtils()
 {
     mockGeneralSettingsUtils       = ISettingsUtilsMocks.GetStubSettingsUtils <GeneralSettings>();
     mockPowerRenamePropertiesUtils = ISettingsUtilsMocks.GetStubSettingsUtils <PowerRenameLocalProperties>();
 }
Пример #14
0
 public void SetUp_StubSettingUtils()
 {
     mockGeneralSettingsUtils       = ISettingsUtilsMocks.GetStubSettingsUtils <GeneralSettings>();
     mockShortcutGuideSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ShortcutGuideSettings>();
 }
Пример #15
0
        public void ColorPickerIsEnabledByDefault()
        {
            var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ColorPickerSettings>();

            using (var viewModel = new ColorPickerViewModel(ISettingsUtilsMocks.GetStubSettingsUtils <ColorPickerSettings>().Object, SettingsRepository <GeneralSettings> .GetInstance(ISettingsUtilsMocks.GetStubSettingsUtils <GeneralSettings>().Object), ColorPickerIsEnabledByDefaultIPC))
            {
                Assert.IsTrue(viewModel.IsEnabled);
            }
        }
Пример #16
0
 public void SetUpStubSettingUtils()
 {
     mockPowerPreviewSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <PowerPreviewSettings>();
     mockGeneralSettingsUtils      = ISettingsUtilsMocks.GetStubSettingsUtils <GeneralSettings>();
 }
Пример #17
0
 public void SetUpStubSettingUtils()
 {
     mockGeneralSettingsUtils    = ISettingsUtilsMocks.GetStubSettingsUtils <GeneralSettings>();
     mockImgResizerSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ImageResizerSettings>();
 }
Пример #18
0
 public void SetUpStubSettingUtils()
 {
     mockGeneralSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <GeneralSettings>();
 }
Пример #19
0
 public void SetUp_StubSettingUtils()
 {
     mockGeneralSettingsUtils    = ISettingsUtilsMocks.GetStubSettingsUtils <GeneralSettings>();
     mockFancyZonesSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <FancyZonesSettings>();
 }