public void Should_Delete_File() { // Given var fixture = new FileDeleteFixture(); // When FileExtensions.DeleteFile(fixture.Context, fixture.Paths[0]); // Then fixture.Files[0].Received(1).Delete(); }
public void Should_Make_Relative_File_Path_Absolute() { // Given var fixture = new FileDeleteFixture(); // When FileExtensions.DeleteFile(fixture.Context, "file1.txt"); // Then fixture.FileSystem.Received(1).GetFile(Arg.Is <FilePath>( p => p.FullPath == "/Working/file1.txt")); }
public void Should_Throw_If_File_Path_Is_Null() { // Given var context = Substitute.For <ICakeContext>(); // When var result = Record.Exception(() => FileExtensions.DeleteFile(context, null)); // Then Assert.IsType <ArgumentNullException>(result); Assert.Equal("filePath", ((ArgumentNullException)result).ParamName); }
public void Should_Throw_If_File_Do_Not_Exist() { // Given var fixture = new FileDeleteFixture(); // When var result = Record.Exception(() => FileExtensions.DeleteFile(fixture.Context, "/file.txt")); // Then Assert.IsType <FileNotFoundException>(result); Assert.Equal("The file '/file.txt' do not exist.", result.Message); }
public void Should_Throw_If_Context_Is_Null() { // Given var filePath = new FilePath("./file.txt"); // When var result = Record.Exception(() => FileExtensions.DeleteFile(null, filePath)); // Then Assert.IsType <ArgumentNullException>(result); Assert.Equal("context", ((ArgumentNullException)result).ParamName); }