Skip to content

Commit c6b021a

Browse files
Merge branch 'main' of https://github.com/bariscanyilmaz/dotignore into main
2 parents 6b5ca9c + ede69b0 commit c6b021a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/FileServiceTests.cs

+35
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,41 @@ public async Task CreateIgnoreFileAsync_ShouldCreate_WhenCalled()
3131
_fileSystem.Verify(x => x.File.WriteAllTextAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()));
3232
}
3333

34+
[Fact]
35+
36+
public async Task CreateIgnoreFileAsync_ShouldCreate_WhenFileNotExist()
37+
{
38+
//Arrange
39+
string path=".gitignore";
40+
string content="content";
41+
var fs=new MockFileSystem();
42+
var fileService=new FileService(fs);
43+
//Act
44+
await fileService.CreateIgnoreFileAsync(content);
45+
//Assert
46+
var expected="content";
47+
Assert.Equal(expected,fs.File.ReadAllText(path));
48+
}
49+
50+
[Fact]
51+
public async Task CreateIgnoreFileAsync_ShouldOverwrite_WhenFileExist()
52+
{
53+
//Arrange
54+
string path=".gitignore",existedContent="exsited",content="content";
55+
56+
var fs=new MockFileSystem();
57+
fs.AddFile(path,new MockFileData(existedContent));
58+
59+
var fileService=new FileService(fs);
60+
//Act
61+
await fileService.CreateIgnoreFileAsync(content);
62+
//Assert
63+
var expected="content";
64+
65+
Assert.Equal(expected,fs.File.ReadAllText(path));
66+
Assert.NotEqual(existedContent,fs.File.ReadAllText(path));
67+
}
68+
3469
[Fact]
3570
public async Task AppendIgnoreFileAsync_ShouldAppend_WhenCalled()
3671
{

0 commit comments

Comments
 (0)