public void TestXboxFileInfoDelete()
        {
            string path = @"xd:\parentDirectory\file";
            XboxOperatingSystem operatingSystem = XboxOperatingSystem.System;

            bool success = false;

            this.shimAdapter.DeleteFileStringXboxPath = (systemIpAddress, xboxPath) =>
            {
                Assert.IsTrue(path.Equals(xboxPath.FullName, StringComparison.OrdinalIgnoreCase), "The path is not the correct path.");
                Assert.IsTrue(operatingSystem == xboxPath.OperatingSystem, "The operating system is not the correct operating system.");
                success = true;
            };

            ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition()
            {
                PathGet = () => new XboxPath(path, operatingSystem)
            };

            ShimXboxFileSystemInfo.ExistsImplStringXboxPathFuncOfXboxFileSystemInfoDefinitionBooleanXboxConsoleAdapterBase = (address, xboxPath, existsPredicate, adapter) => true;

            XboxFileInfo fileInfo = new XboxFileInfo(xboxFileShim, this.XboxConsole);

            fileInfo.Delete();
            Assert.IsTrue(success);
        }
        /// <summary>
        /// Provides the adapter-specific implementation of the "StopDebug" method.
        /// </summary>
        /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
        /// <param name="operatingSystem">The Xbox operating system.</param>
        /// <param name="processId">The process Id.</param>
        protected override void StopDebugImpl(string systemIpAddress, XboxOperatingSystem operatingSystem, uint processId)
        {
            switch (operatingSystem)
            {
            case XboxOperatingSystem.System:
                if (this.systemXboxDebugMonitorClient == null)
                {
                    this.systemXboxDebugMonitorClient = this.XboxXdk.CreateDebugMonitorClient(systemIpAddress, XboxOperatingSystem.System);
                }

                this.systemXboxDebugMonitorClient.Stop(processId);
                break;

            case XboxOperatingSystem.Title:
                if (this.titleXboxDebugMonitorClient == null)
                {
                    this.titleXboxDebugMonitorClient = this.XboxXdk.CreateDebugMonitorClient(systemIpAddress, XboxOperatingSystem.Title);
                }

                this.titleXboxDebugMonitorClient.Stop(processId);
                break;

            default:
                throw new ArgumentException("This operating system is not supported.");
            }
        }
        public void TestConstructorInitializesProperties()
        {
            const string FakeFilePath = "ContentNotImportant";
            const XboxOperatingSystem OperatingSystem = XboxOperatingSystem.System;
            XboxPath path = new XboxPath(FakeFilePath, OperatingSystem);

            Assert.AreEqual(FakeFilePath, path.FullName, "The constructor for the XboxPath class did not initialize the FilePath property correctly.");
            Assert.AreEqual(OperatingSystem, path.OperatingSystem, "The constructor for the XboxPath class did not initialize the OperatingSystem property correctly.");
        }
        /// <summary>
        /// Starts debug monitoring of an Xbox process.
        /// </summary>
        /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
        /// <param name="operatingSystem">The Xbox operating system.</param>
        /// <param name="processId">The process Id.</param>
        /// <param name="handler">The handler called when a TextReceived event occurs.</param>
        public void StartDebug(string systemIpAddress, XboxOperatingSystem operatingSystem, uint processId, EventHandler <TextEventArgs> handler)
        {
            this.ThrowIfDisposed();
            this.ThrowIfInvalidSystemIpAddress(systemIpAddress);

            this.PerformXdkAction(
                systemIpAddress,
                () => this.StartDebugImpl(systemIpAddress, operatingSystem, processId, handler),
                "Failed to start debug output monitoring.");
        }
        /// <summary>
        /// Stops debug monitoring of an Xbox process.
        /// </summary>
        /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
        /// <param name="operatingSystem">The Xbox operating system.</param>
        /// <param name="processId">The process Id.</param>
        public void StopDebug(string systemIpAddress, XboxOperatingSystem operatingSystem, uint processId)
        {
            this.ThrowIfDisposed();
            this.ThrowIfInvalidSystemIpAddress(systemIpAddress);

            this.PerformXdkAction(
                systemIpAddress,
                () => this.StopDebugImpl(systemIpAddress, operatingSystem, processId),
                "Failed to stop debug output monitoring.");
        }
Example #6
0
        /// <summary>
        /// Initializes a new instance of the XboxPath class.
        /// </summary>
        /// <param name="path">The complete path to the file or directory on the Xbox.</param>
        /// <param name="operatingSystem">The Xbox operating system on which the file resides.</param>
        public XboxPath(string path, XboxOperatingSystem operatingSystem)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentNullException("path");
            }

            this.FullName        = path;
            this.OperatingSystem = operatingSystem;
        }
Example #7
0
        /// <summary>
        /// Initializes a new instance of the XboxProcessDefinition class.
        /// </summary>
        /// <param name="operatingSystem">The Xbox operating system.</param>
        /// <param name="processId">The Id (PID) of the Xbox process.</param>
        /// <param name="imageFileName">The file name of the Xbox process.</param>
        internal XboxProcessDefinition(XboxOperatingSystem operatingSystem, uint processId, string imageFileName)
        {
            // When XTF returns a null imageFileName, we change it to an empty string to avoid breaking our existing code
            // It is not exactly clear why XTF returns a null imageFileName, but it does in some cases.
            if (imageFileName == null)
            {
                imageFileName = string.Empty;
            }

            this.OperatingSystem = operatingSystem;
            this.ProcessId       = processId;
            this.ImageFileName   = imageFileName;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="XboxFileSystemInfo"/> class.
        /// </summary>
        /// <param name="path">The path to the file system object.</param>
        /// <param name="operatingSystem">The operating system on which the file system object resides.</param>
        /// <param name="console">The console on which the file system object resides.</param>
        /// <exception cref="System.ArgumentException">Thrown if given an invalid path.</exception>
        protected XboxFileSystemInfo(string path, XboxOperatingSystem operatingSystem, XboxConsole console)
            : base(console)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentNullException("path");
            }

            if (!XboxPath.IsValidPath(path))
            {
                throw new ArgumentException("Invalid path.", "path");
            }

            this.XboxPath = new XboxPath(path, operatingSystem);
        }
        public void TestConstructorInitializesProperties()
        {
            const ulong               CreationTime    = 0;
            const FileAttributes      FileAttributes  = FileAttributes.System;
            const string              FilePath        = "ContentIsNotImportant";
            const XboxOperatingSystem OperatingSystem = XboxOperatingSystem.System;
            const ulong               FileSize        = 0;
            const ulong               LastAccessTime  = 0;
            const ulong               LastWriteTime   = 0;

            XboxFileSystemInfoDefinition infoDefinition = new XboxFileSystemInfoDefinition(CreationTime, FileAttributes, FilePath, OperatingSystem, FileSize, LastAccessTime, LastWriteTime);

            Assert.AreEqual(DateTime.FromFileTime((long)CreationTime), infoDefinition.CreationTime, "The XboxFileSystemInfoDefinition did not initialize the CreationTime property correctly.");
            Assert.AreEqual(FileAttributes, infoDefinition.FileAttributes, "The XboxFileSystemInfoDefinition did not initialize the FileAttributes property correctly.");
            Assert.AreEqual(FilePath, infoDefinition.Path.FullName, "The XboxFileSystemInfoDefinition did not initialize the Path.FullName property correctly.");
            Assert.AreEqual(OperatingSystem, infoDefinition.Path.OperatingSystem, "The XboxFileSystemInfoDefinition did not initialize the Path.OperatingSystem property correctly.");
            Assert.AreEqual(FileSize, infoDefinition.FileSize, "The XboxFileSystemInfoDefinition did not initialize the FileSize property correctly.");
            Assert.AreEqual(DateTime.FromFileTime((long)LastAccessTime), infoDefinition.LastAccessTime, "The XboxFileSystemInfoDefinition did not initialize the LastAccessTime property correctly.");
            Assert.AreEqual(DateTime.FromFileTime((long)LastWriteTime), infoDefinition.LastWriteTime, "The XboxFileSystemInfoDefinition did not initialize the LastWriteTime property correctly.");
        }
Example #10
0
        /// <summary>
        /// Initializes a new instance of the XboxFileSystemInfoDefinition class.
        /// </summary>
        /// <param name="creationTime">The creation time represented by ticks.</param>
        /// <param name="fileAttributes">The attributes describing this file system object.</param>
        /// <param name="filePath">The path to the file system object.</param>
        /// <param name="operatingSystem">The Xbox operating system on which this file resides.</param>
        /// <param name="fileSize">The size of this file system object.</param>
        /// <param name="lastAccessTime">The last time this file was accessed represented by ticks.</param>
        /// <param name="lastWriteTime">The last time this file was written to represented by ticks.</param>
        public XboxFileSystemInfoDefinition(
            ulong creationTime,
            FileAttributes fileAttributes,
            string filePath,
            XboxOperatingSystem operatingSystem,
            ulong fileSize,
            ulong lastAccessTime,
            ulong lastWriteTime)
        {
            if (string.IsNullOrWhiteSpace(filePath))
            {
                throw new ArgumentNullException("filePath");
            }

            this.CreationTime   = DateTime.FromFileTime((long)creationTime);
            this.FileAttributes = fileAttributes;
            this.Path           = new XboxPath(filePath, operatingSystem);
            this.FileSize       = fileSize;
            this.LastAccessTime = DateTime.FromFileTime((long)lastAccessTime);
            this.LastWriteTime  = DateTime.FromFileTime((long)lastWriteTime);
        }
Example #11
0
        /// <summary>
        /// Runs an executable on the Xbox.
        /// </summary>
        /// <param name="console">The console to run the executable on.</param>
        /// <param name="fileName">The path to an executable to start.</param>
        /// <param name="arguments">The command-line arguments to pass into the executable.</param>
        /// <param name="operatingSystem">The <see cref="Microsoft.Internal.GamesTest.Xbox.XboxOperatingSystem"/> to run the executable on.</param>
        /// <param name="outputReceivedCallback">A callback method that will be called when there is output from the process.</param>
        public static void Run(XboxConsole console, string fileName, string arguments, XboxOperatingSystem operatingSystem, Action <string> outputReceivedCallback)
        {
            if (console == null)
            {
                throw new ArgumentNullException("console");
            }

            if (console.IsDisposed)
            {
                throw new ObjectDisposedException("console");
            }

            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("fileName is not valid", "fileName");
            }

            console.Adapter.RunExecutable(console.SystemIpAddressAndSessionKeyCombined, fileName, arguments, operatingSystem, outputReceivedCallback);
        }
        /// <summary>
        /// Gets the list of processes running on a console.
        /// </summary>
        /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
        /// <param name="operatingSystem">The Xbox operating system.</param>
        /// <returns>The enumeration of XboxProcessDefinition instances.</returns>
        public IEnumerable <XboxProcessDefinition> GetRunningProcesses(string systemIpAddress, XboxOperatingSystem operatingSystem)
        {
            this.ThrowIfDisposed();
            this.ThrowIfInvalidSystemIpAddress(systemIpAddress);

            return(this.PerformXdkFunc(
                       systemIpAddress,
                       () => this.GetRunningProcessesImpl(systemIpAddress, operatingSystem),
                       "Failed to get running processes."));
        }
Example #13
0
 /// <summary>
 /// Runs an executable on the Xbox.
 /// </summary>
 /// <param name="console">The console to run the executable on.</param>
 /// <param name="fileName">The path to an executable to start.</param>
 /// <param name="arguments">The command-line arguments to pass into the executable.</param>
 /// <param name="operatingSystem">The <see cref="Microsoft.Internal.GamesTest.Xbox.XboxOperatingSystem"/> to run the application on.</param>
 public static void Run(XboxConsole console, string fileName, string arguments, XboxOperatingSystem operatingSystem)
 {
     Run(console, fileName, arguments, operatingSystem, null);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XboxDirectoryInfo"/> class.
 /// </summary>
 /// <param name="path">The path to the directory.</param>
 /// <param name="operatingSystem">The operating system on which the directory resides.</param>
 /// <param name="console">The console on which the directory resides.</param>
 public XboxDirectoryInfo(string path, XboxOperatingSystem operatingSystem, XboxConsole console)
     : base(path, operatingSystem, console)
 {
 }
 /// <summary>
 /// Provides the adapter-specific implementation of the "StopDebug" method.
 /// </summary>
 /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
 /// <param name="operatingSystem">The Xbox operating system.</param>
 /// <param name="processId">The process Id.</param>
 protected virtual void StopDebugImpl(string systemIpAddress, XboxOperatingSystem operatingSystem, uint processId)
 {
     throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
 }
 /// <summary>
 /// Runs an executable on the console.
 /// </summary>
 /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
 /// <param name="fileName">The path to an executable to start.</param>
 /// <param name="arguments">The command-line arguments to pass into the executable.</param>
 /// <param name="operatingSystem">The <see cref="Microsoft.Internal.GamesTest.Xbox.XboxOperatingSystem"/> to run the executable on.</param>
 /// <param name="outputRecievedCallback">A callback method that will be called when there is output from the process.</param>
 protected override void RunExecutableImpl(string systemIpAddress, string fileName, string arguments, XboxOperatingSystem operatingSystem, Action <string> outputRecievedCallback)
 {
     this.XboxXdk.RunExecutable(systemIpAddress, fileName, arguments, operatingSystem, outputRecievedCallback);
 }
Example #17
0
 /// <summary>
 /// Copies files that match the search pattern from either a PC to an Xbox or from an Xbox to a PC.  The direction of the copy is dependent on the paths
 /// passed to <paramref name="sourceSearchPath"/> and <paramref name="destinationPath"/>.  If one of the paths starts with
 /// the letter "x", then it is considered to be the path to the file on the Xbox.
 /// </summary>
 /// <param name="ipAddress">The IP address of the console to copy a file from or to.</param>
 /// <param name="sourceSearchPath">The search pattern of the files to be copied.  If the files resides on the Xbox then the path must start with the letter "x".  For example, if the
 /// file is on the Xbox's D:\ drive, then the path must start with "XD:\".</param>
 /// <param name="destinationPath">The complete destination path for the file.  If the destination is intended to be on the Xbox then this path must start with the letter "x".
 /// For example, if you wish to copy the file to the D:\ drive, then this path must start with "XD:\".</param>
 /// <param name="targetOperatingSystem">The operating system on the Xbox that you wish to copy the files from or to.</param>
 /// <param name="recursionLevel">The number of levels of recursion to use when searching for files.</param>
 /// <param name="metrics">The progress handler that the calling app uses to receive progress updates about metrics. This may be null.</param>
 public abstract void CopyFiles(string ipAddress, string sourceSearchPath, string destinationPath, XboxOperatingSystem targetOperatingSystem, int recursionLevel, IProgress <XboxFileTransferMetric> metrics);
Example #18
0
 /// <summary>
 /// Runs an executable on the console.
 /// </summary>
 /// <param name="ipAddress">The tools IP address of the console.</param>
 /// <param name="fileName">The path to an executable to start.</param>
 /// <param name="arguments">The command-line arguments to pass into the executable.</param>
 /// <param name="operatingSystem">The <see cref="Microsoft.Internal.GamesTest.Xbox.XboxOperatingSystem"/> to run the executable on.</param>
 /// <param name="outputRecievedCallback">A callback method that will be called when there is output from the process.</param>
 public virtual void RunExecutable(string ipAddress, string fileName, string arguments, XboxOperatingSystem operatingSystem, Action <string> outputRecievedCallback)
 {
     throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
 }
Example #19
0
 /// <summary>
 /// Gets the list of processes running on a console.
 /// </summary>
 /// <param name="ipAddress">The IP address of console.</param>
 /// <param name="operatingSystem">The Xbox operating system.</param>
 /// <returns>The enumeration of XboxProcessDefinition instances.</returns>
 public abstract IEnumerable <XboxProcessDefinition> GetRunningProcesses(string ipAddress, XboxOperatingSystem operatingSystem);
Example #20
0
        private void CheckRunExecutableValueEquality(Type objectType, string toolsIP, string fileName, string arguments, XboxOperatingSystem operatingSystem, Action <string> outputReceivedCallback)
        {
            const string FailedToPassSameValue = "Failed to pass in the same {0} to the {1}.";

            Assert.AreEqual(ConsoleAddress, toolsIP, FailedToPassSameValue, "toolsIP", objectType);
            Assert.AreEqual(ProcessRunTestFileName, fileName, FailedToPassSameValue, "fileName", objectType);
            Assert.AreEqual(ProcessRunTestArguments, arguments, FailedToPassSameValue, "arguments", objectType);
            Assert.AreEqual(ProcessRunTestOperatingSystem, operatingSystem, FailedToPassSameValue, "operatingSystem", objectType);
            Assert.AreSame(this.processRunTestAction, outputReceivedCallback, FailedToPassSameValue, "outputReceivedCallback", objectType);
        }
Example #21
0
 /// <summary>
 /// Creates an Xbox debug monitor client.
 /// </summary>
 /// <param name="ipAddress">The IP address of console.</param>
 /// <param name="operatingSystem">The Xbox operating system.</param>
 /// <returns>The Xbox debug monitor client.</returns>
 public virtual IXboxDebugMonitorClient CreateDebugMonitorClient(string ipAddress, XboxOperatingSystem operatingSystem)
 {
     throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
 }
Example #22
0
 /// <summary>
 /// Removes a directory from an Xbox.
 /// </summary>
 /// <param name="ipAddress">The IP address of the console on which the directory will be deleted.</param>
 /// <param name="remoteDirectoryPath">The complete path to the directory to be deleted.</param>
 /// <param name="targetOperatingSystem">The operating system on the Xbox from which the directory will be removed.</param>
 /// <param name="recursive">A flag to indicate whether or not to recursively delete the contents of the given directory and all
 /// of its children.</param>
 public abstract void RemoveDirectory(string ipAddress, string remoteDirectoryPath, XboxOperatingSystem targetOperatingSystem, bool recursive);
Example #23
0
 /// <summary>
 /// Deletes files from an Xbox.
 /// </summary>
 /// <param name="ipAddress">The IP address of the console on which the files will be deleted.</param>
 /// <param name="remoteFileSearchPattern">The search path for the files to be deleted.</param>
 /// <param name="targetOperatingSystem">The operating system on the Xbox from which the files will be deleted.</param>
 /// <param name="recursionLevel">The number of levels of recursion to use when searching for files to delete.</param>
 public abstract void DeleteFiles(string ipAddress, string remoteFileSearchPattern, XboxOperatingSystem targetOperatingSystem, int recursionLevel);
Example #24
0
 /// <summary>
 /// Creates a directory on the Xbox.
 /// </summary>
 /// <param name="ipAddress">The IP address of the console on which to create the directory.</param>
 /// <param name="destinationDirectoryPath">The path to the directory to be created.</param>
 /// <param name="targetOperatingSystem">The operating system on the Xbox where the directory shall be created.</param>
 public abstract void CreateDirectory(string ipAddress, string destinationDirectoryPath, XboxOperatingSystem targetOperatingSystem);
 /// <summary>
 /// Provides the adapter-specific implementation of the "GetRunningProcesses" method.
 /// </summary>
 /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
 /// <param name="operatingSystem">The Xbox operating system.</param>
 /// <returns>The enumeration of XboxProcessDefinition instances.</returns>
 protected virtual IEnumerable <XboxProcessDefinition> GetRunningProcessesImpl(string systemIpAddress, XboxOperatingSystem operatingSystem)
 {
     throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
 }
 /// <summary>
 /// Provides the adapter-specific implementation of the "GetRunningProcesses" method.
 /// </summary>
 /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
 /// <param name="operatingSystem">The Xbox operating system.</param>
 /// <returns>The enumeration of XboxProcessDefinition instances.</returns>
 protected override IEnumerable <XboxProcessDefinition> GetRunningProcessesImpl(string systemIpAddress, XboxOperatingSystem operatingSystem)
 {
     return(this.XboxXdk.GetRunningProcesses(systemIpAddress, operatingSystem));
 }
 /// <summary>
 /// Provides the adapter-specific implementation of the "StartDebug" method.
 /// </summary>
 /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
 /// <param name="operatingSystem">The Xbox operating system.</param>
 /// <param name="processId">The process Id.</param>
 /// <param name="handler">The handler called when a TextReceived event occurs.</param>
 protected virtual void StartDebugImpl(string systemIpAddress, XboxOperatingSystem operatingSystem, uint processId, EventHandler <TextEventArgs> handler)
 {
     throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
 }
Example #28
0
        /// <summary>
        /// Gets the list of processes running on the console.
        /// </summary>
        /// <param name="operatingSystem">The Xbox operating system.</param>
        /// <returns>The enumeration of XboxProcessInfo instances.</returns>
        public IEnumerable <XboxProcess> GetRunningProcesses(XboxOperatingSystem operatingSystem)
        {
            this.ThrowIfDisposed();

            return(this.Adapter.GetRunningProcesses(this.SystemIpAddressAndSessionKeyCombined, operatingSystem).Select(definition => new XboxProcess(definition, this)));
        }
Example #29
0
 /// <summary>
 /// Retrieves a collection of files on an Xbox that match the given search pattern.
 /// </summary>
 /// <param name="ipAddress">The IP address of the console on which to search for files.</param>
 /// <param name="remoteSearchPattern">The pattern used to search for files.</param>
 /// <param name="targetOperatingSystem">The operating system on the Xbox to search for files.</param>
 /// <param name="recursionLevels">The number of recursion levels to use while searching for matches.</param>
 /// <returns>A enumeration of the files that match the given search pattern.</returns>
 public abstract IEnumerable <XboxFileSystemInfoDefinition> FindFiles(string ipAddress, string remoteSearchPattern, XboxOperatingSystem targetOperatingSystem, int recursionLevels);
        /// <summary>
        /// Runs an executable on the console.
        /// </summary>
        /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
        /// <param name="fileName">The path to an executable to start.</param>
        /// <param name="arguments">The command-line arguments to pass into the executable.</param>
        /// <param name="operatingSystem">The <see cref="Microsoft.Internal.GamesTest.Xbox.XboxOperatingSystem"/> to run the executable on.</param>
        /// <param name="outputReceivedCallback">A callback method that will be called when there is output from the process.</param>
        public void RunExecutable(string systemIpAddress, string fileName, string arguments, XboxOperatingSystem operatingSystem, Action <string> outputReceivedCallback)
        {
            this.ThrowIfDisposed();
            this.ThrowIfInvalidSystemIpAddress(systemIpAddress);

            this.PerformXdkAction(
                systemIpAddress,
                () => this.RunExecutableImpl(systemIpAddress, fileName, arguments, operatingSystem, outputReceivedCallback),
                "Failed to run executable.");
        }