@@ -26,7 +26,7 @@ public void SetUp()
2626 [ Test ]
2727 public void FindsGitDirectory ( )
2828 {
29- try
29+ var exception = Assert . Catch ( ( ) =>
3030 {
3131 var options = Options . Create ( new GitVersionOptions { WorkingDirectory = workDirectory , Settings = { NoFetch = true } } ) ;
3232
@@ -35,13 +35,8 @@ public void FindsGitDirectory()
3535 var gitVersionCalculator = sp . GetRequiredService < IGitVersionCalculateTool > ( ) ;
3636
3737 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 > ( ) ;
4540 }
4641
4742 [ Test ]
@@ -50,7 +45,7 @@ public void FindsGitDirectoryInParent()
5045 var childDir = PathHelper . Combine ( this . workDirectory , "child" ) ;
5146 Directory . CreateDirectory ( childDir ) ;
5247
53- try
48+ var exception = Assert . Catch ( ( ) =>
5449 {
5550 var options = Options . Create ( new GitVersionOptions { WorkingDirectory = childDir , Settings = { NoFetch = true } } ) ;
5651
@@ -59,13 +54,7 @@ public void FindsGitDirectoryInParent()
5954 var gitVersionCalculator = sp . GetRequiredService < IGitVersionCalculateTool > ( ) ;
6055
6156 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 > ( ) ;
7059 }
7160}
0 commit comments