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 void ShouldThrowFileNotFoundExceptionIfFileDoesNotExist() { // arrange var mountableFile = new MountableFile("/does/not/exist/path"); // act var ex = Record.Exception(() => mountableFile.GetSize()); // assert Assert.IsType <FileNotFoundException>(ex); }
public void ShouldReturnSizeOfFileIfItExists() { // arrange var mountableFile = new MountableFile(_fixture.TempFilePath); // act var actual = mountableFile.GetSize(); // assert Assert.Equal(_fixture.TempFileLengthInBytes, actual); }
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); } }
public TransferToTests(MountableFileFixture fixture) : base(fixture) { _mountableFile = new MountableFile(fixture.TempFilePath); }