Ejemplo n.º 1
0
        protected NoAdminsPresent()
        {
            _seeder = new T();

            using var context = new WebApiContext(_seeder.DbContextOptions);

            _userGroup  = context.GetUserGroup();
            _adminGroup = context.GetAdminGroup();

            _seeder.MakeAllActive();
            _seeder.MakeNoAdmins();
        }
Ejemplo n.º 2
0
        public void MakeNoAdmins()
        {
            using var context = new WebApiContext(DbContextOptions);

            var userGroup = context.GetUserGroup();

            foreach (var user in context.Users)
            {
                user.GroupId = userGroup.Id;
                context.Entry(user).State = EntityState.Modified;
            }

            context.SaveChanges();
        }
Ejemplo n.º 3
0
        protected AdminIsBlocked()
        {
            _seeder = new T();

            using var context = new WebApiContext(_seeder.DbContextOptions);

            _userGroup  = context.GetUserGroup();
            _adminGroup = context.GetAdminGroup();

            _seeder.MakeAllActive();
            _admin = _seeder.MakeSingleAdmin();

            _admin.StateId = context.GetBlockedState().Id;
            context.SaveChanges();
        }
Ejemplo n.º 4
0
        protected SingleAdminPresent()
        {
            _seeder = new T();

            using var context = new WebApiContext(_seeder.DbContextOptions);

            _userGroup  = context.GetUserGroup();
            _adminGroup = context.GetAdminGroup();

            _seeder.MakeAllActive();
            _admin = _seeder.MakeSingleAdmin();

            _admin.GroupId = _adminGroup.Id;
            context.SaveChanges();
        }
Ejemplo n.º 5
0
        protected UsersControllerTests()
        {
            _seeder = new T();

            var host = Program.CreateHostBuilder(new string[] { }).Build();

            _mapper = host.Services.GetRequiredService <IMapper>();

            using var context = new WebApiContext(_seeder.DbContextOptions);

            _adminGroup = _mapper.Map <UserGroupGetDto>(context.GetAdminGroup());
            _userGroup  = _mapper.Map <UserGroupGetDto>(context.GetUserGroup());

            _activeState  = _mapper.Map <UserStateGetDto>(context.GetActiveState());
            _blockedState = _mapper.Map <UserStateGetDto>(context.GetBlockedState());

            _seeder.MakeAllActive();
        }