示例#1
0
        public void CanCheckIfUserHasClaim()
        {
            var claim = ClaimMother.CreateClaim("testing", "test");
            var user  = IdentityUserMother.UserWithClaimAndRole(claim);

            user.HasClaim(claim).ShouldBe(true);
        }
示例#2
0
        public void CannotAddDuplicateClaim()
        {
            var claim = ClaimMother.CreateClaim("testing", "test");
            var user  = IdentityUserMother.UserWithClaimAndRole(claim);

            user.AddClaim(claim).ShouldBe(false);
        }
示例#3
0
        public void CanAddClaim()
        {
            var claim = ClaimMother.CreateClaim("testing", "test");
            var user  = IdentityUserMother.EmptyUser();

            user.AddClaim(claim).ShouldBe(true);
            user.Claims.ShouldContain(x => x.ClaimType == "testing" && x.ClaimValue == "test");
        }
示例#4
0
        public void CanRemoveClaim()
        {
            var claim = ClaimMother.CreateClaim("testing", "test");
            var user  = IdentityUserMother.UserWithClaimAndRole(claim);

            user.RemoveClaim(claim).ShouldBe(true);
            user.Claims.ShouldBeEmpty();
        }
示例#5
0
        public void CanGetClaims()
        {
            var claim = ClaimMother.CreateClaim("testing", "test");
            var user  = IdentityUserMother.UserWithClaimAndRole(claim);

            user.Claims.ShouldNotBeEmpty();
            user.Claims.Count.ShouldBe(1);
        }
示例#6
0
        public void CannotRemoveClaimIfNotAssigned()
        {
            var claim        = ClaimMother.CreateClaim("testing", "test");
            var anotherClaim = ClaimMother.CreateClaim("testing1", "test1");

            var user = IdentityUserMother.UserWithClaimAndRole(claim);

            user.RemoveClaim(anotherClaim).ShouldBe(false);
        }