Ejemplo n.º 1
0
        public void TestProjectController_ProjectTransfer_ShouldSendOutEmailAndRedirectToActionProjects(string httpMethod, string projectStatusCase)
        {
            SetUpProjectControllerForTesting(httpMethod);
            projectController.CurrentUser = user;

            projectController.ViewData["PageMessages"] = new Messages();
            projectController.ViewData["KeyMessages"]  = new Messages();

            long _projectId;

            if (projectStatusCase == "ProjectStatusIsOpen")
            {
                _projectId = this.db.Context.Projects.Where(p => p.OwnerId == user.UserId && p.ProjectStatusTypeId == ProjectStatusTypeEnum.Open)
                             .OrderByDescending(p => p.ProjectId)
                             .Select(p => p.ProjectId)
                             .FirstOrDefault();

                RedirectResult result = projectController.ProjectTransfer(_projectId, "*****@*****.**") as RedirectResult;

                Assert.That(result, Is.Not.EqualTo(null));
                Assert.That(result.Url, Is.EqualTo("/Projectdashboard/Projects"));
            }
            if (projectStatusCase == "ProjectStatusIsNotOpen")
            {
                _projectId = this.db.Projects.Where(p => p.OwnerId == user.UserId && p.ProjectStatusTypeId == ProjectStatusTypeEnum.ClosedLost)
                             .OrderByDescending(p => p.ProjectId)
                             .Select(p => p.ProjectId)
                             .FirstOrDefault();

                RedirectResult result = projectController.ProjectTransfer(_projectId, "*****@*****.**") as RedirectResult;

                Assert.That(result, Is.EqualTo(null));
            }
        }