@@ -26,7 +26,7 @@ public void SetUp()
26
26
[ Test ]
27
27
public void FindsGitDirectory ( )
28
28
{
29
- try
29
+ var exception = Assert . Catch ( ( ) =>
30
30
{
31
31
var options = Options . Create ( new GitVersionOptions { WorkingDirectory = workDirectory , Settings = { NoFetch = true } } ) ;
32
32
@@ -35,13 +35,8 @@ public void FindsGitDirectory()
35
35
var gitVersionCalculator = sp . GetRequiredService < IGitVersionCalculateTool > ( ) ;
36
36
37
37
gitVersionCalculator . CalculateVersionVariables ( ) ;
38
- }
39
- catch ( Exception ex )
40
- {
41
- // `RepositoryNotFoundException` means that it couldn't find the .git directory,
42
- // any other exception means that the .git was found but there was some other issue that this test doesn't care about.
43
- Assert . IsNotAssignableFrom < RepositoryNotFoundException > ( ex ) ;
44
- }
38
+ } ) ;
39
+ exception . ShouldNotBeAssignableTo < RepositoryNotFoundException > ( ) ;
45
40
}
46
41
47
42
[ Test ]
@@ -50,7 +45,7 @@ public void FindsGitDirectoryInParent()
50
45
var childDir = PathHelper . Combine ( this . workDirectory , "child" ) ;
51
46
Directory . CreateDirectory ( childDir ) ;
52
47
53
- try
48
+ var exception = Assert . Catch ( ( ) =>
54
49
{
55
50
var options = Options . Create ( new GitVersionOptions { WorkingDirectory = childDir , Settings = { NoFetch = true } } ) ;
56
51
@@ -59,13 +54,7 @@ public void FindsGitDirectoryInParent()
59
54
var gitVersionCalculator = sp . GetRequiredService < IGitVersionCalculateTool > ( ) ;
60
55
61
56
gitVersionCalculator . CalculateVersionVariables ( ) ;
62
- }
63
- catch ( Exception ex )
64
- {
65
- // TODO I think this test is wrong.. It throws a different exception
66
- // `RepositoryNotFoundException` means that it couldn't find the .git directory,
67
- // any other exception means that the .git was found but there was some other issue that this test doesn't care about.
68
- Assert . IsNotAssignableFrom < RepositoryNotFoundException > ( ex ) ;
69
- }
57
+ } ) ;
58
+ exception . ShouldNotBeAssignableTo < RepositoryNotFoundException > ( ) ;
70
59
}
71
60
}
0 commit comments