public void RepoAdminCannotRemoveThemselves() { var user = ITH.CreateUsers().Single(); var repoId = ITH.CreateRepositoryOnWebInterface(ITH.MakeName()); app.NavigateTo <RepositoryController>(c => c.Edit(repoId)); var form = app.FindFormFor <RepositoryDetailModel>(); // Set User0 to be admin for this repo var adminBox = form.WebApp.Browser.FindElementsByCssSelector( string.Format("input[name=PostedSelectedAdministrators][value=\"{0}\"]", user.Id)).Single(); ITH.SetCheckbox(adminBox, true); form.Submit(); ITH.AssertThatNoValidationErrorOccurred(); // Now, log in as the ordinary user ITH.LoginAsUser(user); app.NavigateTo <RepositoryController>(c => c.Edit(repoId)); form = app.FindFormFor <RepositoryDetailModel>(); var chkboxes = form.WebApp.Browser.FindElementsByCssSelector("input[name=PostedSelectedAdministrators]"); ITH.SetCheckboxes(chkboxes, false); form.Submit(); app.WaitForElementToBeVisible(By.CssSelector("div.validation-summary-errors"), TimeSpan.FromSeconds(1)); ITH.AssertThatValidationErrorContains(Resources.Repository_Edit_CantRemoveYourself); }