public async Task ShouldThrowArgumentNullExceptionIfTarArchiveIsNull() { // act var ex = await Record.ExceptionAsync(async() => await _mountableFile.TransferTo(null, "my_file")); // assert Assert.IsType <ArgumentNullException>(ex); }
public async Task ShouldTransferRecursivelyToArchiveIfFolderExists() { // arrange var mountableFile = new MountableFile(_fixture.TempFilePath); var destinationFileName = Path.GetFileName(_fixture.TempFilePath); // act await mountableFile.TransferTo(_tarWriteStream, destinationFileName); _tarWriteStream.Close(); // assert using (var tarFileStream = new FileStream(_tarFilePath, FileMode.Open)) using (var tarReadStream = TarArchive.CreateInputTarArchive(tarFileStream)) { var extractionPath = Path.GetTempPath() + "/extracted"; Directory.CreateDirectory(extractionPath); tarReadStream.ExtractContents(extractionPath); var expected = new FileInfo(_fixture.TempFilePath); var actual = new FileInfo(extractionPath + "/" + destinationFileName); Assert.Equal(expected, actual, new FileComparer()); Directory.Delete(extractionPath, true); } }
public async Task ShouldThrowFileNotFoundExceptionIfFolderDoesNotExist() { // arrange var mountableFile = new MountableFile("/does/not/exist/path"); // act var ex = await Record.ExceptionAsync(async() => await mountableFile.TransferTo(_tarWriteStream, ".")); // assert Assert.IsType <FileNotFoundException>(ex); }
public async Task ShouldTransferRecursivelyToArchiveIfFolderExists() { // arrange var mountableFile = new MountableFile(_fixture.TempFolderPath); // act await mountableFile.TransferTo(_tarWriteStream, "."); _tarWriteStream.Close(); // assert using (var tarFileStream = new FileStream(_tarFilePath, FileMode.Open)) using (var tarReadStream = TarArchive.CreateInputTarArchive(tarFileStream)) { var extractionPath = Path.GetTempPath() + "/extracted"; Directory.CreateDirectory(extractionPath); tarReadStream.ExtractContents(extractionPath); AssertDirectoryEquals(_fixture.TempFolderPath, extractionPath); Directory.Delete(extractionPath, true); } }