public void WhenFileDoesNotExist_ThenDoNothing() { var sut = new FileInfo(Path.Combine(WorkingDir, "DoesntExist")); sut.DeleteIfExists(); AssertFile.NotExists(sut); }
public void WhenFileExists_ThenDelete() { var sut = FileBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "Test1.txt")).Build(); sut.DeleteIfExists(); AssertFile.NotExists(sut); }
public void WhenFileExists_ThenAssertFalse() { const string file1 = "NotExists-File1.txt"; BaseDir.CreateFile(file1); Assert.Throws <AssertionException>(() => AssertFile.NotExists(Path.Combine(ExistingDirectoryPath, file1))); }
public void WhenDestinationFileDoesNotExist_ThenMoveFile() { var sourceFile = CreateSourceFile(FileName1); var result = Act(sourceFile.FullName, Path.Combine(DestinationDir, FileName1)); AssertFile.NotExists(sourceFile); AssertFile.Exists(result); }
public void WhenFileHasExtension_ThenRemoveExtension() { var sut = FileBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "Test.txt")).Build(); sut.RemoveExtension(); AssertFile.Exists(Path.Combine(WorkingDir, "Test")); AssertFile.NotExists(Path.Combine(WorkingDir, "Test.txt")); }
public void WhenExistingFileHasNoExtension_ThenAddFileExtension() { var sut = FileBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "Test")).Build(); sut.RenameExtension(".log"); AssertFile.Exists(Path.Combine(WorkingDir, "Test.log")); AssertFile.NotExists(Path.Combine(WorkingDir, "Test")); }
public void WhenExtensionHasNoDotPrefix_ThenAddDotPrefix() { var sut = FileBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "Test.txt")).Build(); sut.RenameExtension("log"); AssertFile.Exists(Path.Combine(WorkingDir, "Test.log")); AssertFile.NotExists(Path.Combine(WorkingDir, "Test.txt")); }
public void WhenNewExtensionIsDifferent_ThenRenameExtension() { var sut = FileBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "Test.txt")).Build(); sut.RenameExtension(".log"); AssertFile.Exists(Path.Combine(WorkingDir, "Test.log")); AssertFile.NotExists(Path.Combine(WorkingDir, "Test.txt")); }
public void WhenDestinationFileAlreadyExists_ThenOverwriteFile() { var sourceFile = CreateSourceFile(FileName1, 1); var destinationFile = CreateDestinationFile(FileName1, 10); var result = Act(sourceFile.FullName, destinationFile.FullName); AssertFile.NotExists(sourceFile); AssertFile.SizeEquals(result, 1); }
public void WhenDestinationFileIsSmaller_ThenOverwriteWithSourceFile() { const int sourceSize = 3; var sourceFile = CreateSourceFile(FileName1, sourceSize); var destinationFile = CreateDestinationFile(FileName1, sourceSize - 1); var result = Act(sourceFile.FullName, destinationFile.FullName); AssertFile.NotExists(sourceFile); AssertFile.SizeEquals(result, sourceSize); }
public void WhenSourceFileIsNewer_ThenMoveFile() { var sourceFile = CreateSourceFile(FileName1); var destinationFile = CreateDestinationFile(FileName1); PauseHalfSecond(); AppendCharToFile(sourceFile.FullName); var result = Act(sourceFile.FullName, destinationFile.FullName); AssertFile.NotExists(sourceFile); AssertFile.Exists(result); }
public void WhenDestinationFileExists_ThenMoveAndRename() { var origFileName = "Test1.txt"; var newFileName = "Test1 (2).txt"; var sourceFile = CreateSourceFile(origFileName, 1); var destinationFile = CreateDestinationFile(origFileName, 10); var result = Act(sourceFile.FullName, destinationFile.FullName); Assert.That(result.Name, Is.EqualTo(newFileName)); AssertFile.NotExists(sourceFile); AssertFile.SizeEquals(destinationFile, 10); AssertFile.SizeEquals(result.FullName, 1); }
public void WhenFileDoesNotExist_ThenAssertTrue() { Assert.DoesNotThrow(() => AssertFile.NotExists(DoesNotExistFile)); }
public void WhenFileIsNull_ThenThrowException() { Assert.Throws <ArgumentNullException>(() => AssertFile.NotExists(null as FileInfo)); }