예제 #1
0
        public void TestProjectController_UpdateProjectsDeleteItem(string httpMethod)
        {
            SetUpProjectControllerForTesting(httpMethod);
            projectController.CurrentUser = user;

            ProjectsModel model = new ProjectsModel();

            model.ProjectId = projectId;
            FormCollection   form             = new FormCollection();
            ProjectListModel projectListModel = new ProjectListModel();

            long _projectId = this.db.Context.Projects.Where(p => p.OwnerId == user.UserId && p.ProjectStatusTypeId == ProjectStatusTypeEnum.Inactive).OrderByDescending(p => p.ProjectId).Select(p => p.ProjectId).FirstOrDefault();

            projectListModel.ProjectId = _projectId;
            model.Items.Add(projectListModel);

            System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection();
            nameValueCollection.Add(_projectId.ToString(), _projectId.ToString());
            form.Add(nameValueCollection);

            ViewResult result = projectController.UpdateProjectsDeleteItem(model, form) as ViewResult;

            Assert.That(result, Is.Not.EqualTo(null));
            Assert.That(result.ViewName, Is.EqualTo("Projects"));
            Assert.That(result.Model, Is.Not.EqualTo(null));
            Assert.That((result.Model as ProjectsModel).DeleteProjects.First().ProjectId, Is.EqualTo(_projectId));
        }