Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…to main
  • Loading branch information
bariscanyilmaz committed Oct 13, 2021
2 parents 6b5ca9c + ede69b0 commit c6b021a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/FileServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,41 @@ public async Task CreateIgnoreFileAsync_ShouldCreate_WhenCalled()
_fileSystem.Verify(x => x.File.WriteAllTextAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()));
}

[Fact]

public async Task CreateIgnoreFileAsync_ShouldCreate_WhenFileNotExist()
{
//Arrange
string path=".gitignore";
string content="content";
var fs=new MockFileSystem();
var fileService=new FileService(fs);
//Act
await fileService.CreateIgnoreFileAsync(content);
//Assert
var expected="content";
Assert.Equal(expected,fs.File.ReadAllText(path));
}

[Fact]
public async Task CreateIgnoreFileAsync_ShouldOverwrite_WhenFileExist()
{
//Arrange
string path=".gitignore",existedContent="exsited",content="content";

var fs=new MockFileSystem();
fs.AddFile(path,new MockFileData(existedContent));

var fileService=new FileService(fs);
//Act
await fileService.CreateIgnoreFileAsync(content);
//Assert
var expected="content";

Assert.Equal(expected,fs.File.ReadAllText(path));
Assert.NotEqual(existedContent,fs.File.ReadAllText(path));
}

[Fact]
public async Task AppendIgnoreFileAsync_ShouldAppend_WhenCalled()
{
Expand Down

0 comments on commit c6b021a

Please # to comment.