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

            List <long> _projectIds = this.db.Context.Projects.Where(p => p.OwnerId == user.UserId && p.Name.Contains("AA")).Select(p => p.ProjectId).Take(3).ToList();

            ProjectsModel model = new ProjectsModel();

            PagedList <ProjectListModel> items = new PagedList <ProjectListModel>();

            foreach (long projectId in _projectIds)
            {
                ProjectListModel item = new ProjectListModel();
                item.ProjectId = projectId;
                items.Add(item);
            }

            model.Items = items;

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

            FormCollection collection = new FormCollection();

            for (int i = 0; i < model.Items.Count; i++)
            {
                collection[model.Items[i].ProjectId.ToString()] = model.Items[i].ProjectId.ToString();
            }

            ViewResult result = projectController.ProjectsDelete(model, collection) as ViewResult;

            Assert.That(this.response.HasError, Is.EqualTo(false));
            Assert.That(result, Is.Not.EqualTo(null));
            Assert.That(result.ViewName, Is.EqualTo("Projects"));
        }