public void AddingDuplicateRoleThrows()
 {
     string role = Guid.NewGuid().ToString();
     var target = new AuthenticationModel();
     target.AddRole(role);
     target.AddRole(role);
 }
        public void CanAddRole()
        {
            string role = Guid.NewGuid().ToString();
            var target = new AuthenticationModel();
            target.AddRole(role);

            Assert.IsTrue(target.RoleExists(role));
            Assert.AreEqual(1, target.Roles.Count());
            Assert.AreEqual(role, target.Roles.Single().Name);
        }
Esempio n. 3
0
        public void Setup()
        {
            //Arrange
            string password = "******";
            target = new AuthenticationModel();
            var user = new User(userName);
            user.Roles.Add("admin");
            user.SetPassword(password);
            target.AddUser(user);

            //Act
            principal = target.Authenticate(userName, password);
        }
 public void UsersRolesAreAddedIfMissing()
 {
     var user = new User("robert");
     user.Roles.Add("admin");
     user.Roles.Add("superuser");
     var target = new AuthenticationModel();
     target.AddUser(user);
     Assert.AreEqual(2, target.Roles.Count());
     Assert.IsTrue(target.Roles.Count(r => r.Name == "admin") == 1);
     Assert.IsTrue(target.Roles.Count(r => r.Name == "superuser") == 1);
     foreach (var role in target.Roles)
     {
         Assert.IsTrue(role.Users.Single() == "robert");
     }
 }
 public void CanAddUserWithoutRoles()
 {
     var user = new User("robert");
     var target = new AuthenticationModel();
     target.AddUser(user);
 }