diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 93e409c46e..be3ef7f779 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -21,7 +21,7 @@ - + diff --git a/src/GitVersion.Core.Tests/Core/GitVersionToolDirectoryTests.cs b/src/GitVersion.Core.Tests/Core/GitVersionToolDirectoryTests.cs index f83cc8d703..34d252ad8f 100644 --- a/src/GitVersion.Core.Tests/Core/GitVersionToolDirectoryTests.cs +++ b/src/GitVersion.Core.Tests/Core/GitVersionToolDirectoryTests.cs @@ -26,7 +26,7 @@ public void SetUp() [Test] public void FindsGitDirectory() { - try + var exception = Assert.Catch(() => { var options = Options.Create(new GitVersionOptions { WorkingDirectory = workDirectory, Settings = { NoFetch = true } }); @@ -35,13 +35,8 @@ public void FindsGitDirectory() var gitVersionCalculator = sp.GetRequiredService(); gitVersionCalculator.CalculateVersionVariables(); - } - catch (Exception ex) - { - // `RepositoryNotFoundException` means that it couldn't find the .git directory, - // any other exception means that the .git was found but there was some other issue that this test doesn't care about. - Assert.IsNotAssignableFrom(ex); - } + }); + exception.ShouldNotBeAssignableTo(); } [Test] @@ -50,7 +45,7 @@ public void FindsGitDirectoryInParent() var childDir = PathHelper.Combine(this.workDirectory, "child"); Directory.CreateDirectory(childDir); - try + var exception = Assert.Catch(() => { var options = Options.Create(new GitVersionOptions { WorkingDirectory = childDir, Settings = { NoFetch = true } }); @@ -59,13 +54,7 @@ public void FindsGitDirectoryInParent() var gitVersionCalculator = sp.GetRequiredService(); gitVersionCalculator.CalculateVersionVariables(); - } - catch (Exception ex) - { - // TODO I think this test is wrong.. It throws a different exception - // `RepositoryNotFoundException` means that it couldn't find the .git directory, - // any other exception means that the .git was found but there was some other issue that this test doesn't care about. - Assert.IsNotAssignableFrom(ex); - } + }); + exception.ShouldNotBeAssignableTo(); } }