Esempio n. 1
0
        public void RestoreWindowLocationAndSize()
        {
            MockPresentationService presentationService = (MockPresentationService)Container.GetExportedValue <IPresentationService>();

            presentationService.VirtualScreenWidth  = 1000;
            presentationService.VirtualScreenHeight = 700;

            SetSettingsValues(20, 10, 400, 300, true);

            ShellViewModel shellViewModel = Container.GetExportedValue <ShellViewModel>();
            MockShellView  shellView      = (MockShellView)Container.GetExportedValue <IShellView>();

            Assert.AreEqual(20, shellView.Left);
            Assert.AreEqual(10, shellView.Top);
            Assert.AreEqual(400, shellView.Width);
            Assert.AreEqual(300, shellView.Height);
            Assert.IsTrue(shellView.IsMaximized);

            shellView.Left        = 25;
            shellView.Top         = 15;
            shellView.Width       = 450;
            shellView.Height      = 350;
            shellView.IsMaximized = false;

            shellView.Close();
            AssertSettingsValues(25, 15, 450, 350, false);
        }
Esempio n. 2
0
        public void RestoreWindowLocationAndSizeSpecial()
        {
            DataService             dataService         = new DataService();
            MockPresentationService presentationService = (MockPresentationService)Container.GetExportedValue <IPresentationService>();

            presentationService.VirtualScreenWidth  = 1000;
            presentationService.VirtualScreenHeight = 700;

            FloatingViewModel viewModel = Container.GetExportedValue <FloatingViewModel>();
            MockFloatingView  view      = (MockFloatingView)Container.GetExportedValue <IFloatingView>();

            view.SetNAForLocationAndSize();

            SetSettingsValues();
            new FloatingViewModel(view, dataService, presentationService).Close();
            AssertSettingsValues(0, 0);

            // Left = 881 + Width(120) = 901 > VirtualScreenWidth = 1000 => don't apply the Settings values
            SetSettingsValues(881, 100);
            new FloatingViewModel(view, dataService, presentationService).Close();
            AssertSettingsValues(0, 0);

            // Top = 681 + Height(20) = 701 > VirtualScreenWidth = 600 => don't apply the Settings values
            SetSettingsValues(100, 681);
            new FloatingViewModel(view, dataService, presentationService).Close();
            AssertSettingsValues(0, 0);

            // Use the limit values => apply the Settings values
            SetSettingsValues(880, 680);
            new FloatingViewModel(view, dataService, presentationService).Close();
            AssertSettingsValues(880, 680);
        }
Esempio n. 3
0
        public void ModuleControllerLifecycleTest()
        {
            MockPresentationService presentationService = Container.GetExportedValue <MockPresentationService>();
            MockEntityController    entityController    = Container.GetExportedValue <MockEntityController>();
            ModuleController        moduleController    = Container.GetExportedValue <ModuleController>();

            Assert.IsTrue(presentationService.InitializeCulturesCalled);

            // Initialize
            Assert.IsFalse(entityController.InitializeCalled);
            moduleController.Initialize();
            Assert.IsTrue(entityController.InitializeCalled);

            // Run
            MockShellView shellView = Container.GetExportedValue <MockShellView>();

            Assert.IsFalse(shellView.IsVisible);
            moduleController.Run();
            Assert.IsTrue(shellView.IsVisible);

            // Exit the ShellView
            ShellViewModel shellViewModel = ViewHelper.GetViewModel <ShellViewModel>(shellView);

            shellViewModel.ExitCommand.Execute(null);
            Assert.IsFalse(shellView.IsVisible);

            // Shutdown
            Assert.IsFalse(entityController.ShutdownCalled);
            moduleController.Shutdown();
            Assert.IsTrue(entityController.ShutdownCalled);
        }
Esempio n. 4
0
        public void RestoreWindowLocationAndSize()
        {
            MockPresentationService presentationService = (MockPresentationService)Container.GetExportedValue <IPresentationService>();

            presentationService.VirtualScreenWidth  = 1000;
            presentationService.VirtualScreenHeight = 700;

            SetSettingsValues(20, 10, 400, 300);

            MainViewModel viewModel = Container.GetExportedValue <MainViewModel>();
            MockMainView  view      = (MockMainView)Container.GetExportedValue <IMainView>();

            Assert.AreEqual(20, view.Left);
            Assert.AreEqual(10, view.Top);
            Assert.AreEqual(400, view.Width);
            Assert.AreEqual(300, view.Height);

            view.Left   = 25;
            view.Top    = 15;
            view.Width  = 450;
            view.Height = 350;

            view.Close();
            AssertSettingsValues(25, 15, 450, 350);
        }
Esempio n. 5
0
        public void RestoreWindowLocationAndSizeSpecial()
        {
            DataService             dataService         = new DataService();
            MockPresentationService presentationService = (MockPresentationService)Container.GetExportedValue <IPresentationService>();

            presentationService.VirtualScreenWidth  = 1000;
            presentationService.VirtualScreenHeight = 700;

            MockShellView   shellView      = (MockShellView)Container.GetExportedValue <IShellView>();
            IShellService   shellService   = Container.GetExportedValue <IShellService>();
            IMessageService messageService = Container.GetExportedValue <IMessageService>();

            shellView.SetNAForLocationAndSize();

            SetSettingsValues();
            new ShellViewModel(shellView, dataService, presentationService, shellService, messageService).Close();
            AssertSettingsValues(double.NaN, double.NaN, double.NaN, double.NaN, false);

            // Height is 0 => don't apply the Settings values
            SetSettingsValues(0, 0, 1, 0);
            new ShellViewModel(shellView, dataService, presentationService, shellService, messageService).Close();
            AssertSettingsValues(double.NaN, double.NaN, double.NaN, double.NaN, false);

            // Left = 100 + Width = 901 > VirtualScreenWidth = 1000 => don't apply the Settings values
            SetSettingsValues(100, 100, 901, 100);
            new ShellViewModel(shellView, dataService, presentationService, shellService, messageService).Close();
            AssertSettingsValues(double.NaN, double.NaN, double.NaN, double.NaN, false);

            // Top = 100 + Height = 601 > VirtualScreenWidth = 600 => don't apply the Settings values
            SetSettingsValues(100, 100, 100, 601);
            new ShellViewModel(shellView, dataService, presentationService, shellService, messageService).Close();
            AssertSettingsValues(double.NaN, double.NaN, double.NaN, double.NaN, false);

            // Use the limit values => apply the Settings values
            SetSettingsValues(0, 0, 1000, 700);
            new ShellViewModel(shellView, dataService, presentationService, shellService, messageService).Close();
            AssertSettingsValues(0, 0, 1000, 700, false);
        }