File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1
- using System . IO ;
1
+ using System ;
2
+ using System . IO ;
2
3
using System . Linq ;
3
4
using LibGit2Sharp . Tests . TestHelpers ;
4
5
using Xunit ;
@@ -44,7 +45,26 @@ public void IsPathIgnoredShouldVerifyWhetherPathIsIgnored()
44
45
repo . Ignore . ResetAllTemporaryRules ( ) ;
45
46
46
47
Assert . False ( repo . Ignore . IsPathIgnored ( "Foo.cs" ) ) ;
47
- }
48
+ }
49
+ }
50
+
51
+ [ Fact ]
52
+ public void CallingIsPathIgnoredWithBadParamsThrows ( )
53
+ {
54
+ using ( var repo = new Repository ( StandardTestRepoWorkingDirPath ) )
55
+ {
56
+ Assert . Throws < ArgumentException > ( ( ) => repo . Ignore . IsPathIgnored ( string . Empty ) ) ;
57
+ Assert . Throws < ArgumentNullException > ( ( ) => repo . Ignore . IsPathIgnored ( null ) ) ;
58
+ }
59
+ }
60
+
61
+ [ Fact ]
62
+ public void AddingATemporaryRuleWithBadParamsThrows ( )
63
+ {
64
+ using ( var repo = new Repository ( StandardTestRepoWorkingDirPath ) )
65
+ {
66
+ Assert . Throws < ArgumentNullException > ( ( ) => repo . Ignore . AddTemporaryRules ( null ) ) ;
67
+ }
48
68
}
49
69
}
50
70
}
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ internal Ignore(Repository repo)
31
31
/// <param name="rules">The content of a .gitignore file that will be applied.</param>
32
32
public virtual void AddTemporaryRules ( IEnumerable < string > rules )
33
33
{
34
+ Ensure . ArgumentNotNull ( rules , "rules" ) ;
35
+
34
36
var allRules = rules . Aggregate ( new StringBuilder ( ) , ( acc , x ) =>
35
37
{
36
38
acc . Append ( x ) ;
@@ -59,6 +61,8 @@ public virtual void ResetAllTemporaryRules()
59
61
/// <returns>true if the path should be ignored.</returns>
60
62
public virtual bool IsPathIgnored ( string relativePath )
61
63
{
64
+ Ensure . ArgumentNotNullOrEmptyString ( relativePath , "relativePath" ) ;
65
+
62
66
return Proxy . git_ignore_path_is_ignored ( repo . Handle , relativePath ) ;
63
67
}
64
68
}
You can’t perform that action at this time.
0 commit comments