예제 #1
0
        public void TestXboxFileCopyPCXboxCallsFileInfoCopyToCorrectly()
        {
            IProgress <XboxFileTransferMetric> expectedProgress = null;

            bool success = false;

            ShimXboxPath.HasXboxOriginString = path => true;
            ShimFileInfoExtensions.CopyToFileInfoXboxPathXboxConsoleIProgressOfXboxFileTransferMetric = (fileInfo, xboxPath, console, metrics) =>
            {
                success = true;

                Assert.AreEqual(this.pcFile, fileInfo.FullName, "Copy didn't pass the expected source file path to the adapter.");
                Assert.AreEqual(this.xboxFilePath.FullName, xboxPath.FullName, "Copy didn't pass the expected destination file path to the adapter.");
                Assert.AreSame(expectedProgress, metrics, "Copy didn't pass the expected destination file path to the adapter.");

                return(null);
            };

            XboxFile.Copy(this.pcFile, this.xboxFilePath, this.XboxConsole);
            Assert.IsTrue(success, "FileInfo.CopyTo wasn't called.");

            XboxFile.Copy(this.pcFile, this.xboxFilePath, this.XboxConsole, null);

            expectedProgress = new Progress <XboxFileTransferMetric>();
            XboxFile.Copy(this.pcFile, this.xboxFilePath, this.XboxConsole, expectedProgress);
        }
예제 #2
0
        public void TestXboxFileExistsCallsXboxFileInfoExistsImplCorrectly()
        {
            // test when a file exists:
            bool success = false;

            ShimXboxFileInfo.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(XboxFile.Exists(this.xboxFilePath, this.XboxConsole), "The file should exist.");
            Assert.IsTrue(success, "XboxFileInfo.ExistsImpl wasn't called.");

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

            Assert.IsFalse(XboxFile.Exists(this.xboxFilePath, this.XboxConsole), "The file shouldn't exist.");
            Assert.IsTrue(success, "XboxFileInfo.ExistsImpl wasn't called.");
        }
예제 #3
0
        public void TestXboxFileDeleteCallsXboxFileInfoDeleteCorrectly()
        {
            bool success = false;

            ShimXboxFileInfo.AllInstances.Delete = xboxFileInfo => { success = true; };
            XboxFile.Delete(this.xboxFilePath, this.XboxConsole);
            Assert.IsTrue(success, "XboxFileInfo.Delete wasn't called.");
        }
예제 #4
0
        public void TestXboxFileMoveXboxPCCallsCopyXboxFileInfoDeleteCorrectly()
        {
            int successSequenceChecker = 1;

            ShimXboxFile.CopyXboxPathStringXboxConsole = (sourceFile, destinationFile, console) =>
            {
                successSequenceChecker *= 2;
                Assert.AreEqual(this.xboxFilePath, sourceFile, "The source file is incorrect.");
                Assert.AreEqual(this.pcFile, destinationFile, "The destination file is incorrect.");
                Assert.AreEqual(this.XboxConsole, console, "The console is incorrect.");
            };

            ShimXboxFileInfo.AllInstances.Delete = xboxFileInfo =>
            {
                successSequenceChecker++;
                Assert.IsTrue(string.Equals(this.xboxFilePath.FullName, xboxFileInfo.FullName, StringComparison.OrdinalIgnoreCase) && this.xboxFilePath.OperatingSystem == xboxFileInfo.OperatingSystem, "The file to be deleted is incorrect.");
            };

            XboxFile.Move(this.xboxFilePath, this.pcFile, this.XboxConsole);
            Assert.IsTrue(successSequenceChecker == 3, "XboxFile.Copy and XboxFileInfo.Delete were not called in the required order.");
        }
예제 #5
0
        public void TestXboxFileCopyXboxPCCallsXboxFileInfoCopyCorrectly()
        {
            IProgress <XboxFileTransferMetric> expectedProgress = null;

            bool success = false;

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

                Assert.AreEqual(this.xboxFilePath.FullName, xboxFileInfo.FullName, "Copy didn't pass the expected source file path to the adapter.");
                Assert.AreEqual(this.pcFile, path, "Copy didn't pass the expected destination file path to the adapter.");
                Assert.AreSame(expectedProgress, metrics, "Copy didn't pass the expected destination file path to the adapter.");
            };

            XboxFile.Copy(this.xboxFilePath, this.pcFile, this.XboxConsole);
            Assert.IsTrue(success, "XboxFileInfo.Copy wasn't called.");
            XboxFile.Copy(this.xboxFilePath, this.pcFile, this.XboxConsole, null);

            expectedProgress = new Progress <XboxFileTransferMetric>();
            XboxFile.Copy(this.xboxFilePath, this.pcFile, this.XboxConsole, expectedProgress);
        }
예제 #6
0
 public void TestXboxFileCopyPCXboxNotSupportedDestinationFile()
 {
     ShimXboxPath.HasXboxOriginString = path => false;
     XboxFile.Copy(this.pcFile, this.xboxFilePath, this.XboxConsole);
 }
예제 #7
0
 public void TestXboxFileCopyPCXboxArgumentNullDestinationFile()
 {
     XboxFile.Copy(this.pcFile, null, this.XboxConsole);
 }
예제 #8
0
 public void TestXboxFileExistsArgumentNullConsole()
 {
     XboxFile.Exists(this.xboxFilePath, null);
 }
예제 #9
0
 public void TestXboxFileCopyXboxPCNotSupportedSourceFile()
 {
     ShimXboxPath.HasXboxOriginString = path => false;
     XboxFile.Copy(this.xboxFilePath, this.pcFile, this.XboxConsole);
 }
예제 #10
0
 public void TestXboxFileCopyXboxPCArgumentNullSourceFile()
 {
     XboxFile.Copy(null, this.pcFile, this.XboxConsole);
 }