public void TestXboxFileInfoCopy() { XboxFileInfo fileInfo = new XboxFileInfo( new ShimXboxFileSystemInfoDefinition() { PathGet = () => new XboxPath(@"xd:\parentDirectory\file", XboxOperatingSystem.System) }, this.XboxConsole); string expectedDestination = @"c:\parentDirectory\file"; IProgress <XboxFileTransferMetric> expectedMetric = null; bool success = false; this.shimAdapter.ReceiveFileStringXboxPathStringIProgressOfXboxFileTransferMetric = (systemIpAddress, sourceFilePath, destinationFilePath, metrics) => { success = true; Assert.AreEqual(fileInfo.FullName, sourceFilePath.FullName, "Copy didn't pass the expected source file path to the adapter."); Assert.AreEqual(expectedDestination, destinationFilePath, "Copy didn't pass the expected destination file path to the adapter."); Assert.AreSame(expectedMetric, metrics, "Copy didn't pass the expected destination file path to the adapter."); }; fileInfo.Copy(expectedDestination); Assert.IsTrue(success); fileInfo.Copy(expectedDestination, null); expectedMetric = new Progress <XboxFileTransferMetric>(); fileInfo.Copy(expectedDestination, expectedMetric); }
public void TestXboxFileInfoCopyTargetDirectoryDoesNotExist() { this.shimAdapter.ReceiveFileStringXboxPathStringIProgressOfXboxFileTransferMetric = (systemIpAddress, sourceFilePath, destinationFilePath, metrics) => { throw new DirectoryNotFoundException(); }; XboxFileInfo fileInfo = new XboxFileInfo(@"xd:\file", XboxOperatingSystem.System, this.XboxConsole); fileInfo.Copy(@"c:\parentDirectoryThatDoesNotExist\file"); }
public void TestXboxFileInfoCopyTargetDirectoryNull() { this.shimAdapter.ReceiveFileStringXboxPathStringIProgressOfXboxFileTransferMetric = (systemIpAddress, sourceFilePath, destinationFilePath, metrics) => { throw new ArgumentNullException("destinationFilePath"); }; XboxFileInfo fileInfo = new XboxFileInfo(new ShimXboxFileSystemInfoDefinition(), this.XboxConsole); fileInfo.Copy(null); }
public void TestXboxFileInfoDeleteCallsRefresh() { bool calledDeleteFile = false; this.shimAdapter.DeleteFileStringXboxPath = (systemIpAddress, path) => { calledDeleteFile = true; }; bool success = false; ShimXboxFileSystemInfo.AllInstances.Refresh = info => { success = true; Assert.IsTrue(calledDeleteFile); }; ShimXboxFileSystemInfoDefinition xboxFileShim = new ShimXboxFileSystemInfoDefinition() { PathGet = () => new XboxPath(@"xd:\parentDirectory\file", XboxOperatingSystem.System) }; ShimXboxFileSystemInfo.ExistsImplStringXboxPathFuncOfXboxFileSystemInfoDefinitionBooleanXboxConsoleAdapterBase = (address, xboxPath, existsPredicate, adapter) => true; XboxFileInfo fileInfo = new XboxFileInfo(xboxFileShim, this.XboxConsole); fileInfo.Delete(); Assert.IsTrue(success); }
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); }
public void XboxFileInfoConstructorXboxPathTest() { var fileInfo = new XboxFileInfo(this.xboxFilePath, this.XboxConsole); Assert.IsNotNull(fileInfo); Assert.AreEqual(this.xboxFilePath.FullName, fileInfo.FullName); Assert.AreEqual(this.xboxFilePath.OperatingSystem, fileInfo.OperatingSystem); }
public void TestXboxFileInfoInternalConstructor() { XboxFileSystemInfoDefinition fileSystemInfo = new XboxFileSystemInfoDefinition(0, FileAttributes.Normal, this.xboxFilePath.FullName, this.xboxFilePath.OperatingSystem, 0, 0, 0); var fileInfo = new XboxFileInfo(fileSystemInfo, this.XboxConsole); Assert.IsNotNull(fileInfo); Assert.AreEqual(this.xboxFilePath.FullName, fileInfo.FullName); Assert.AreEqual(this.xboxFilePath.OperatingSystem, fileInfo.OperatingSystem); }
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); }
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); }
public void TestXboxFileInfoThrowsWithInvalidCharactersInPath() { XboxFileInfo dirInfo = new XboxFileInfo(@"xd:\<>FakeFile", XboxOperatingSystem.System, this.XboxConsole); Assert.IsNotNull(dirInfo, "The XboxFileInfo constructor should have thrown an exception."); }
public void TestXboxFileInfoThrowsInvalidXboxFileArgument() { XboxFileInfo dirInfo = new XboxFileInfo(@"e:\\FakeFile", XboxOperatingSystem.System, this.XboxConsole); Assert.IsNotNull(dirInfo, "The XboxFileInfo constructor should have thrown an exception."); }
public void TestXboxFileInfoThrowsNullConsoleArgument() { XboxFileInfo dirInfo = new XboxFileInfo(this.xboxFilePath.FullName, XboxOperatingSystem.System, null); Assert.IsNotNull(dirInfo, "The XboxFileInfo constructor should have thrown an exception."); }
public void TestXboxFileInfoThrowsNullPathArgument() { XboxFileInfo dirInfo = new XboxFileInfo(null, XboxOperatingSystem.System, this.XboxConsole); Assert.IsNotNull(dirInfo, "The XboxFileInfo constructor should have thrown an exception."); }