public void Should_Copy_Multiple_Files_Absolute_Path() { const string filePath1 = "./src/a/a.txt"; const string filePath2 = "./src/b/b.txt"; const string dstPath = "./dst"; // Given var fixture = new FileCopierFixture(); fixture.EnsureFileExists(filePath1); fixture.EnsureFileExists(filePath2); fixture.EnsureDirectoryExists(dstPath); // When FileCopier.CopyFiles( fixture.Context, new[] { fixture.MakeAbsolute(filePath1), fixture.MakeAbsolute(filePath2) }, new DirectoryPath(dstPath), true); // Then Assert.True(fixture.ExistsFile($"{dstPath}/a/a.txt")); Assert.True(fixture.ExistsFile($"{dstPath}/b/b.txt")); }
public void Should_Throw_If_File_Paths_Is_Null() { // Given var fixture = new FileCopierFixture(); // When var result = Record.Exception(() => FileCopier.CopyFiles(fixture.Context, (List <FilePath>)null, new DirectoryPath(""), true)); // Then AssertEx.IsArgumentNullException(result, "filePaths"); }
public void Should_Throw_If_Target_Directory_Path_Is_Null() { // Given var fixture = new FileCopierFixture(); // When var result = Record.Exception(() => FileCopier.CopyFiles(fixture.Context, Enumerable.Empty <FilePath>(), null, true)); // Then AssertEx.IsArgumentNullException(result, "targetDirectoryPath"); }
public void Should_Throw_If_Target_Directory_Does_Not_Exist() { const string dstPath = "/dst"; // Given var fixture = new FileCopierFixture(); // When var result = Record.Exception(() => FileCopier.CopyFiles(fixture.Context, Enumerable.Empty <FilePath>(), new DirectoryPath(dstPath), true)); // Then AssertEx.IsExceptionWithMessage <DirectoryNotFoundException>(result, $"The directory '{dstPath}' does not exist."); }
public void Should_Copy_Single_File_Relative_Path() { const string filePath = "./src/a/a.txt"; const string dstPath = "./dst"; // Given var fixture = new FileCopierFixture(); fixture.EnsureFileExists(filePath); fixture.EnsureDirectoryExists(dstPath); // When FileCopier.CopyFiles( fixture.Context, new FilePath[] { filePath }, new DirectoryPath(dstPath), true); // Then Assert.True(fixture.ExistsFile($"{dstPath}/a/a.txt")); }