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>)); }
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); }
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); }