Exemplo n.º 1
0
        public void GetIndex()
        {
            ProjectController controller = new ProjectController();

            var result = controller.Index();

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(ViewResult));

            var vresult = (ViewResult)result;

            Assert.IsNotNull(vresult.Model);
            Assert.IsInstanceOfType(vresult.Model, typeof(IEnumerable<Project>));
        }
Exemplo n.º 2
0
        public void PostCreateFirstProject()
        {
            Project project = new Project() { Name = "New Project" };
            List<Project> projects = new List<Project>();
            ProjectController controller = new ProjectController(projects);

            var result = controller.Create(project);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));

            var rresult = (RedirectToRouteResult)result;

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

            Assert.AreEqual(1, projects.Count);
            Assert.IsTrue(projects.Any(p => p.Name == "New Project"));
            Assert.AreEqual(1, project.Id);
        }
Exemplo n.º 3
0
        public void Setup()
        {
            this.projects = new List<Project>()
            {
                new Project() { Id = 1, Name = "Project 1" },
                new Project() { Id = 2, Name = "Project 2" },
                new Project() { Id = 3, Name = "Project 3" }
            };

            this.controller = new ProjectController(this.projects);
        }