public void Should_Recursively_Move_Files_And_Directory() { // Given var context = Substitute.For <ICakeContext>(); var environment = FakeEnvironment.CreateUnixEnvironment(); var fileSystem = new FakeFileSystem(environment); CreateFileStructure(fileSystem); context.FileSystem.Returns(fileSystem); var sourcePath = new DirectoryPath("/Temp"); var destinationPath = new DirectoryPath("/Temp2"); // When DirectoryAliases.MoveDirectory(context, sourcePath, destinationPath); // Then Assert.False(fileSystem.GetDirectory("/Temp/Stuff").Exists); Assert.False(fileSystem.GetDirectory("/Temp/Things").Exists); Assert.True(fileSystem.GetDirectory("/Temp2/Stuff").Exists); Assert.True(fileSystem.GetDirectory("/Temp2/Things").Exists); Assert.False(fileSystem.GetFile("/Temp/Stuff/file1.txt").Exists); Assert.False(fileSystem.GetFile("/Temp/Stuff/file2.txt").Exists); Assert.False(fileSystem.GetFile("/Temp/Things/file1.txt").Exists); Assert.True(fileSystem.GetFile("/Temp2/Stuff/file1.txt").Exists); Assert.True(fileSystem.GetFile("/Temp2/Stuff/file2.txt").Exists); Assert.True(fileSystem.GetFile("/Temp2/Things/file1.txt").Exists); }
public void Should_Throw_If_Context_Is_Null() { // Given, When var source = new DirectoryPath("./source"); var target = new DirectoryPath("./target"); var result = Record.Exception(() => DirectoryAliases.MoveDirectory(null, source, target)); // Then Assert.IsArgumentNullException(result, "context"); }
public void Should_Throw_If_Target_Directory_Path_Is_Null() { // Given var context = Substitute.For <ICakeContext>(); var source = new DirectoryPath("./source"); // When var result = Record.Exception(() => DirectoryAliases.MoveDirectory(context, source, null)); // Then Assert.IsArgumentNullException(result, "targetDirectoryPath"); }
public void Should_Throw_If_Source_Directory_Path_Is_Null() { // Given var context = Substitute.For <ICakeContext>(); var target = new DirectoryPath("./target"); // When var result = Record.Exception(() => DirectoryAliases.MoveDirectory(context, null, target)); // Then AssertEx.IsArgumentNullException(result, "directoryPath"); }