public void Users_List()
        {

            IEnumerable<GroupUser> fakeGroupUser = new List<GroupUser> {            
            new GroupUser {AddedDate=DateTime.Now,Admin=true,GroupId=1,GroupUserId=1,UserId="402bd590-fdc7-49ad-9728-40efbfe512ec"},
            new GroupUser {AddedDate=DateTime.Now,Admin=false,GroupId=1,GroupUserId=2,UserId="402bd590-fdc7-49ad-9728-40efbfe512ed"},
            new GroupUser {AddedDate=DateTime.Now,Admin=false,GroupId=1,GroupUserId=3,UserId="402bd590-fdc7-49ad-9728-40efbfe512ee"},
            new GroupUser {AddedDate=DateTime.Now,Admin=true,GroupId=1,GroupUserId=4,UserId="402bd590-fdc7-49ad-9728-40efbfe512ef"},
            new GroupUser {AddedDate=DateTime.Now,Admin=true,GroupId=1,GroupUserId=5,UserId="402bd590-fdc7-49ad-9728-40efbfe512eg"},
            new GroupUser {AddedDate=DateTime.Now,Admin=true,GroupId=2,GroupUserId=6,UserId="402bd590-fdc7-49ad-9728-40efbfe512eh"}
           
          }.AsEnumerable();
            groupUserRepository.Setup(x => x.GetMany(It.IsAny<Expression<Func<GroupUser, bool>>>())).Returns(fakeGroupUser);
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);

            ViewResult result = controller.UsersList(2) as ViewResult;
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(typeof(List<GroupUser>), result.ViewData.Model, "Wrong Model");
            var grpusr = result.ViewData.Model as List<GroupUser>;
            Assert.AreEqual(6, grpusr.Count(), "Got wrong number of GroupUser");


        }
        public void Delete_Goal_Get_ReturnsView()
        {


            GroupGoal fake = new GroupGoal()
            {
                GroupGoalId = 1,
                GoalName = "test",
                Description = "test",
                GroupId = 1,
                StartDate = DateTime.Now,
                EndDate = DateTime.Now.AddDays(1),
                GoalStatusId = 1,
                GroupUserId = 2

            };


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

            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            ViewResult result = controller.DeleteGoal(1) as ViewResult;
            Assert.IsNotNull(result, "View Result is null");
            Assert.IsInstanceOf(typeof(GroupGoal),
                 result.ViewData.Model, "Wrong View Model");
            var group = result.ViewData.Model as GroupGoal;
            Assert.AreEqual("test", group.Description, "Got wrong Focus Description");

        }
        public void ListOfGroups_Test()
        {
            // Arrange      
            IEnumerable<Group> fakeCategories = new List<Group> {
            new Group { GroupName = "Test1", Description="Test1Desc"},
            new Group {  GroupName= "Test2", Description="Test2Desc"},
            new Group { GroupName = "Test3", Description="Test3Desc"}
          }.AsEnumerable();
            groupRepository.Setup(x => x.GetAll()).Returns(fakeCategories);
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);

            // Act
            ViewResult result = controller.ListOfGroups() as ViewResult;
            // Assert
            Assert.IsNotNull(result, "View Result is null");
            Assert.IsInstanceOf(typeof(IEnumerable<Group>),
            result.ViewData.Model, "Wrong View Model");
            var grp = result.ViewData.Model as IEnumerable<Group>;
            Assert.AreEqual(3, grp.Count(), "Got wrong number of Groups");
        }
        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);
            GroupGoalFormModel goal = new GroupGoalFormModel();
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);

            ViewResult result = controller.CreateGoal(1) as ViewResult;

            Assert.IsNotNull(result, "View Result is null");
            Assert.IsInstanceOf(typeof(GroupGoalFormModel),
                result.ViewData.Model, "Wrong View Model");


        }
        public void Edit_Focus_Get_ReturnsView()
        {


            Focus focus = new Focus() { FocusId = 1, FocusName = "Test", Description = "test" };
            focusRepository.Setup(x => x.GetById(1)).Returns(focus);
            Mapper.CreateMap<Focus, FocusFormModel>();
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            ViewResult actual = controller.EditFocus(1) as ViewResult;
            Assert.IsNotNull(actual, "View Result is null");
            Assert.IsInstanceOf(typeof(FocusFormModel),
                actual.ViewData.Model, "Wrong View Model");
        }
        public void Focus_Description_Mandatory()
        {
            // Arrange                    
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            // The MVC pipeline doesn't run, so binding and validation don't run. 
            controller.ModelState.AddModelError("", "mock error message");

            // Act          
            Mapper.CreateMap<FocusFormModel, Focus>();
            FocusFormModel focus = new FocusFormModel();
            focus.Description = string.Empty;
            var result = (ViewResult)controller.CreateFocus(focus);

            // Assert - check that we are passing an invalid model to the view
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
            Assert.AreEqual("CreateFocus", result.ViewName);
        }
        public void Focus()
        {
            Focus mock = new Focus()
            {
                FocusName = "x",
                FocusId = 1,
                Description = "t",
                GroupId = 1
            };
            focusRepository.Setup(x => x.GetById(1)).Returns(mock);

            GroupUser grpUser = new GroupUser()
            {
                UserId = "402bd590-fdc7-49ad-9728-40efbfe512ec",
                Admin = true
            };
            groupUserRepository.Setup(x => x.Get(It.IsAny<Expression<Func<GroupUser, bool>>>())).Returns(grpUser);

            IEnumerable<GroupGoal> fakegoal = new List<GroupGoal> {
            new GroupGoal{ GroupId = 1, Description="Test1Desc",GroupGoalId =1,FocusId =1,GroupUser = grpUser},
             new GroupGoal{ GroupId = 1, Description="Test1Desc",GroupGoalId =2,FocusId = 2,GroupUser = grpUser},
          
          
          }.AsEnumerable();
            groupGoalRepository.Setup(x => x.GetMany(It.IsAny<Expression<Func<GroupGoal, bool>>>())).Returns(fakegoal);

            Mapper.CreateMap<Focus, FocusViewModel>();
            Mapper.CreateMap<GroupGoal, GroupGoalViewModel>();


            MemoryUser user = new MemoryUser("adarsh");
            ApplicationUser applicationUser = getApplicationUser();
            var userContext = new UserInfo
            {
                UserId = user.Id,
                DisplayName = user.UserName,
                UserIdentifier = applicationUser.Email,
                RoleName = Enum.GetName(typeof(UserRoles), applicationUser.RoleId)
            };
            var testTicket = new FormsAuthenticationTicket(
                1,
                user.Id,
                DateTime.Now,
                DateTime.Now.Add(FormsAuthentication.Timeout),
                false,
                userContext.ToString());

            userRepository.Setup(x => x.Get(It.IsAny<Expression<Func<ApplicationUser, bool>>>())).Returns(applicationUser);


            IEnumerable<ApplicationUser> fakeUser = new List<ApplicationUser> {            
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user1",LastName="user1",RoleId=0},
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user2",LastName="user2",RoleId=0},
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user3",LastName="user3",RoleId=0},
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user4",LastName="user4",RoleId=0}
          }.AsEnumerable();
            userRepository.Setup(x => x.GetAll()).Returns(fakeUser);

            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            principal.SetupGet(x => x.Identity.Name).Returns("abc");
            controllerContext.SetupGet(x => x.HttpContext.User).Returns(principal.Object);
            controllerContext.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);
            controller.ControllerContext = controllerContext.Object;

            contextBase.SetupGet(x => x.Request).Returns(httpRequest.Object);
            contextBase.SetupGet(x => x.Response).Returns(httpResponse.Object);
            genericPrincipal.Setup(x => x.Identity).Returns(identity.Object);
            contextBase.SetupGet(a => a.Response.Cookies).Returns(new HttpCookieCollection());
            var formsAuthentication = new DefaultFormsAuthentication();
            formsAuthentication.SetAuthCookie(contextBase.Object, testTicket);
            HttpCookie authCookie = contextBase.Object.Response.Cookies[FormsAuthentication.FormsCookieName];
            var ticket = formsAuthentication.Decrypt(authCookie.Value);
            var goalsetterUser = new SocialGoalUser(ticket);
            principal.Setup(x => x.Identity).Returns(goalsetterUser);

            ViewResult result = controller.Focus(1) as ViewResult;
            Assert.IsNotNull(result);
            Assert.AreEqual("Focus", result.ViewName);


        }
        public void Show_All_Request_View()
        {
            IEnumerable<GroupRequest> request = new List<GroupRequest> {            
            new GroupRequest {GroupId =1,Accepted = false},
            new GroupRequest {GroupId =1,Accepted = false},
            new GroupRequest {GroupId =1,Accepted = false},
            
          }.AsEnumerable();
            groupRequestRepository.Setup(x => x.GetMany(It.IsAny<Expression<Func<GroupRequest, bool>>>())).Returns(request);

            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);

            Mapper.CreateMap<GroupRequest, GroupRequestViewModel>();
            ViewResult result = controller.ShowAllRequests(1) as ViewResult;
            Assert.IsNotNull(result);
            Assert.AreEqual("_RequestsView", result.ViewName);
            Assert.IsInstanceOf(typeof(IEnumerable<GroupRequestViewModel>), result.ViewData.Model, "Wrong View Model");
            var gol = result.ViewData.Model as IEnumerable<GroupRequestViewModel>;
            Assert.AreEqual(3, gol.Count(), "Got wrong number of Groups");


        }
        public void Search_Goal_For_Assigning()
        {
            MemoryUser user = new MemoryUser("adarsh");
            ApplicationUser applicationUser = getApplicationUser();
            var userContext = new UserInfo
            {
                UserId = user.Id,
                DisplayName = user.UserName,
                UserIdentifier = applicationUser.Email,
                RoleName = Enum.GetName(typeof(UserRoles), applicationUser.RoleId)
            };
            var testTicket = new FormsAuthenticationTicket(
                1,
                user.Id,
                DateTime.Now,
                DateTime.Now.Add(FormsAuthentication.Timeout),
                false,
                userContext.ToString());

            //userRepository.Setup(x => x.GetById(1)).Returns(user);

            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            principal.SetupGet(x => x.Identity.Name).Returns("adarsh");            //identity.Setup(x=>x.)
            controllerContext.SetupGet(x => x.HttpContext.User).Returns(principal.Object);
            controllerContext.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);
            controller.ControllerContext = controllerContext.Object;

            contextBase.SetupGet(x => x.Request).Returns(httpRequest.Object);
            contextBase.SetupGet(x => x.Response).Returns(httpResponse.Object);
            genericPrincipal.Setup(x => x.Identity).Returns(identity.Object);

            contextBase.SetupGet(a => a.Response.Cookies).Returns(new HttpCookieCollection());

            var formsAuthentication = new DefaultFormsAuthentication();



            formsAuthentication.SetAuthCookie(contextBase.Object, testTicket);

            HttpCookie authCookie = contextBase.Object.Response.Cookies[FormsAuthentication.FormsCookieName];

            var ticket = formsAuthentication.Decrypt(authCookie.Value);
            var goalsetterUser = new SocialGoalUser(ticket);
            string[] userRoles = { goalsetterUser.RoleName };

            principal.Setup(x => x.Identity).Returns(goalsetterUser);

            IEnumerable<GroupUser> fakeGroupUser = new List<GroupUser> {            
            new GroupUser {AddedDate=DateTime.Now,Admin=true,GroupId=1,GroupUserId=1,UserId="402bd590-fdc7-49ad-9728-40efbfe512ec"},
            new GroupUser {AddedDate=DateTime.Now,Admin=false,GroupId=1,GroupUserId=2,UserId="402bd590-fdc7-49ad-9728-40efbfe512ed"},
            new GroupUser {AddedDate=DateTime.Now,Admin=false,GroupId=1,GroupUserId=3,UserId="402bd590-fdc7-49ad-9728-40efbfe512ee"},
            new GroupUser {AddedDate=DateTime.Now,Admin=true,GroupId=1,GroupUserId=4,UserId="402bd590-fdc7-49ad-9728-40efbfe512ef"},
            new GroupUser {AddedDate=DateTime.Now,Admin=true,GroupId=1,GroupUserId=5,UserId="402bd590-fdc7-49ad-9728-40efbfe512eg"},
            new GroupUser {AddedDate=DateTime.Now,Admin=true,GroupId=2,GroupUserId=6,UserId="402bd590-fdc7-49ad-9728-40efbfe512eh"}
           
          }.AsEnumerable();
            groupUserRepository.Setup(x => x.GetMany(It.IsAny<Expression<Func<GroupUser, bool>>>())).Returns(fakeGroupUser);


            IEnumerable<ApplicationUser> fakeUser = new List<ApplicationUser> {            
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user1",LastName="user1",RoleId=0},
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user2",LastName="user2",RoleId=0},
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user3",LastName="user3",RoleId=0},
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user4",LastName="user4",RoleId=0}
          }.AsEnumerable();
            userRepository.Setup(x => x.GetMany(It.IsAny<Expression<Func<ApplicationUser, bool>>>())).Returns(fakeUser);

            PartialViewResult result = controller.SearchMemberForGoalAssigning(1) as PartialViewResult;
            Assert.IsNotNull(result);
            Assert.AreEqual("_MembersToSearch", result.ViewName);
            Assert.IsInstanceOf(typeof(IEnumerable<MemberViewModel>), result.ViewData.Model, "Wrong View Model");
        }
 public void Groups_List_Test()
 {
     IEnumerable<Group> fake = new List<Group> {
     new Group{ GroupName = "Test1", Description="Test1Desc"},
     new Group { GroupName = "Test2", Description="Test2Desc"},
   
   }.AsEnumerable();
     groupRepository.Setup(x => x.GetAll()).Returns(fake);
     GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
     PartialViewResult result = controller.Groupslist(0) as PartialViewResult;
     Assert.IsNotNull(result);
     Assert.IsInstanceOf(typeof(IEnumerable<Group>), result.ViewData.Model, "Wrong View Model");
     var gol = result.ViewData.Model as IEnumerable<Group>;
     Assert.AreEqual(2, gol.Count(), "Got wrong number of Groups");
 }
 public void Group_Join_Request_Reject_Post_Action_Test()
 {
     GroupRequest request = new GroupRequest()
     {
         UserId = "402bd590-fdc7-49ad-9728-40efbfe512ec",
         GroupId = 1
     };
     groupRequestRepository.Setup(x => x.Get(It.IsAny<Expression<Func<GroupRequest, bool>>>())).Returns(request);
     GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
     var result = controller.RejectRequest(1, "402bd590-fdc7-49ad-9728-40efbfe512ec") as RedirectToRouteResult;
     Assert.AreEqual("ShowAllRequests", result.RouteValues["action"]);
 }
        public void Get_GoalReport_Test()
        {
            GroupGoal goal = new GroupGoal()
            {
                GoalStatusId = 1,
                GroupGoalId = 1
            };
            groupGoalRepository.Setup(x => x.GetById(1)).Returns(goal);
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            JsonResult reslt = controller.GetGoalReport(1) as JsonResult;
            Assert.IsNotNull(reslt);

        }
        public void Goal_Status_Post_Test()
        {
            GoalStatus status = new GoalStatus()
            {
                GoalStatusId = 1,
                GoalStatusType = "InProgress"
            };
            GroupGoal goal = new GroupGoal()
            {
                GroupId = 1,
                GroupGoalId = 1,
                GoalStatusId = 1,
                GoalStatus = status

            };
            groupGoalRepository.Setup(x => x.GetById(1)).Returns(goal);
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            string result = controller.GoalStatus(1, 1) as string;
            Assert.AreEqual("InProgress", result);
        }
        public void Group_Join_Request_Post_Action_Test()
        {
            MemoryUser user = new MemoryUser("adarsh");
            ApplicationUser applicationUser = getApplicationUser();
            var userContext = new UserInfo
            {
                UserId = user.Id,
                DisplayName = user.UserName,
                UserIdentifier = applicationUser.Email,
                RoleName = Enum.GetName(typeof(UserRoles), applicationUser.RoleId)
            };
            var testTicket = new FormsAuthenticationTicket(
                1,
                user.Id,
                DateTime.Now,
                DateTime.Now.Add(FormsAuthentication.Timeout),
                false,
                userContext.ToString());





            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            //principal.SetupGet(x=>x.Get(((SocialGoalUser)(User.Identity)).UserId).Callback(1));

            principal.SetupGet(x => x.Identity.Name).Returns("adarsh");
            //identity.Setup(x=>x.)
            controllerContext.SetupGet(x => x.HttpContext.User).Returns(principal.Object);
            controllerContext.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);
            controller.ControllerContext = controllerContext.Object;

            contextBase.SetupGet(x => x.Request).Returns(httpRequest.Object);
            contextBase.SetupGet(x => x.Response).Returns(httpResponse.Object);
            genericPrincipal.Setup(x => x.Identity).Returns(identity.Object);

            contextBase.SetupGet(a => a.Response.Cookies).Returns(new HttpCookieCollection());

            var formsAuthentication = new DefaultFormsAuthentication();



            formsAuthentication.SetAuthCookie(contextBase.Object, testTicket);

            HttpCookie authCookie = contextBase.Object.Response.Cookies[FormsAuthentication.FormsCookieName];

            var ticket = formsAuthentication.Decrypt(authCookie.Value);
            var goalsetterUser = new SocialGoalUser(ticket);
            string[] userRoles = { goalsetterUser.RoleName };

            principal.Setup(x => x.Identity).Returns(goalsetterUser);
            Mapper.CreateMap<GroupRequestFormModel, GroupRequest>();

            var rslt = controller.GroupJoinRequest(1) as RedirectToRouteResult;
            Assert.AreEqual("Index", rslt.RouteValues["action"]);

        }
        public void Create_Group_Get_ReturnsView()
        {
            //Arrange
            GroupFormModel group = new GroupFormModel();
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            //Act
            PartialViewResult result = controller.CreateGroup() as PartialViewResult;
            //Assert
            Assert.IsNotNull(result);

        }
        public void Edit_Update_Get_View()
        {

            GroupUpdate update = new GroupUpdate()
            {
                GroupUpdateId = 1,
                Updatemsg = "abc",
                GroupGoalId = 1,

            };
            groupUdateRepository.Setup(x => x.GetById(1)).Returns(update);

            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            Mapper.CreateMap<GroupUpdate, GroupUpdateFormModel>();
            PartialViewResult result = controller.EditUpdate(1) as PartialViewResult;
            Assert.IsNotNull(result, "View Result is null");
            Assert.IsInstanceOf(typeof(GroupUpdateFormModel),
                result.ViewData.Model, "Wrong View Model");
            var data = result.ViewData.Model as GroupUpdateFormModel;
            Assert.AreEqual("abc", data.Updatemsg);
        }
        public void Group_Description_Required()
        {
            //Arrange

            MemoryUser user = new MemoryUser("adarsh");
            ApplicationUser applicationUser = getApplicationUser();
            var userContext = new UserInfo
            {
                UserId = user.Id,
                DisplayName = user.UserName,
                UserIdentifier = applicationUser.Email,
                RoleName = Enum.GetName(typeof(UserRoles), applicationUser.RoleId)
            };
            var testTicket = new FormsAuthenticationTicket(
                1,
                user.Id,
                DateTime.Now,
                DateTime.Now.Add(FormsAuthentication.Timeout),
                false,
                userContext.ToString());



            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);

            principal.SetupGet(x => x.Identity.Name).Returns("adarsh");

            controllerContext.SetupGet(x => x.HttpContext.User).Returns(principal.Object);
            controllerContext.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);
            controller.ControllerContext = controllerContext.Object;

            contextBase.SetupGet(x => x.Request).Returns(httpRequest.Object);
            contextBase.SetupGet(x => x.Response).Returns(httpResponse.Object);
            genericPrincipal.Setup(x => x.Identity).Returns(identity.Object);

            contextBase.SetupGet(a => a.Response.Cookies).Returns(new HttpCookieCollection());

            var formsAuthentication = new DefaultFormsAuthentication();



            formsAuthentication.SetAuthCookie(contextBase.Object, testTicket);

            HttpCookie authCookie = contextBase.Object.Response.Cookies[FormsAuthentication.FormsCookieName];

            var ticket = formsAuthentication.Decrypt(authCookie.Value);
            var goalsetterUser = new SocialGoalUser(ticket);


            principal.Setup(x => x.Identity).Returns(goalsetterUser);


            // The MVC pipeline doesn't run, so binding and validation don't run. 
            controller.ModelState.AddModelError("", "mock error message");


            // Act          

            Mapper.CreateMap<GroupFormModel, Group>();
            GroupFormModel group = new GroupFormModel();
            group.Description = string.Empty;
            var result = (ViewResult)controller.CreateGroup(group);
            // Assert - check that we are passing an invalid model to the view
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
            Assert.AreEqual("CreateGroup", result.ViewName);

        }
        public void Edit_Update_Post()
        {
            MemoryUser user = new MemoryUser("adarsh");
            ApplicationUser applicationUser = getApplicationUser();
            var userContext = new UserInfo
            {
                UserId = user.Id,
                DisplayName = user.UserName,
                UserIdentifier = applicationUser.Email,
                RoleName = Enum.GetName(typeof(UserRoles), applicationUser.RoleId)
            };
            var testTicket = new FormsAuthenticationTicket(
                1,
                user.Id,
                DateTime.Now,
                DateTime.Now.Add(FormsAuthentication.Timeout),
                false,
                userContext.ToString());


            userRepository.Setup(x => x.Get(It.IsAny<Expression<Func<ApplicationUser, bool>>>())).Returns(applicationUser);

            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);

            principal.SetupGet(x => x.Identity.Name).Returns("adarsh");
            controllerContext.SetupGet(x => x.HttpContext.User).Returns(principal.Object);
            controllerContext.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);
            controller.ControllerContext = controllerContext.Object;

            contextBase.SetupGet(x => x.Request).Returns(httpRequest.Object);
            contextBase.SetupGet(x => x.Response).Returns(httpResponse.Object);
            genericPrincipal.Setup(x => x.Identity).Returns(identity.Object);

            contextBase.SetupGet(a => a.Response.Cookies).Returns(new HttpCookieCollection());

            var formsAuthentication = new DefaultFormsAuthentication();
            formsAuthentication.SetAuthCookie(contextBase.Object, testTicket);

            HttpCookie authCookie = contextBase.Object.Response.Cookies[FormsAuthentication.FormsCookieName];

            var ticket = formsAuthentication.Decrypt(authCookie.Value);
            var goalsetterUser = new SocialGoalUser(ticket);
            string[] userRoles = { goalsetterUser.RoleName };

            principal.Setup(x => x.Identity).Returns(goalsetterUser);
            //GoalController controller = new GoalController(goalService, metricService, focusService, supportService, updateService, commentService, userService, securityTokenService, supportInvitationService, goalStatusService, commentUserService, updateSupportService);
            Mapper.CreateMap<GroupUpdateFormModel, GroupUpdate>();
            Mapper.CreateMap<GroupUpdate, GroupUpdateViewModel>();

            Metric fakeMetric = new Metric()
            {
                MetricId = 1,
                Type = "%"
            };
            GroupGoal goal = new GroupGoal()
            {
                Metric = fakeMetric,
                Target = 100,
                GroupGoalId = 1
            };
            groupGoalRepository.Setup(x => x.GetById(1)).Returns(goal);


            IEnumerable<GroupUpdate> updt = new List<GroupUpdate> {            
            new GroupUpdate { GroupUpdateId =1, Updatemsg = "t1",GroupGoalId =1},
             new GroupUpdate { GroupUpdateId =2, Updatemsg = "t2",GroupGoalId =1},
              new GroupUpdate { GroupUpdateId =3, Updatemsg = "t3",GroupGoalId =2},
            
          }.AsEnumerable();
            groupUdateRepository.Setup(x => x.GetMany(It.IsAny<Expression<Func<GroupUpdate, bool>>>())).Returns(updt);

            GroupUser grpuser = new GroupUser()
            {
                GroupUserId = 1,
                UserId = "402bd590-fdc7-49ad-9728-40efbfe512ec"
            };
            groupUserRepository.Setup(x => x.Get(It.IsAny<Expression<Func<GroupUser, bool>>>())).Returns(grpuser);

            GroupUpdateUser updtuser = new GroupUpdateUser()
            {
                GroupUpdateId = 1,
                UserId = "402bd590-fdc7-49ad-9728-40efbfe512ec"
            };
            groupUpdateUserRepository.Setup(x => x.Get(It.IsAny<Expression<Func<GroupUpdateUser, bool>>>())).Returns(updtuser);
            GroupUpdateFormModel mock = new GroupUpdateFormModel();
            mock.Updatemsg = "mock";
            mock.GroupGoalId = 1;
            mock.status = 34;
            PartialViewResult result = controller.EditUpdate(mock) as PartialViewResult;
            Assert.IsNotNull(result);
            Assert.IsInstanceOf(typeof(GroupUpdateListViewModel),
            result.ViewData.Model, "Wrong View Model");
        }
        public void Create_Focus()
        {
            MemoryUser user = new MemoryUser("adarsh");
            ApplicationUser applicationUser = getApplicationUser();
            var userContext = new UserInfo
            {
                UserId = user.Id,
                DisplayName = user.UserName,
                UserIdentifier = applicationUser.Email,
                RoleName = Enum.GetName(typeof(UserRoles), applicationUser.RoleId)
            };
            var testTicket = new FormsAuthenticationTicket(
                1,
                user.Id,
                DateTime.Now,
                DateTime.Now.Add(FormsAuthentication.Timeout),
                false,
                userContext.ToString());
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            principal.SetupGet(x => x.Identity.Name).Returns("adarsh");
            controllerContext.SetupGet(x => x.HttpContext.User).Returns(principal.Object);
            controllerContext.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);
            controller.ControllerContext = controllerContext.Object;

            contextBase.SetupGet(x => x.Request).Returns(httpRequest.Object);
            contextBase.SetupGet(x => x.Response).Returns(httpResponse.Object);
            genericPrincipal.Setup(x => x.Identity).Returns(identity.Object);
            contextBase.SetupGet(a => a.Response.Cookies).Returns(new HttpCookieCollection());
            var formsAuthentication = new DefaultFormsAuthentication();
            formsAuthentication.SetAuthCookie(contextBase.Object, testTicket);
            HttpCookie authCookie = contextBase.Object.Response.Cookies[FormsAuthentication.FormsCookieName];
            var ticket = formsAuthentication.Decrypt(authCookie.Value);
            var goalsetterUser = new SocialGoalUser(ticket);
            principal.Setup(x => x.Identity).Returns(goalsetterUser);




            FocusFormModel focus = new FocusFormModel();
            focus.GroupId = 1;
            focus.FocusName = "t";
            focus.Description = "t";
            Focus mock = new Focus()
            {
                FocusName = "x",
                FocusId = 2,
                Description = "t",
                GroupId = 1
            };

            //Create Mapping 
            Mapper.CreateMap<FocusFormModel, Focus>();


            // Act
            var result = (RedirectToRouteResult)controller.CreateFocus(focus);
            Assert.AreEqual("Focus", result.RouteValues["action"]);


        }
        public void Delete_Update_Get_ReturnsView()
        {

            GroupUpdate update = new GroupUpdate()
            {
                GroupUpdateId = 1,
                Updatemsg = "abc",
                GroupGoalId = 1,

            };
            groupUdateRepository.Setup(x => x.GetById(1)).Returns(update);

            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            PartialViewResult result = controller.DeleteUpdate(1) as PartialViewResult;
            Assert.IsNotNull(result, "View Result is null");
            Assert.IsInstanceOf(typeof(GroupUpdate),
                 result.ViewData.Model, "Wrong View Model");
            var group = result.ViewData.Model as GroupUpdate;
            Assert.AreEqual("abc", group.Updatemsg, "Got wrong message");

        }
        public void Create_Focus_Get_ReturnsView()
        {
            //Arrange

            Group group = new Group() { GroupId = 1, GroupName = "Test", Description = "test" };
            groupRepository.Setup(x => x.GetById(1)).Returns(group);
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            //Act
            ActionResult result = controller.CreateFocus(1) as ActionResult;
            //Assert
            Assert.IsNotNull(result);

        }
        public void Delete_Update_Post()
        {

            GroupUpdate update = new GroupUpdate()
            {
                GroupUpdateId = 1,
                Updatemsg = "abc",
                GroupGoalId = 1,

            };
            groupUdateRepository.Setup(x => x.GetById(1)).Returns(update);
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            var result = controller.DeleteConfirmedUpdate(1) as RedirectToRouteResult;
            Assert.AreEqual("GroupGoal", result.RouteValues["action"]);

        }
        public void Create_Goal()
        {
            MemoryUser user = new MemoryUser("adarsh");
            ApplicationUser applicationUser = getApplicationUser();
            var userContext = new UserInfo
            {
                UserId = user.Id,
                DisplayName = user.UserName,
                UserIdentifier = applicationUser.Email,
                RoleName = Enum.GetName(typeof(UserRoles), applicationUser.RoleId)
            };
            var testTicket = new FormsAuthenticationTicket(
                1,
                user.Id,
                DateTime.Now,
                DateTime.Now.Add(FormsAuthentication.Timeout),
                false,
                userContext.ToString());
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            principal.SetupGet(x => x.Identity.Name).Returns("adarsh");
            controllerContext.SetupGet(x => x.HttpContext.User).Returns(principal.Object);
            controllerContext.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);
            controller.ControllerContext = controllerContext.Object;

            contextBase.SetupGet(x => x.Request).Returns(httpRequest.Object);
            contextBase.SetupGet(x => x.Response).Returns(httpResponse.Object);
            genericPrincipal.Setup(x => x.Identity).Returns(identity.Object);

            contextBase.SetupGet(a => a.Response.Cookies).Returns(new HttpCookieCollection());

            var formsAuthentication = new DefaultFormsAuthentication();



            formsAuthentication.SetAuthCookie(contextBase.Object, testTicket);

            HttpCookie authCookie = contextBase.Object.Response.Cookies[FormsAuthentication.FormsCookieName];

            var ticket = formsAuthentication.Decrypt(authCookie.Value);
            var goalsetterUser = new SocialGoalUser(ticket);
            string[] userRoles = { goalsetterUser.RoleName };

            principal.Setup(x => x.Identity).Returns(goalsetterUser);
            GroupUser grpuser = new GroupUser()
            {
                GroupId = 1,
                UserId = "402bd590-fdc7-49ad-9728-40efbfe512ec"
            };
            groupUserRepository.Setup(x => x.Get(It.IsAny<Expression<Func<GroupUser, bool>>>())).Returns(grpuser);


            // Act
            Mapper.CreateMap<GroupGoalFormModel, GroupGoal>();

            GroupGoalFormModel goal = new GroupGoalFormModel()
            {
                GoalName = "t",
                GroupGoalId = 1,
                StartDate = DateTime.Now,
                EndDate = DateTime.Now.AddDays(1),
                Description = "t",
                GroupId = 1,
                GroupUserId = 1,


            };
            var result = (RedirectToRouteResult)controller.CreateGoal(goal);


            Assert.AreEqual("Index", result.RouteValues["action"]);


        }
        public void Display_Update_Supporters_Count()
        {
            IEnumerable<GroupUpdateSupport> updtsprt = new List<GroupUpdateSupport> {            

            new GroupUpdateSupport { GroupUpdateSupportId =1, GroupUpdateId = 1,GroupUserId = 1},
            new GroupUpdateSupport { GroupUpdateSupportId =2, GroupUpdateId = 1,GroupUserId = 2},
            new GroupUpdateSupport { GroupUpdateSupportId =3, GroupUpdateId = 1,GroupUserId = 3},
          
             
            
          }.AsEnumerable();

            groupUpdateSupportRepository.Setup(x => x.GetMany(It.IsAny<Expression<Func<GroupUpdateSupport, bool>>>())).Returns(updtsprt);
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            JsonResult count = controller.DisplayUpdateSupportCount(1) as JsonResult;
            Assert.IsNotNull(count);
            Assert.AreEqual(3, count.Data);

        }
        public void Delete_Focus_Get_ReturnsView()
        {
            Focus fake = new Focus()
            {
                FocusId = 1,
                FocusName = "test",
                Description = "test"
            };
            focusRepository.Setup(x => x.GetById(1)).Returns(fake);
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);

            ViewResult result = controller.DeleteFocus(1) as ViewResult;

            Assert.IsNotNull(result, "View Result is null");
            Assert.IsInstanceOf(typeof(Focus),
                 result.ViewData.Model, "Wrong View Model");
            var focus = result.ViewData.Model as Focus;
            Assert.AreEqual("test", focus.Description, "Got wrong Focus Description");

        }
        public void Supporters_Of_Updates_List()
        {

            IEnumerable<ApplicationUser> fakeUser = new List<ApplicationUser> {            
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user1",LastName="user1",RoleId=0},
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user2",LastName="user2",RoleId=0},
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user3",LastName="user3",RoleId=0},
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user4",LastName="user4",RoleId=0}
          }.AsEnumerable();
            userRepository.Setup(x => x.GetAll()).Returns(fakeUser);
            IEnumerable<GroupUpdateSupport> fake = new List<GroupUpdateSupport> {            
            new GroupUpdateSupport { GroupUpdateSupportId =1, GroupUpdateId = 1, GroupUserId = 1},
            new GroupUpdateSupport { GroupUpdateSupportId =2, GroupUpdateId = 1, GroupUserId = 2},
            new GroupUpdateSupport { GroupUpdateSupportId =3, GroupUpdateId = 1, GroupUserId = 3},
          
          }.AsEnumerable();
            groupUpdateSupportRepository.Setup(x => x.GetMany(It.IsAny<Expression<Func<GroupUpdateSupport, bool>>>())).Returns(fake);

            GroupUser grpuser = new GroupUser()
            {
                GroupUserId = 1,
                UserId = "402bd590-fdc7-49ad-9728-40efbfe512ec"
            };
            groupUserRepository.Setup(x => x.Get(It.IsAny<Expression<Func<GroupUser, bool>>>())).Returns(grpuser);

            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            PartialViewResult result = controller.SupportersOfUpdate(1) as PartialViewResult;
            Assert.IsNotNull(result);
            Assert.IsInstanceOf(typeof(GroupUpdateSupportersViewModel), result.ViewData.Model, "Wrong View Model");
        }
        public void Delete_Group_Post()
        {
            Group fake = new Group()
            {
                GroupId = 1,
                GroupName = "test",
                Description = "test"
            };
            groupRepository.Setup(x => x.GetById(fake.GroupId)).Returns(fake);


            Assert.IsNotNull(fake);
            Assert.AreEqual(1, fake.GroupId);
            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            var result = controller.DeleteConfirmedGroup(1) as RedirectToRouteResult;
            Assert.AreEqual("Index", result.RouteValues["action"]);

        }
        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);
        }
        public void Joined_User_Test()
        {
            IEnumerable<ApplicationUser> fakeUser = new List<ApplicationUser> {            
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user1",LastName="user1",RoleId=0},
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user2",LastName="user2",RoleId=0},
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user3",LastName="user3",RoleId=0},
              new ApplicationUser{Activated=true,Email="*****@*****.**",FirstName="user4",LastName="user4",RoleId=0}
          }.AsEnumerable();
            userRepository.Setup(x => x.GetAll()).Returns(fakeUser);


            IEnumerable<GroupUser> fakeGroupUser = new List<GroupUser> {            
            new GroupUser {AddedDate=DateTime.Now,Admin=true,GroupId=1,GroupUserId=1,UserId="402bd590-fdc7-49ad-9728-40efbfe512ec"},
            new GroupUser {AddedDate=DateTime.Now,Admin=false,GroupId=1,GroupUserId=1,UserId="402bd590-fdc7-49ad-9728-40efbfe512ed"},
            new GroupUser {AddedDate=DateTime.Now,Admin=false,GroupId=1,GroupUserId=1,UserId="402bd590-fdc7-49ad-9728-40efbfe512ee"},
            new GroupUser {AddedDate=DateTime.Now,Admin=true,GroupId=1,GroupUserId=1,UserId="402bd590-fdc7-49ad-9728-40efbfe512ef"},
            new GroupUser {AddedDate=DateTime.Now,Admin=true,GroupId=1,GroupUserId=1,UserId="402bd590-fdc7-49ad-9728-40efbfe512eg"},
            new GroupUser {AddedDate=DateTime.Now,Admin=true,GroupId=2,GroupUserId=1,UserId="402bd590-fdc7-49ad-9728-40efbfe512eh"}
           
          }.AsEnumerable();
            groupUserRepository.Setup(x => x.GetAll()).Returns(fakeGroupUser);


            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);

            // Act
            ViewResult result = controller.JoinedUsers(1) as ViewResult;
            Assert.IsNotNull(result, "View Result is null");
            Assert.IsInstanceOf(typeof(GroupMemberViewModel),
            result.ViewData.Model, "Wrong View Model");




        }
        public void Invite_Users()
        {
            Mapper.CreateMap<Group, GroupViewModel>();
            Group grp = new Group()
            {
                GroupId = 1,
                GroupName = "t",
                Description = "t"
            };
            groupRepository.Setup(x => x.GetById(1)).Returns(grp);

            GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService);
            ViewResult reslt = controller.InviteUsers(1) as ViewResult;
            Assert.IsNotNull(reslt);
            Assert.IsInstanceOf(typeof(GroupViewModel),
               reslt.ViewData.Model, "Wrong View Model");
            //var grpview = reslt.ViewData.Model as GroupViewModel;
            //Assert.AreEqual("t", grpview.GroupName);

        }