Example #1
0
        public void Given_Rectangle_Width_5_Height_5_When_ComputePerimeter_Then_20()
        {
            double    expected = 20;
            Rectangle input    = new Rectangle();

            input.Width  = 5;
            input.Height = 5;
            RectangleService service = new RectangleService();

            service.Target = input;
            double actual = service.ComputePerimeter();

            Assert.AreEqual(expected, actual);
        }
Example #2
0
        protected override void CreateComponents()
        {
            RunServiceImpl       = new RunService(RunWindowStrategy.WinForms);
            KeyServiceImpl       = new KeyServiceHotKey(RunServiceImpl);
            RectangleServiceImpl = new RectangleService();
            WindowOsServiceImpl  = new WindowOsService();
            WindowRepositoryImpl = new WindowRepository(new WindowId.WindowIdEqualityComparer());
            ScreenOsServiceImpl  = new ScreenOsService();
            ScreenRepositoryImpl = new ScreenRepository();

            AddComponent(RunService);
            AddComponent(KeyService);
            AddComponent(RectangleService);
            AddComponent(WindowOsService);
            AddComponent(WindowRepository);
            AddComponent(ScreenOsService);
            AddComponent(ScreenRepository);
        }
Example #3
0
        public void MultiFocusTest()
        {
            TraceFile.SetName("MultiFocusTest");

            AddAction(KeyModifier.Alt, "S", "Quit", () => RunService.Stop());

            var testWindows      = GetTestWindows.ToList();
            var testWindowsCount = testWindows.Count;
            int currentPosition  = -1;

            var     screens = ScreenOsService.GetScreens();
            IScreen screen  = screens.Last();

            foreach (var testWindow in testWindows)
            {
                this.LogLine("Window : {0}", testWindow.ToRepr());
            }

            var trayWindows = GetTrayWindows;

            trayWindows = trayWindows.Where(w => RectangleService.Intersect(w.RectangleCurrent, screen.Rectangle) != null);

            foreach (var trayWindowItem in trayWindows)
            {
                this.LogLine("Tray Window : {0}", trayWindowItem.ToRepr());
            }
            var trayWindow = trayWindows.First();

            void focusNext()
            {
                currentPosition++;
                currentPosition %= testWindowsCount;
                this.LogLine("  -> Focusing {0}]", testWindows[currentPosition].ToRepr());
                WindowOsServiceImpl.FocusWindowSync(testWindows[currentPosition]);
            }

            void focusPrev()
            {
                currentPosition += testWindowsCount;
                currentPosition--;
                currentPosition %= testWindowsCount;
                this.LogLine("  -> Focusing {0}]", testWindows[currentPosition].ToRepr());
                WindowOsServiceImpl.FocusWindowSync(testWindows[currentPosition]);
            }

            void moveToNewPosition(int newPosition)
            {
                var currentWindow = testWindows[currentPosition];

                testWindows.Remove(currentWindow);
                testWindows.Insert(newPosition, currentWindow);

                this.LogLine("  -> Moving {0}]", currentWindow.ToRepr());

                DispatchOnScreen(testWindows, screen);
                currentPosition = newPosition;
                WindowOsServiceImpl.FocusWindowSync(currentWindow);
            }

            void moveToNext()
            {
                var newPosition = (currentPosition + 1) % testWindowsCount;

                moveToNewPosition(newPosition);
            }

            void moveToPrev()
            {
                var newPosition = (currentPosition + testWindowsCount - 1) % testWindowsCount;

                moveToNewPosition(newPosition);
            }

            AddAction(KeyModifier.Alt, "Left", "FocusPrev", focusPrev);
            AddAction(KeyModifier.Alt, "Right", "FocusNext", focusNext);
            AddAction(KeyModifier.Alt, "J", "MoveToPrev", moveToPrev);
            AddAction(KeyModifier.Alt, "K", "MoveToNext", moveToNext);

            DispatchOnScreen(testWindows, screen);

            WindowOsServiceImpl.HideSync(trayWindow);
            focusNext();
            RunService.Run();

            foreach (var testWindow in testWindows)
            {
                WindowOsServiceImpl.UnmanageSync(testWindow);
            }
            WindowOsServiceImpl.ShowSync(trayWindow);
        }