예제 #1
0
        public void Test_Identity_should_be_the_same_as_from_provided_IPrincipal()
        {
            var identity = new GenericIdentity("username");
            var userPrincipal = new UserPrincipal(new GenericPrincipal(identity, roles: new string[] { }), new User());

            Assert.Equal(identity, userPrincipal.Identity);
        }
예제 #2
0
        public void Test_Admin_should_have_admin_role()
        {
            var genericPrincipal = new GenericPrincipal(new GenericIdentity("username"), roles: new string[] { });
            var admin = new User() { IsAdmin = true };
            var userPrincipal = new UserPrincipal(genericPrincipal, admin);

            Assert.Equal(true, userPrincipal.IsInRole("admin"));
            Assert.Equal(true, userPrincipal.IsInRole("Admin"));
        }