示例#1
0
        public void TestXboxDirectoryExistsCallsXboxDirectoryInfoExistsImplCorrectly()
        {
            // test when a directory exists:
            bool success = false;

            ShimXboxDirectoryInfo.ExistsImplStringXboxPathXboxConsoleAdapterBase = (systemIpAddress, xboxPath, adapterBase) =>
            {
                success = true;
                Assert.AreEqual(this.XboxConsole.Adapter, adapterBase, "The passed adapter does not equal the original one.");
                return(true);
            };

            Assert.IsTrue(XboxDirectory.Exists(this.xboxDirectoryPath, this.XboxConsole), "The directory should exist.");
            Assert.IsTrue(success, "XboxDirectoryInfo.ExistsImpl wasn't called.");

            // test when a directory doesn't exist:
            success = false;
            ShimXboxDirectoryInfo.ExistsImplStringXboxPathXboxConsoleAdapterBase = (systemIpAddress, xboxPath, adapterBase) =>
            {
                success = true;
                return(false);
            };

            Assert.IsFalse(XboxDirectory.Exists(this.xboxDirectoryPath, this.XboxConsole), "The directory shouldn't exist.");
            Assert.IsTrue(success, "XboxDirectoryInfo.ExistsImpl wasn't called.");
        }
示例#2
0
        public void TestXboxDirectoryDeleteCallsXboxDirectoryInfoDeleteCorrectly()
        {
            bool success = false;

            ShimXboxDirectoryInfo.AllInstances.Delete = xboxDirectoryInfo => { success = true; };
            XboxDirectory.Delete(this.xboxDirectoryPath, this.XboxConsole);
            Assert.IsTrue(success, "XboxDirectoryInfo.Delete wasn't called.");
        }
示例#3
0
        public void TestXboxDirectoryDeleteRecursiveCallsXboxDirectoryInfoDeleteRecursiveCorrectly()
        {
            // test non-recursive:
            bool success   = false;
            bool recursive = false;

            ShimXboxDirectoryInfo.AllInstances.DeleteBoolean = (xboxDirectoryInfo, isRecursive) =>
            {
                success = true;
                Assert.IsTrue(recursive == isRecursive, string.Format(CultureInfo.CurrentCulture, "Recursion behavior does not correspond to the specified parameter ({0}).", recursive));
            };

            XboxDirectory.Delete(this.xboxDirectoryPath, recursive, this.XboxConsole);
            Assert.IsTrue(success, "XboxDirectoryInfo.Delete (recursive) wasn't called.");

            // test recursive:
            success   = false;
            recursive = true;
            XboxDirectory.Delete(this.xboxDirectoryPath, recursive, this.XboxConsole);
            Assert.IsTrue(success, "XboxDirectoryInfo.Delete (recursive) wasn't called.");
        }
示例#4
0
        public void TestXboxDirectoryMoveXboxPCCallsCopyXboxDirectoryInfoDeleteCorrectly()
        {
            int successSequenceChecker = 1;

            ShimXboxDirectory.CopyXboxPathStringXboxConsole = (sourceDirectory, destinationDirectory, console) =>
            {
                successSequenceChecker *= 2;
                Assert.AreEqual(this.xboxDirectoryPath, sourceDirectory, "The source directory is incorrect.");
                Assert.AreEqual(this.pcDirectory, destinationDirectory, "The destination directory is incorrect.");
                Assert.AreEqual(this.XboxConsole, console, "The console is incorrect.");
            };

            ShimXboxDirectoryInfo.AllInstances.DeleteBoolean = (xboxDirectoryInfo, isRecursive) =>
            {
                successSequenceChecker++;
                Assert.IsTrue(string.Equals(this.xboxDirectoryPath.FullName, xboxDirectoryInfo.FullName, StringComparison.OrdinalIgnoreCase) && this.xboxDirectoryPath.OperatingSystem == xboxDirectoryInfo.OperatingSystem, "The directory to be deleted is incorrect.");
                Assert.IsTrue(isRecursive, "The delete should be recursive.");
            };

            XboxDirectory.Move(this.xboxDirectoryPath, this.pcDirectory, this.XboxConsole);
            Assert.IsTrue(successSequenceChecker == 3, "XboxDirectory.Copy and XboxDirectoryInfo.Delete were not called in the required order.");
        }
示例#5
0
        public void TestXboxDirectoryCopyXboxPCCallsXboxDirectoryInfoCopyCorrectly()
        {
            bool success = false;
            IProgress <XboxFileTransferMetric> expectedProgress = null;

            ShimXboxPath.HasXboxOriginString = path => true;
            ShimXboxDirectoryInfo.AllInstances.CopyStringIProgressOfXboxFileTransferMetric = (xboxDirectoryInfo, path, metrics) =>
            {
                success = true;

                Assert.AreEqual(this.xboxDirectoryPath.FullName, xboxDirectoryInfo.FullName, "Copy didn't pass on the correct directory.");
                Assert.AreEqual(this.pcDirectory, path, "Copy didn't pass on the correct xbox directory.");
                Assert.AreSame(expectedProgress, metrics, "Copy didn't pass on the same progress object.");
            };

            XboxDirectory.Copy(this.xboxDirectoryPath, this.pcDirectory, this.XboxConsole);
            Assert.IsTrue(success, "XboxDirectoryInfo.Copy wasn't called.");

            XboxDirectory.Copy(this.xboxDirectoryPath, this.pcDirectory, this.XboxConsole, null);

            expectedProgress = new Progress <XboxFileTransferMetric>();
            XboxDirectory.Copy(this.xboxDirectoryPath, this.pcDirectory, this.XboxConsole, expectedProgress);
        }
示例#6
0
        public void TestXboxDirectoryCopyPCXboxCallsDirectoryInfoCopyToCorrectly()
        {
            bool success = false;
            IProgress <XboxFileTransferMetric> expectedProgress = null;

            ShimXboxPath.HasXboxOriginString = path => true;
            ShimDirectoryInfoExtensions.CopyToDirectoryInfoXboxPathXboxConsoleIProgressOfXboxFileTransferMetric = (directoryInfo, xboxPath, console, metrics) =>
            {
                success = true;
                Assert.AreEqual(this.pcDirectory, directoryInfo.FullName, "Copy didn't pass on the correct directory.");
                Assert.AreEqual(this.xboxDirectoryPath, xboxPath, "Copy didn't pass on the correct xbox directory.");
                Assert.AreSame(expectedProgress, metrics, "Copy didn't pass on the same progress object.");
                return(null);
            };

            XboxDirectory.Copy(this.pcDirectory, this.xboxDirectoryPath, this.XboxConsole);
            Assert.IsTrue(success, "DirectoryInfo.CopyTo wasn't called.");

            XboxDirectory.Copy(this.pcDirectory, this.xboxDirectoryPath, this.XboxConsole, null);

            expectedProgress = new Progress <XboxFileTransferMetric>();
            XboxDirectory.Copy(this.pcDirectory, this.xboxDirectoryPath, this.XboxConsole, expectedProgress);
        }
示例#7
0
 public void TestXboxDirectoryCopyPCXboxNotSupportedDestinationDirectory()
 {
     ShimXboxPath.HasXboxOriginString = path => false;
     XboxDirectory.Copy(this.pcDirectory, this.xboxDirectoryPath, this.XboxConsole);
 }
示例#8
0
 public void TestXboxDirectoryCopyPCXboxArgumentNullDestinationDirectory()
 {
     XboxDirectory.Copy(this.pcDirectory, null, this.XboxConsole);
 }
示例#9
0
 public void TestXboxDirectoryExistsArgumentNullConsole()
 {
     XboxDirectory.Exists(this.xboxDirectoryPath, null);
 }
示例#10
0
 public void TestXboxDirectoryCopyXboxPCNotSupportedSourceDirectory()
 {
     ShimXboxPath.HasXboxOriginString = path => false;
     XboxDirectory.Copy(this.xboxDirectoryPath, this.pcDirectory, this.XboxConsole);
 }
示例#11
0
 public void TestXboxDirectoryCopyXboxPCArgumentNullSourceDirectory()
 {
     XboxDirectory.Copy(null, this.pcDirectory, this.XboxConsole);
 }