Example #1
0
        public void ClaimsIdentityBuilder_WithName_CallsWrongClaim_ShouldThrowInvalidOperationException()
        {
            ClaimsIdentityBuilder builder        = new ClaimsIdentityBuilder();
            ClaimsIdentity        claimsIdentity = builder.WithName("Handsome B. Wonderful").Build();

            Assert.ThrowsException <InvalidOperationException>(() => claimsIdentity.Claims.First(x => x.Type == ClaimTypes.NameIdentifier).Value);
        }
Example #2
0
        public void ClaimsIdentityBuilder_WithName_ShouldSetClaim()
        {
            ClaimsIdentityBuilder builder        = new ClaimsIdentityBuilder();
            ClaimsIdentity        claimsIdentity = builder.WithName("Handsome B. Wonderful").Build();

            string name = claimsIdentity.Claims.First(x => x.Type == ClaimTypes.Name).Value;

            Assert.IsTrue(name == "Handsome B. Wonderful");
        }