public void Update(Group group) { this._groupsRepository.Save(); }
public void ShouldRenderCreateViewByPOSTForAnInvalidGroup() { // Arrange IPrincipal fakeUser = new GenericPrincipal(new GenericIdentity("User1", "Forms"), null); Group newGroup = new Group { Name = "Test Group", Description = "Just a test group" }; _controller.ViewData.ModelState.AddModelError("Key", "ErrorMessage"); // Act ActionResult actual = _controller.Create(newGroup, fakeUser); // Assert Assert.IsNotNull(actual, "The returned ActionResult is Null"); Assert.IsInstanceOf<ViewResult>(actual, "The returned ActionResult was not an instance of ViewResult"); ViewResult viewResult = (ViewResult) actual; Assert.IsNotNull(viewResult.ViewData.Model, "The value of viewResult.ViewData.Model is Null"); Assert.IsInstanceOf<Group>(viewResult.ViewData.Model, "The value of viewResult.ViewData.Model is not an instance of Group"); Group model = (Group) viewResult.ViewData.Model; Assert.IsTrue(model.ID == newGroup.ID, string.Format("The value of Model.ID should be '{0}' but it is '{1}'", newGroup.ID, model.ID)); Assert.IsTrue(model.Name == newGroup.Name, string.Format("The value of Model.Name should be '{0}' but it is '{1}'", newGroup.Name, model.Name)); Assert.IsTrue(model.Description == newGroup.Description, string.Format("The value of Model.Description should be '{0}' but it is '{1}'", newGroup.Description, model.Description)); }
public void Add(Group newGroup) { this._groupsRepository.Add(newGroup); this._groupsRepository.Save(); }
public void ShouldRenderMovieDetailsViewByPOSTForANewValidGroup() { // Arrange IPrincipal fakeUser = new GenericPrincipal(new GenericIdentity("User1", "Forms"), null); Group newGroup = new Group {Name = "Test Group", Description = "Just a test group"}; const int newGroupId = 4; // Act ActionResult actual = _controller.Create(newGroup, fakeUser); // Assert Assert.IsNotNull(actual, "The returned ActionResult is Null"); Assert.IsInstanceOf<RedirectToRouteResult>(actual, "The returned ActionResult was not an instance of RedirectToRouteResult"); Assert.IsTrue(newGroup.ID == newGroupId, string.Format("The value of newGroup.ID should be '{0}' but it is '{1}'", newGroupId, newGroup.ID)); RedirectToRouteResult viewResult = (RedirectToRouteResult) actual; Assert.IsNotNull(viewResult.RouteName == "Default", string.Format("The RedirectToRouteResult RouteName should be 'Default' but it is '{0}'", viewResult.RouteName)); Assert.IsTrue(viewResult.RouteValues["Action"].ToString() == "Index", string.Format("The value of RouteValues[\"Action\"] should be 'Index' but it is '{0}'", viewResult.RouteValues["Action"])); }
public void Update(Group group) { }
public void Add(Group newGroup) { newGroup.ID = Interlocked.Increment(ref _newId); _groups.Add(newGroup); }
public ActionResult Create(Group group, IPrincipal user) { try { if (ModelState.IsValid) { var owner = this._groupsService.GetUserInfo(user.Identity.Name); group.Owner = owner; group.OwnerId = owner.UserId; this._groupsService.Add(group); return RedirectToAction("Index"); } } catch (Exception e) { ModelState.AddModelError("", String.Format("Edit Failure, inner exception: {0}", e)); } return View(group); }
// GET: /Groups/Create public ActionResult Create() { Group group = new Group(); return View(group); }