public void Create_Goal() { GoalController controller = new GoalController(goalService, metricService, focusService, supportService, updateService, commentService, userService, securityTokenService, supportInvitationService, goalStatusService, commentUserService, updateSupportService); // Act Mapper.CreateMap<GoalFormModel, Goal>(); GoalFormModel goal = new GoalFormModel() { GoalName = "t", StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(1), Desc = "t", UserId = "402bd590-fdc7-49ad-9728-40efbfe512ec", }; var result = (RedirectToRouteResult)controller.Create(goal); Assert.AreEqual("Index", result.RouteValues["action"]); }
public void Create_Goal_Get_ReturnsView() { IEnumerable<Focus> fakeFocus = new List<Focus> { new Focus { FocusId = 1, FocusName="Test1",GroupId = 1}, new Focus { FocusId = 2, FocusName="Test2",GroupId = 1}, new Focus { FocusId = 3, FocusName="Test3",GroupId = 1} }.AsEnumerable(); focusRepository.Setup(x => x.GetMany(It.IsAny<Expression<Func<Focus, bool>>>())).Returns(fakeFocus); IEnumerable<Metric> fakeMatrices = new List<Metric> { new Metric{MetricId=1, Type="Test1"}, new Metric{MetricId=2,Type="Test2"}, new Metric{MetricId=3,Type="Test3"} }.AsEnumerable(); metricRepository.Setup(x => x.GetAll()).Returns(fakeMatrices); GoalFormModel goal = new GoalFormModel(); GoalController controller = new GoalController(goalService, metricService, focusService, supportService, updateService, commentService, userService, securityTokenService, supportInvitationService, goalStatusService, commentUserService, updateSupportService); PartialViewResult result = controller.Create() as PartialViewResult; Assert.IsNotNull(result, "View Result is null"); Assert.IsInstanceOf(typeof(GoalFormModel), result.ViewData.Model, "Wrong View Model"); }