Beispiel #1
0
        public void TestXboxDirectoryInfoDeleteBooleanCallsRefresh()
        {
            bool calledDeleteDirectory = false;

            this.shimAdapter.DeleteDirectoryStringXboxPathBoolean = (systemIpAddress, path, isRecursive) =>
            {
                calledDeleteDirectory = true;
            };

            bool success = false;

            ShimXboxFileSystemInfo.AllInstances.Refresh = info =>
            {
                success = true;
                Assert.IsTrue(calledDeleteDirectory);
            };

            ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition()
            {
                PathGet = () => new XboxPath(@"xd:\directory", XboxOperatingSystem.System)
            };

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

            XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(xboxFileShim, this.XboxConsole);

            directoryInfo.Delete(false);
            Assert.IsTrue(success);
        }
Beispiel #2
0
        public void TestXboxDirectoryInfoGetFiles()
        {
            ShimXboxFileSystemInfoDefinition directoryDefinition = new ShimXboxFileSystemInfoDefinition()
            {
                FileAttributesGet = () => FileAttributes.Directory
            };

            ShimXboxFileSystemInfoDefinition fileDefinition = new ShimXboxFileSystemInfoDefinition()
            {
                FileAttributesGet = () => FileAttributes.Archive
            };

            ShimXboxDirectoryInfo.AllInstances.GetFileSystemInfos = _ =>
            {
                return(new XboxFileSystemInfo[]
                {
                    new XboxDirectoryInfo(directoryDefinition, this.XboxConsole),
                    new XboxFileInfo(fileDefinition, this.XboxConsole),
                });
            };

            XboxDirectoryInfo          directoryInfo = new XboxDirectoryInfo(new ShimXboxFileSystemInfoDefinition(), this.XboxConsole);
            IEnumerable <XboxFileInfo> files         = directoryInfo.GetFiles();

            Assert.AreEqual(1, files.Count());
        }
Beispiel #3
0
        public void TestXboxDirectoryInfoCopyXboxToXbox()
        {
            ShimXboxDirectoryInfo.AllInstances.ExistsGet = info => true;
            XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(new ShimXboxFileSystemInfoDefinition(), this.XboxConsole);

            directoryInfo.Copy(@"xd:\directory");
        }
Beispiel #4
0
        public void XboxDirectoryInfoConstructorTest()
        {
            var directoryInfo = new XboxDirectoryInfo(this.xboxDirectoryPath.FullName, this.xboxDirectoryPath.OperatingSystem, this.XboxConsole);

            Assert.IsNotNull(directoryInfo);
            Assert.AreEqual(this.xboxDirectoryPath.FullName, directoryInfo.FullName);
            Assert.AreEqual(this.xboxDirectoryPath.OperatingSystem, directoryInfo.OperatingSystem);
        }
Beispiel #5
0
        public void TestXboxDirectoryInfoInternalConstructor()
        {
            XboxFileSystemInfoDefinition fileSystemInfo = new XboxFileSystemInfoDefinition(0, FileAttributes.Directory, this.xboxDirectoryPath.FullName, this.xboxDirectoryPath.OperatingSystem, 0, 0, 0);
            var directoryInfo = new XboxDirectoryInfo(fileSystemInfo, this.XboxConsole);

            Assert.IsNotNull(directoryInfo);
            Assert.AreEqual(this.xboxDirectoryPath.FullName, directoryInfo.FullName);
            Assert.AreEqual(this.xboxDirectoryPath.OperatingSystem, directoryInfo.OperatingSystem);
        }
Beispiel #6
0
        public void TestXboxDirectoryInfoCopyDirectoryDoesNotExist()
        {
            XboxDirectoryInfo     directoryInfo     = new XboxDirectoryInfo(@"xd:\test", XboxOperatingSystem.System, this.XboxConsole);
            ShimXboxDirectoryInfo shimDirectoryInfo = new ShimXboxDirectoryInfo(directoryInfo)
            {
                ExistsGet = () => false
            };

            directoryInfo.Copy(@"c:\test");
        }
Beispiel #7
0
        public void TestXboxDirectoryInfoGetParentTrailingSlash()
        {
            ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition()
            {
                PathGet = () => new XboxPath(@"xd:\parentDirectory\directory\", XboxOperatingSystem.System)
            };

            var directoryInfo = new XboxDirectoryInfo(xboxFileShim, this.XboxConsole);

            Assert.AreEqual(@"xd:\parentDirectory", directoryInfo.Parent.FullName);
        }
Beispiel #8
0
        public void TestXboxDirectoryInfoGetParentRoot()
        {
            ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition()
            {
                PathGet = () => new XboxPath(@"xd:\", XboxOperatingSystem.System)
            };

            var directoryInfo = new XboxDirectoryInfo(xboxFileShim, this.XboxConsole);

            Assert.IsNull(directoryInfo.Parent);
        }
Beispiel #9
0
        public void TestXboxDirectoryInfoGetRoot()
        {
            ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition()
            {
                PathGet = () => new XboxPath(@"xd:\parent\child", XboxOperatingSystem.System)
            };

            XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(xboxFileShim, this.XboxConsole);

            Assert.AreEqual(@"xd:\", directoryInfo.Root.FullName);
        }
Beispiel #10
0
        public void TestXboxDirectoryInfoDeleteThrowsRootDirectory()
        {
            ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition()
            {
                PathGet = () => new XboxPath(@"xd:\", XboxOperatingSystem.System)
            };

            XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(xboxFileShim, this.XboxConsole);

            directoryInfo.Delete();
        }
Beispiel #11
0
        public void TestXboxDirectoryInfoGetRootInvalidDirectoryPath()
        {
            ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition()
            {
                PathGet = () => new ShimXboxPath()
                {
                    FullNameGet = () => string.Empty
                }
            };

            XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(xboxFileShim, this.XboxConsole);

            Assert.IsNull(directoryInfo.Root);
        }
Beispiel #12
0
        public void TestXboxDirectoryInfoCopyDefaultIsRecursive()
        {
            bool success = false;

            ShimXboxFileSystemInfo.AllInstances.ExistsGet        = info => true;
            ShimXboxDirectoryInfo.AllInstances.CopyStringBoolean = (dirInfo, localPath, isRecursive) =>
            {
                success = true;
                Assert.IsTrue(isRecursive);
            };

            XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(new ShimXboxFileSystemInfoDefinition(), this.XboxConsole);

            directoryInfo.Copy(@"C:\test");
            Assert.IsTrue(success);
        }
Beispiel #13
0
        public void TestXboxDirectoryInfoCreatesChecksExistenceBeforeCreating()
        {
            bool checkedExistence = false;

            ShimXboxDirectoryInfo.AllInstances.ExistsGet = info =>
            {
                checkedExistence = true;
                return(false);
            };

            this.shimAdapter.CreateDirectoryStringXboxPath = (systemIpAddress, path) =>
            {
                Assert.IsTrue(checkedExistence);
            };

            XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(new ShimXboxFileSystemInfoDefinition(), this.XboxConsole);

            directoryInfo.Create();
        }
Beispiel #14
0
        public void TestXboxDirectoryInfoCopyCreatesDirectoryIfItDoesNotExist()
        {
            bool success = false;

            ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition()
            {
                PathGet = () => new XboxPath(@"xd:\directory", XboxOperatingSystem.System)
            };

            ShimDirectory.ExistsString          = s => false;
            ShimDirectory.CreateDirectoryString = path =>
            {
                success = true;
                return(null);
            };

            ShimXboxDirectoryInfo.AllInstances.ExistsGet = info => true;
            XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(xboxFileShim, this.XboxConsole);

            directoryInfo.Copy(@"c:\directory");

            Assert.IsTrue(success);
        }
Beispiel #15
0
        public void TestXboxDirectoryInfoThrowsWithInvalidCharactersInPath()
        {
            XboxDirectoryInfo dirInfo = new XboxDirectoryInfo(@"xd:\<>FakeDirectory", XboxOperatingSystem.System, this.XboxConsole);

            Assert.IsNotNull(dirInfo, "The XboxDirectoryInfo constructor should have thrown an exception.");
        }
Beispiel #16
0
        public void TestXboxDirectoryInfoThrowsInvalidXboxDirectoryArgument()
        {
            XboxDirectoryInfo dirInfo = new XboxDirectoryInfo(@"e:\\FakeDirectory", XboxOperatingSystem.System, this.XboxConsole);

            Assert.IsNotNull(dirInfo, "The XboxDirectoryInfo constructor should have thrown an exception.");
        }
Beispiel #17
0
        public void TestXboxDirectoryInfoThrowsNullConsoleArgument()
        {
            XboxDirectoryInfo dirInfo = new XboxDirectoryInfo(this.xboxDirectoryPath.FullName, XboxOperatingSystem.System, null);

            Assert.IsNotNull(dirInfo, "The XboxDirectoryInfo constructor should have thrown an exception.");
        }
Beispiel #18
0
        public void TestXboxDirectoryInfoCopyNullDirectory()
        {
            XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(new ShimXboxFileSystemInfoDefinition(), this.XboxConsole);

            directoryInfo.Copy(null);
        }