public void Roles()
        {
            UserBase user = new MockUserBase();
            IPrincipal principal = user;

            string[] roles = new string[] { "role1", "role2" };

            user.Roles = roles;

            Assert.IsTrue(roles.SequenceEqual(user.Roles),
                "Roles should be equal.");
            foreach (string role in roles)
            {
                Assert.IsTrue(user.IsInRole(role),
                    "User should be in role");
                Assert.IsTrue(principal.IsInRole(role),
                    "Principal should be in role");
            }

            user.Roles = null;

            Assert.IsNull(user.Roles,
                "Roles should be null.");
            foreach (string role in roles)
            {
                Assert.IsFalse(user.IsInRole(role),
                    "User should not be in role");
                Assert.IsFalse(principal.IsInRole(role),
                    "Principal should not be in role");
            }
        }
Beispiel #2
0
        public void Roles()
        {
            UserBase   user      = new MockUserBase();
            IPrincipal principal = user;

            string[] roles = new string[] { "role1", "role2" };

            user.Roles = roles;

            Assert.IsTrue(roles.SequenceEqual(user.Roles),
                          "Roles should be equal.");
            foreach (string role in roles)
            {
                Assert.IsTrue(user.IsInRole(role),
                              "User should be in role");
                Assert.IsTrue(principal.IsInRole(role),
                              "Principal should be in role");
            }

            user.Roles = null;

            Assert.IsNull(user.Roles,
                          "Roles should be null.");
            foreach (string role in roles)
            {
                Assert.IsFalse(user.IsInRole(role),
                               "User should not be in role");
                Assert.IsFalse(principal.IsInRole(role),
                               "Principal should not be in role");
            }
        }
        public void Properties()
        {
            UserBase user = new MockUserBase();

            string name = "name";

            user.Name = name;

            Assert.IsTrue(user.IsAuthenticated,
                "A user with a valid name should be authenticated.");
            Assert.AreEqual(name, user.Name,
                "Names should be equal.");

            user.Name = null;

            Assert.IsFalse(user.IsAuthenticated,
                "A user with an invalid name should be authenticated.");
            Assert.IsNull(user.Name,
                "Name should be null.");

            IPrincipal principal = user;

            Assert.IsNotNull(principal.Identity,
                "Identity should not be null.");
            Assert.AreEqual(string.Empty, principal.Identity.AuthenticationType,
                "Authentication type should be empty.");
        }
Beispiel #4
0
        public void Properties()
        {
            UserBase user = new MockUserBase();

            string name = "name";

            user.Name = name;

            Assert.IsTrue(user.IsAuthenticated,
                          "A user with a valid name should be authenticated.");
            Assert.AreEqual(name, user.Name,
                            "Names should be equal.");

            user.Name = null;

            Assert.IsFalse(user.IsAuthenticated,
                           "A user with an invalid name should be authenticated.");
            Assert.IsNull(user.Name,
                          "Name should be null.");

            IPrincipal principal = user;

            Assert.IsNotNull(principal.Identity,
                             "Identity should not be null.");
            Assert.AreEqual(string.Empty, principal.Identity.AuthenticationType,
                            "Authentication type should be empty.");
        }