public void UserWithoutClaims_AddClaim_OneClaimAdded() { var user = new IdentityUser(); string claimType = "test-claim"; string claimValue = "test-value"; var claim = new Claim(claimType, claimValue); user.AddClaim(claim); Assert.Equal(1, user.Claims.Count); Assert.Equal(claimType, user.Claims[0].ClaimType); Assert.Equal(claimValue, user.Claims[0].ClaimValue); }
public void UserWithOneClaim_RemoveNonExistingClaim_DoesNothing() { var user = new IdentityUser(); string claimType = "test-claim"; string claimValue = "test-value"; var claim = new Claim(claimType, claimValue); user.AddClaim(claim); user.RemoveClaim(new Claim("non-existing-type", "non-existing-value")); Assert.Equal(1, user.Claims.Count); Assert.Equal(claimType, user.Claims[0].ClaimType); Assert.Equal(claimValue, user.Claims[0].ClaimValue); }
public void UserWithTwoClaims_RemoveOneOfTheClaims_OtherClaimRemains() { var user = new IdentityUser(); string claimType1 = "test-claim-1"; string claimValue1 = "test-value-1"; var claim1 = new Claim(claimType1, claimValue1); string claimType2 = "test-claim-2"; string claimValue2 = "test-value-2"; var claim2 = new Claim(claimType2, claimValue2); user.AddClaim(claim1); user.AddClaim(claim2); user.RemoveClaim(new Claim(claimType1, claimValue1)); Assert.Equal(1, user.Claims.Count); Assert.Equal(claimType2, user.Claims[0].ClaimType); Assert.Equal(claimValue2, user.Claims[0].ClaimValue); }
public void UserWithOneClaim_RemoveTheClaim_NoClaimsRemain() { var user = new IdentityUser(); string claimType = "test-claim"; string claimValue = "test-value"; var claim1 = new Claim(claimType, claimValue); var claim2 = new Claim(claimType, claimValue); user.AddClaim(claim1); user.RemoveClaim(claim2); Assert.Empty(user.Claims); }