Esempio n. 1
0
        public void WindowSizeIsClampedToScreenSize()
        {
            // Arrange
            var screen = new Mock <IVirtualScreen>();

            screen.SetupGet(s => s.Width).Returns(500);
            screen.SetupGet(s => s.Height).Returns(400);

            var screenRepo = new Mock <IScreenRepository>();

            screenRepo.Setup(s => s.GetScreenFromPosition(It.IsAny <double>(), It.IsAny <double>())).Returns(screen.Object);

            var settings = new WindowSettings
            {
                Width      = 1000,
                Height     = 1000,
                ScreenRepo = screenRepo.Object
            };

            var window = new Mock <IWindowAdapter>();

            window.SetupSet(w => w.Width  = 500).Verifiable();
            window.SetupSet(w => w.Height = 400).Verifiable();

            // Act
            settings.Apply(window.Object);

            // Assert
            window.VerifySet(w => w.Width  = 500, Times.Once());
            window.VerifySet(w => w.Height = 400, Times.Once());
        }
Esempio n. 2
0
        public void SettingsAreCorrectlyApplied()
        {
            // Arrange
            var settings = new WindowSettings
            {
                Width  = 1,
                Height = 2,
                Left   = 3,
                Top    = 4,
                State  = WindowState.Maximized
            };

            var window = new Mock <IWindowAdapter>();

            window.SetupSet(w => w.Width       = 1.0).Verifiable();
            window.SetupSet(w => w.Height      = 2.0).Verifiable();
            window.SetupSet(w => w.Left        = 3.0).Verifiable();
            window.SetupSet(w => w.Top         = 4.0).Verifiable();
            window.SetupSet(w => w.WindowState = WindowState.Maximized).Verifiable();

            // Act
            settings.Apply(window.Object);

            // Assert
            window.VerifySet(w => w.Width       = 1.0, Times.Once());
            window.VerifySet(w => w.Height      = 2.0, Times.Once());
            window.VerifySet(w => w.Left        = 3.0, Times.Once());
            window.VerifySet(w => w.Top         = 4.0, Times.Once());
            window.VerifySet(w => w.WindowState = WindowState.Maximized, Times.Once());
        }
Esempio n. 3
0
        public void WindowIsMovedTopOnScreenIfNeeded()
        {
            // Arrange
            var screen = new Mock <IVirtualScreen>();

            screen.SetupGet(s => s.Width).Returns(500);
            screen.SetupGet(s => s.Height).Returns(400);

            var screenRepo = new Mock <IScreenRepository>();

            screenRepo.Setup(s => s.GetScreenFromPosition(It.IsAny <double>(), It.IsAny <double>())).Returns(screen.Object);

            var settings = new WindowSettings
            {
                Width      = 250,
                Height     = 200,
                Left       = 0,
                Top        = 700,
                ScreenRepo = screenRepo.Object
            };

            var window = new Mock <IWindowAdapter>();

            window.SetupSet(w => w.Top = 200).Verifiable();

            // Act
            settings.Apply(window.Object);

            // Assert
            window.VerifySet(w => w.Top = 200, Times.Once());
        }
Esempio n. 4
0
        internal static void ApplyWindowSettings(Window window)
        {
            WindowSettings = WindowSettings.Load(Constants.IO.WindowSettingsFileName);
            WindowSettings?.Apply(new WindowWrapper(window));

            // Default settings contain no width or height so instanciate them only AFTER setting the
            // position otherwise the window would disappear
            if (WindowSettings == null)
            {
                WindowSettings = new WindowSettings();
            }
        }