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); }
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 TestXboxDirectoryInfoCopyXboxToXbox() { ShimXboxDirectoryInfo.AllInstances.ExistsGet = info => true; XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(new ShimXboxFileSystemInfoDefinition(), this.XboxConsole); directoryInfo.Copy(@"xd:\directory"); }
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); }
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); }
public void TestXboxDirectoryInfoCopyDirectoryDoesNotExist() { XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(@"xd:\test", XboxOperatingSystem.System, this.XboxConsole); ShimXboxDirectoryInfo shimDirectoryInfo = new ShimXboxDirectoryInfo(directoryInfo) { ExistsGet = () => false }; directoryInfo.Copy(@"c:\test"); }
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); }
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 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); }
public void TestXboxDirectoryInfoDeleteThrowsRootDirectory() { ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition() { PathGet = () => new XboxPath(@"xd:\", XboxOperatingSystem.System) }; XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(xboxFileShim, this.XboxConsole); directoryInfo.Delete(); }
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 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); }
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(); }
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); }
public void TestXboxDirectoryInfoThrowsWithInvalidCharactersInPath() { XboxDirectoryInfo dirInfo = new XboxDirectoryInfo(@"xd:\<>FakeDirectory", XboxOperatingSystem.System, this.XboxConsole); Assert.IsNotNull(dirInfo, "The XboxDirectoryInfo constructor should have thrown an exception."); }
public void TestXboxDirectoryInfoThrowsInvalidXboxDirectoryArgument() { XboxDirectoryInfo dirInfo = new XboxDirectoryInfo(@"e:\\FakeDirectory", XboxOperatingSystem.System, this.XboxConsole); Assert.IsNotNull(dirInfo, "The XboxDirectoryInfo constructor should have thrown an exception."); }
public void TestXboxDirectoryInfoThrowsNullConsoleArgument() { XboxDirectoryInfo dirInfo = new XboxDirectoryInfo(this.xboxDirectoryPath.FullName, XboxOperatingSystem.System, null); Assert.IsNotNull(dirInfo, "The XboxDirectoryInfo constructor should have thrown an exception."); }
public void TestXboxDirectoryInfoCopyNullDirectory() { XboxDirectoryInfo directoryInfo = new XboxDirectoryInfo(new ShimXboxFileSystemInfoDefinition(), this.XboxConsole); directoryInfo.Copy(null); }