diff --git a/IntelliTect.Multitool.Tests/ClaimsPrincipalExtensionsTests.cs b/IntelliTect.Multitool.Tests/ClaimsPrincipalExtensionsTests.cs index f015ee8..ddc198c 100644 --- a/IntelliTect.Multitool.Tests/ClaimsPrincipalExtensionsTests.cs +++ b/IntelliTect.Multitool.Tests/ClaimsPrincipalExtensionsTests.cs @@ -6,6 +6,9 @@ namespace IntelliTect.Multitool.Security.Tests; public class ClaimsPrincipalExtensionsTests { + static readonly string[] roles = new[] { "Foo", "Bar" }; + static readonly string[] singleRole = new[] { "Bar" }; + [Fact] public void GetRoles_WhenClaimsPrincipalNull_Should_Throw() { @@ -25,7 +28,7 @@ public void GetRoles_WhenClaimsPrincipalHasNoRoles_Should_ReturnEmpty() [Fact] public void GetRoles_WhenClaimsPrincipalHasRoles_Should_ReturnNotEmpty() { - ClaimsPrincipal sut = new GenericPrincipal(new GenericIdentity("Uncle Festus"), new[] { "Foo", "Bar" }); + ClaimsPrincipal sut = new GenericPrincipal(new GenericIdentity("Uncle Festus"), roles); Assert.Collection(sut.GetRoles(), s => Assert.Equal("Foo", s), t => Assert.Equal("Bar", t)); } @@ -49,7 +52,7 @@ public void GetUserId_WhenClaimsPrincipalHasNoProperty_Should_ReturnNull() [Fact] public void GetUserId_WhenClaimsPrincipalHasId_Should_ReturnString() { - ClaimsPrincipal sut = new GenericPrincipal(new GenericIdentity("Taki The Frog"), new[] { "Bar" }); + ClaimsPrincipal sut = new GenericPrincipal(new GenericIdentity("Taki The Frog"), singleRole); Assert.Equal("Taki The Frog", sut.GetUserId()); } diff --git a/IntelliTect.Multitool.Tests/RepositoryPaths.Tests.cs b/IntelliTect.Multitool.Tests/RepositoryPaths.Tests.cs index 7919c78..902ce18 100644 --- a/IntelliTect.Multitool.Tests/RepositoryPaths.Tests.cs +++ b/IntelliTect.Multitool.Tests/RepositoryPaths.Tests.cs @@ -15,13 +15,13 @@ public void GetDefaultRepoRoot_ReturnsRepoRootDirectory() public void BuildVariables_BeingSetProperly() { Assert.Equal(3, RepositoryPaths.BuildVariables.Count); - + Assert.True(RepositoryPaths.BuildVariables.TryGetValue("BuildingForLiveUnitTesting", out _)); - + Assert.True(RepositoryPaths.BuildVariables.TryGetValue("ProjectPath", out string? projectPath)); Assert.NotNull(projectPath); Assert.NotEmpty(projectPath); - + Assert.True(RepositoryPaths.BuildVariables.TryGetValue("SolutionDir", out string? solutionDir)); Assert.NotNull(solutionDir); Assert.NotEmpty(solutionDir); @@ -38,7 +38,9 @@ public void TrySearchForGitContainingDirectory_ReturnsTrueWhenFound() [Fact] public void TrySearchForGitContainingDirectory_ReturnsFalseWhenNotFound() { - Assert.False(RepositoryPaths.TrySearchForGitContainingDirectory(new DirectoryInfo(Path.GetPathRoot(Directory.GetCurrentDirectory())), out string gitParentDirectory)); + string? path = Path.GetPathRoot(Directory.GetCurrentDirectory()); + Assert.NotNull(path); + Assert.False(RepositoryPaths.TrySearchForGitContainingDirectory(new DirectoryInfo(path), out string gitParentDirectory)); Assert.Empty(gitParentDirectory); } } \ No newline at end of file diff --git a/IntelliTect.Multitool/ReleaseDateAttribute.cs b/IntelliTect.Multitool/ReleaseDateAttribute.cs index 8018601..4366bf2 100644 --- a/IntelliTect.Multitool/ReleaseDateAttribute.cs +++ b/IntelliTect.Multitool/ReleaseDateAttribute.cs @@ -33,5 +33,5 @@ public ReleaseDateAttribute(string utcDateString) object[]? attribute = (assembly ?? Assembly.GetEntryAssembly())?.GetCustomAttributes(typeof(ReleaseDateAttribute), false); return attribute?.Length >= 1 ? ((ReleaseDateAttribute)attribute[0]).ReleaseDate : null; } - + } \ No newline at end of file diff --git a/IntelliTect.Multitool/RepositoryPaths.cs b/IntelliTect.Multitool/RepositoryPaths.cs index 9a346df..68627f2 100644 --- a/IntelliTect.Multitool/RepositoryPaths.cs +++ b/IntelliTect.Multitool/RepositoryPaths.cs @@ -78,7 +78,7 @@ public static bool TrySearchForGitContainingDirectory(DirectoryInfo? searchStart } searchStartDirectory = searchStartDirectory.Parent; - } + } gitParentDirectory = string.Empty; return false; }