public void ReplaceClaim_ExistingClaim_Replaces()
        {
            var user       = new IdentityUser();
            var firstClaim = new Claim("type", "value");

            user.AddClaim(firstClaim);
            var newClaim = new Claim("newType", "newValue");

            user.ReplaceClaim(firstClaim, newClaim);

            user.ExpectOnlyHasThisClaim(newClaim);
        }
        public void ReplaceClaim_TypeMatchesButValueDoesNot_DoesNotReplace()
        {
            var user       = new IdentityUser();
            var firstClaim = new Claim("sameType", "value");

            user.AddClaim(firstClaim);
            var newClaim = new Claim("sameType", "newValue");

            user.ReplaceClaim(new Claim("sameType", "wrongValue"), newClaim);

            user.ExpectOnlyHasThisClaim(firstClaim);
        }
예제 #3
0
        public async Task ReplaceClaim_Replaces()
        {
            // note: unit tests cover behavior of ReplaceClaim method on IdentityUser
            var user = new IdentityUser {
                UserName = "******"
            };
            var manager = GetUserManager();
            await manager.CreateAsync(user);

            var existingClaim = new Claim("type", "value");
            await manager.AddClaimAsync(user, existingClaim);

            var newClaim = new Claim("newType", "newValue");

            await manager.ReplaceClaimAsync(user, existingClaim, newClaim);

            user.ExpectOnlyHasThisClaim(newClaim);
        }