Esempio n. 1
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());
        }
        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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public void TestXboxDirectoryInfoDeleteThrowsRootDirectory()
        {
            ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition()
            {
                PathGet = () => new XboxPath(@"xd:\", XboxOperatingSystem.System)
            };

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

            directoryInfo.Delete();
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
        public void TestXboxFileInfoGetDirectoryName()
        {
            ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition()
            {
                PathGet = () => new XboxPath(@"xd:\parentDirectory\file", XboxOperatingSystem.System)
            };

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

            Assert.AreEqual(@"xd:\parentDirectory", fileInfo.DirectoryName);
        }
Esempio n. 9
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);
        }
        public void TestXboxFileInfoGetExtension()
        {
            ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition()
            {
                PathGet = () => new XboxPath(@"xd:\parentDirectory\file.txt", XboxOperatingSystem.System)
            };

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

            Assert.AreEqual(@".txt", fileInfo.Extension);

            xboxFileShim.PathGet = () => new XboxPath(@"xd:\parentDirectory\file", XboxOperatingSystem.System);
            fileInfo             = new XboxFileInfo(xboxFileShim, this.XboxConsole);
            Assert.AreEqual(string.Empty, fileInfo.Extension);
        }
Esempio n. 11
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);
        }