public void ExtractClaimUid_Unauthenticated() { // Arrange var extractor = new DefaultClaimUidExtractor(_pool); var mockIdentity = new Mock <ClaimsIdentity>(); mockIdentity.Setup(o => o.IsAuthenticated) .Returns(false); // Act var claimUid = extractor.ExtractClaimUid(new ClaimsPrincipal(mockIdentity.Object)); // Assert Assert.Null(claimUid); }
public void ExtractClaimUid_ClaimsIdentity() { // Arrange var mockIdentity = new Mock <ClaimsIdentity>(); mockIdentity.Setup(o => o.IsAuthenticated) .Returns(true); mockIdentity.Setup(o => o.Claims).Returns(new Claim[] { new Claim(ClaimTypes.Name, "someName") }); var extractor = new DefaultClaimUidExtractor(_pool); // Act var claimUid = extractor.ExtractClaimUid(new ClaimsPrincipal(mockIdentity.Object)); // Assert Assert.NotNull(claimUid); Assert.Equal("yhXE+2v4zSXHtRHmzm4cmrhZca2J0g7yTUwtUerdeF4=", claimUid); }