Ejemplo n.º 1
0
        public void Group_Goal_Page_View()
        {
            //Arrange 
            GroupUser grpUser = new GroupUser()
            {
                UserId = "402bd590-fdc7-49ad-9728-40efbfe512ec"
            };
            GroupGoal goal = new GroupGoal()
            {
                GroupGoalId = 1,
                GoalName = "t",
                GoalStatusId = 1,
                Description = "x",
                StartDate = DateTime.Now,
                EndDate = DateTime.Now.AddDays(1),
                GroupUser = grpUser

            };
            groupGoalRepository.Setup(x => x.GetById(1)).Returns(goal);

            ApplicationUser user = new ApplicationUser()
            {
                Id = "402bd590-fdc7-49ad-9728-40efbfe512ec"
            };
            userRepository.Setup(x => x.Get(It.IsAny<Expression<Func<ApplicationUser, bool>>>())).Returns(user);
            IEnumerable<GoalStatus> fake = new List<GoalStatus> {
            new GoalStatus { GoalStatusId =1, GoalStatusType ="Inprogress"},
            new GoalStatus { GoalStatusId =2, GoalStatusType ="OnHold"},
         
          }.AsEnumerable();
            goalStatusRepository.Setup(x => x.GetAll()).Returns(fake);

            Mapper.CreateMap<GroupGoal, GroupGoalViewModel>();
            //Act
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            ViewResult result = controller.GroupGoal(1) as ViewResult;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(typeof(GroupGoalViewModel), result.ViewData.Model, "WrongType");
            var data = result.ViewData.Model as GroupGoalViewModel;
            Assert.AreEqual("t", data.GoalName);
        }