File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,41 @@ public async Task CreateIgnoreFileAsync_ShouldCreate_WhenCalled()
31
31
_fileSystem . Verify ( x => x . File . WriteAllTextAsync ( It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < CancellationToken > ( ) ) ) ;
32
32
}
33
33
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
+
34
69
[ Fact ]
35
70
public async Task AppendIgnoreFileAsync_ShouldAppend_WhenCalled ( )
36
71
{
You can’t perform that action at this time.
0 commit comments