Ejemplo n.º 1
0
        public void ValidSettings_ReturnsTrue_WhenAllSettingsMakeSense()
        {
            var winConfig = new Fake_WindowConfiguration("winOne");
            winConfig.Left = 10;
            winConfig.Top = 20;
            winConfig.Width = 30;
            winConfig.Height = 40;

            Assert.IsTrue(winConfig.ValidSettings());
        }
        public void ValidSettings_ReturnsFalse_WhenHeightNegative()
        {
            var winConfig = new Fake_WindowConfiguration("winOne");
            winConfig.Left = 10;
            winConfig.Top = 20;
            winConfig.Width = 30;
            winConfig.Height = -2147483648;

            Assert.IsFalse(winConfig.ValidSettings());
        }
Ejemplo n.º 3
0
        public void ValidSettings_ReturnsFalse_WhenAtLeastOneSettingDoesNotMakeSense()
        {
            var winConfig = new Fake_WindowConfiguration("winOne");
            winConfig.Left = 10;
            //winConfig.Top = 20;
            winConfig.Width = 30;
            winConfig.Height = 40;

            Assert.IsFalse(winConfig.ValidSettings());
        }
Ejemplo n.º 4
0
        public void ValidSettings_ReturnsFalse_WhenAtLeastOneSettingDoesNotMakeSense()
        {
            var winConfig = new Fake_WindowConfiguration("winOne");

            winConfig.Left = 10;
            //winConfig.Top = 20;
            winConfig.Width  = 30;
            winConfig.Height = 40;

            Assert.IsFalse(winConfig.ValidSettings());
        }
Ejemplo n.º 5
0
        public void ValidSettings_ReturnsTrue_WhenAllSettingsMakeSense()
        {
            var winConfig = new Fake_WindowConfiguration("winOne");

            winConfig.Left   = 10;
            winConfig.Top    = 20;
            winConfig.Width  = 30;
            winConfig.Height = 40;

            Assert.IsTrue(winConfig.ValidSettings());
        }
Ejemplo n.º 6
0
        public void LoadSettings_WillLoadFromRegistryBranchOfSpecificCiderWindow_Always()
        {
            var winConfig = new Fake_WindowConfiguration("winOne");
            winConfig.ForcedSettingsToLoad["Left"] = 10;
            winConfig.ForcedSettingsToLoad["Top"] = 20;
            winConfig.ForcedSettingsToLoad["Width"] = 30;
            winConfig.ForcedSettingsToLoad["Height"] = 40;

            winConfig.LoadSettings();

            Assert.AreEqual(@"HKEY_CURRENT_USER\Software\Cider-x64\1.0.0\winOne", winConfig.RegKeysLoadedFrom[0].RegPath);
        }
Ejemplo n.º 7
0
        public void LoadSettings_WillLoadFromRegistryBranchOfSpecificCiderWindow_Always()
        {
            var winConfig = new Fake_WindowConfiguration("winOne");

            winConfig.ForcedSettingsToLoad["Left"]   = 10;
            winConfig.ForcedSettingsToLoad["Top"]    = 20;
            winConfig.ForcedSettingsToLoad["Width"]  = 30;
            winConfig.ForcedSettingsToLoad["Height"] = 40;

            winConfig.LoadSettings();

            Assert.AreEqual(@"HKEY_CURRENT_USER\Software\Cider-x64\1.0.0\winOne", winConfig.RegKeysLoadedFrom[0].RegPath);
        }
Ejemplo n.º 8
0
        public void LoadSettings_WillLoadWindowDimensions_Always()
        {
            var winConfig = new Fake_WindowConfiguration("winOne");
            winConfig.ForcedSettingsToLoad["Left"] = 10;
            winConfig.ForcedSettingsToLoad["Top"] = 20;
            winConfig.ForcedSettingsToLoad["Width"] = 30;
            winConfig.ForcedSettingsToLoad["Height"] = 40;

            winConfig.LoadSettings();

            Assert.AreEqual(10, winConfig.Left);
            Assert.AreEqual(20, winConfig.Top);
            Assert.AreEqual(30, winConfig.Width);
            Assert.AreEqual(40, winConfig.Height);
        }
Ejemplo n.º 9
0
        public void LoadSettings_WillLoadWindowDimensions_Always()
        {
            var winConfig = new Fake_WindowConfiguration("winOne");

            winConfig.ForcedSettingsToLoad["Left"]   = 10;
            winConfig.ForcedSettingsToLoad["Top"]    = 20;
            winConfig.ForcedSettingsToLoad["Width"]  = 30;
            winConfig.ForcedSettingsToLoad["Height"] = 40;

            winConfig.LoadSettings();

            Assert.AreEqual(10, winConfig.Left);
            Assert.AreEqual(20, winConfig.Top);
            Assert.AreEqual(30, winConfig.Width);
            Assert.AreEqual(40, winConfig.Height);
        }
Ejemplo n.º 10
0
        public void SaveSettings_WillSaveWindowDimensions_Always()
        {
            var winConfig = new Fake_WindowConfiguration("winOne");
            winConfig.Left = 10;
            winConfig.Top = 20;
            winConfig.Width = 30;
            winConfig.Height = 40;

            winConfig.SaveSettings();

            Assert.AreEqual(4, winConfig.SettingsSaved.Count);
            Assert.AreEqual(10, winConfig.SettingsSaved["Left"]);
            Assert.AreEqual(20, winConfig.SettingsSaved["Top"]);
            Assert.AreEqual(30, winConfig.SettingsSaved["Width"]);
            Assert.AreEqual(40, winConfig.SettingsSaved["Height"]);
        }
Ejemplo n.º 11
0
        public void SaveSettings_WillSaveWindowDimensions_Always()
        {
            var winConfig = new Fake_WindowConfiguration("winOne");

            winConfig.Left   = 10;
            winConfig.Top    = 20;
            winConfig.Width  = 30;
            winConfig.Height = 40;

            winConfig.SaveSettings();

            Assert.AreEqual(4, winConfig.SettingsSaved.Count);
            Assert.AreEqual(10, winConfig.SettingsSaved["Left"]);
            Assert.AreEqual(20, winConfig.SettingsSaved["Top"]);
            Assert.AreEqual(30, winConfig.SettingsSaved["Width"]);
            Assert.AreEqual(40, winConfig.SettingsSaved["Height"]);
        }
        public void WindowClosed_WillStoreCurrentWindowPositionToWindowConfig_Always()
        {
            var mainVM = new MainViewModel();
            var configGuard = new ConfigurableWindowGuard();
            var win1 = new Mock<IConfigurableWindow>();
            var win2 = new Mock<IConfigurableWindow>();
            configGuard.Init(mainVM);
            var winConfig1 = new Fake_WindowConfiguration("win1");
            var winConfig2 = new Fake_WindowConfiguration("win2");
            var win1Rect = new Rect(10, 20, 100, 200);
            var win2Rect = new Rect(30, 40, 300, 400);
            win1.Setup(window => window.GetPlacement()).Returns(win1Rect);
            win2.Setup(window => window.GetPlacement()).Returns(win2Rect);
            win1.Setup(window => window.GetAlwaysOnTop()).Returns(false);
            win2.Setup(window => window.GetAlwaysOnTop()).Returns(false);
            configGuard.RegisterConfigurableWindow(win1.Object, winConfig1);
            configGuard.RegisterConfigurableWindow(win2.Object, winConfig2);

            win1.Raise(window => window.ConfigurableWindowClosed += null, EventArgs.Empty);
            win2.Raise(window => window.ConfigurableWindowClosed += null, EventArgs.Empty);

            Assert.AreEqual((int)win1Rect.Left,   winConfig1.SettingsSaved["Left"]);
            Assert.AreEqual((int)win1Rect.Top,    winConfig1.SettingsSaved["Top"]);
            Assert.AreEqual((int)win1Rect.Width,  winConfig1.SettingsSaved["Width"]);
            Assert.AreEqual((int)win1Rect.Height, winConfig1.SettingsSaved["Height"]);
            Assert.AreEqual(0 /*false*/, winConfig1.SettingsSaved["IsTopMostWindow"]);
            Assert.AreEqual((int)win2Rect.Left,   winConfig2.SettingsSaved["Left"]);
            Assert.AreEqual((int)win2Rect.Top,    winConfig2.SettingsSaved["Top"]);
            Assert.AreEqual((int)win2Rect.Width,  winConfig2.SettingsSaved["Width"]);
            Assert.AreEqual((int)win2Rect.Height, winConfig2.SettingsSaved["Height"]);
            Assert.AreEqual(0 /*false*/, winConfig2.SettingsSaved["IsTopMostWindow"]);
        }
        public void WindowInitialized_WillPositionWindowAccordingToLoadedConfig_Always()
        {
            var mainVM = new MainViewModel();
            var configGuard = new ConfigurableWindowGuard();
            var win1 = new Mock<IConfigurableWindow>();
            var win2 = new Mock<IConfigurableWindow>();
            configGuard.Init(mainVM);
            var winConfig1 = new Fake_WindowConfiguration("win1");
            var winConfig2 = new Fake_WindowConfiguration("win2");
            var win1Rect = new Rect(10, 20, 100, 200);
            var win2Rect = new Rect(30, 40, 300, 400);
            winConfig1.ForcedSettingsToLoad["Left"] = (int)win1Rect.Left;
            winConfig2.ForcedSettingsToLoad["Left"] = (int)win2Rect.Left;
            winConfig1.ForcedSettingsToLoad["Top"] = (int)win1Rect.Top;
            winConfig2.ForcedSettingsToLoad["Top"] = (int)win2Rect.Top;
            winConfig1.ForcedSettingsToLoad["Width"] = (int)win1Rect.Width;
            winConfig2.ForcedSettingsToLoad["Width"] = (int)win2Rect.Width;
            winConfig1.ForcedSettingsToLoad["Height"] = (int)win1Rect.Height;
            winConfig2.ForcedSettingsToLoad["Height"] = (int)win2Rect.Height;
            winConfig1.ForcedSettingsToLoad["IsTopMostWindow"] = 0 /*false*/;
            winConfig2.ForcedSettingsToLoad["IsTopMostWindow"] = 0 /*false*/;
            configGuard.RegisterConfigurableWindow(win1.Object, winConfig1);
            configGuard.RegisterConfigurableWindow(win2.Object, winConfig2);

            win1.Raise(window => window.ConfigurableWindowInitialized += null, EventArgs.Empty);
            win2.Raise(window => window.ConfigurableWindowInitialized += null, EventArgs.Empty);

            win1.Verify(window => window.SetPlacement(It.Is<Rect>(r => r.Left   == win1Rect.Left)));
            win1.Verify(window => window.SetPlacement(It.Is<Rect>(r => r.Top    == win1Rect.Top)));
            win1.Verify(window => window.SetPlacement(It.Is<Rect>(r => r.Width  == win1Rect.Width)));
            win1.Verify(window => window.SetPlacement(It.Is<Rect>(r => r.Height == win1Rect.Height)));
            win1.Verify(window => window.SetAlwaysOnTop(false));
            win2.Verify(window => window.SetPlacement(It.Is<Rect>(r => r.Left   == win2Rect.Left)));
            win2.Verify(window => window.SetPlacement(It.Is<Rect>(r => r.Top    == win2Rect.Top)));
            win2.Verify(window => window.SetPlacement(It.Is<Rect>(r => r.Width  == win2Rect.Width)));
            win2.Verify(window => window.SetPlacement(It.Is<Rect>(r => r.Height == win2Rect.Height)));
            win2.Verify(window => window.SetAlwaysOnTop(false));
        }