public void GetIApplicationViewCollection_ReturnsValidComObject()
        {
            var factory = new ComObjectFactory();
            var result  = factory.GetIApplicationViewCollection();

            Assert.NotNull(result);
        }
        /// <summary>
        ///     Moves window to selected virtual desktop.
        /// </summary>
        /// <param name="process">Valid process with MainWindowHandle set</param>
        /// <param name="desktopId">Id of a desktop counting from left, firt one is 0</param>
        public static Guid MoveToDesktop(this Process process, int desktopId)
        {
            ValidateProcessWindow(process);

            var availableVirtualDesktops = GetAvailableVirtualDesktops();

            if (availableVirtualDesktops.Count < desktopId)
            {
                return(Guid.Empty);
            }

            var targetVirtualDesktop = availableVirtualDesktops.ElementAt(desktopId);

            ComObjectFactory.GetIApplicationViewCollection().GetViewForHwnd(
                process.MainWindowHandle,
                out var iApplicationView);

            ComObjectFactory.GetVirtualDesktopManagerInternal().MoveViewToDesktop(
                iApplicationView,
                targetVirtualDesktop
                );

            return(targetVirtualDesktop.GetID());
        }