protected NoAdminsPresent() { _seeder = new T(); using var context = new WebApiContext(_seeder.DbContextOptions); _userGroup = context.GetUserGroup(); _adminGroup = context.GetAdminGroup(); _seeder.MakeAllActive(); _seeder.MakeNoAdmins(); }
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(); }
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(); }
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(); }
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(); }