public void Edit_Update_Get_View() { Update update = new Update() { UpdateId = 1, Updatemsg = "abc", GoalId = 1, }; updateRepository.Setup(x => x.GetById(1)).Returns(update); GoalController controller = new GoalController(goalService, metricService, focusService, supportService, updateService, commentService, userService, securityTokenService, supportInvitationService, goalStatusService, commentUserService, updateSupportService); Mapper.CreateMap<Update, UpdateFormModel>(); PartialViewResult result = controller.EditUpdate(1) as PartialViewResult; Assert.IsNotNull(result, "View Result is null"); Assert.IsInstanceOf(typeof(UpdateFormModel), result.ViewData.Model, "Wrong View Model"); var data = result.ViewData.Model as UpdateFormModel; Assert.AreEqual("abc", data.Updatemsg); }
public void Delete_Update_Post() { Update update = new Update() { UpdateId = 1, Updatemsg = "abc", GoalId = 1, }; updateRepository.Setup(x => x.GetById(1)).Returns(update); GoalController controller = new GoalController(goalService, metricService, focusService, supportService, updateService, commentService, userService, securityTokenService, supportInvitationService, goalStatusService, commentUserService, updateSupportService); var result = controller.DeleteConfirmedUpdate(1) as RedirectToRouteResult; Assert.AreEqual("Index", result.RouteValues["action"]); }
public void EditUpdate(Update update) { updateRepository.Update(update); SaveUpdate(); }
public void Delete_Update_Get_ReturnsView() { Update update = new Update() { UpdateId = 1, Updatemsg = "abc", GoalId = 1, }; updateRepository.Setup(x => x.GetById(1)).Returns(update); GoalController controller = new GoalController(goalService, metricService, focusService, supportService, updateService, commentService, userService, securityTokenService, supportInvitationService, goalStatusService, commentUserService, updateSupportService); PartialViewResult result = controller.DeleteUpdate(1) as PartialViewResult; Assert.IsNotNull(result, "View Result is null"); Assert.IsInstanceOf(typeof(Update), result.ViewData.Model, "Wrong View Model"); var group = result.ViewData.Model as Update; Assert.AreEqual("abc", group.Updatemsg, "Got wrong message"); }
//public IEnumerable<ValidationResult> CanAddUpdate(Update newUpdate) //{ // if (newUpdate.status.GetType().Name != "Double") // yield return new ValidationResult("Status", "Not a valid update"); //} public void CreateUpdate(Update update) { updateRepository.Add(update); SaveUpdate(); }