示例#1
0
        public void CreateRole_Success_Test()
        {
            //get all the roles from the db
            List <Role> previousRoles = rolesBL.GetAllRoles().ToList <Role>();
            //add a new role to the db
            string roleName = "aaa";

            rolesBL.AddRole(roleName);

            Role actualRole   = rolesBL.GetRoleByRoleName(roleName);
            Role expectedRole = new Role()
            {
                RoleID   = actualRole.RoleID,
                RoleName = roleName
            };

            List <Role> expectedRoles = new List <Role>();

            expectedRoles.AddRange(previousRoles); //add the previous Roles to the list
            expectedRoles.Add(expectedRole);       //add the newly added role to the list

            List <Role> actualRoles = rolesBL.GetAllRoles().ToList <Role>();

            //check if expected roles with the actual roles are equal
            AreListsEqual(expectedRoles, actualRoles);
        }