public void Slash_Tasks_Slash_New_Has_Empty_View_Model() { // Arrange TasksController controller = new TasksController(); // Act EditTaskViewModel viewModel = (EditTaskViewModel)controller.New().Model; // Assert Assert.IsNull(viewModel.Task.Description); }
public void Redirect_To_The_List_When_Valid_Task_Is_Posted() { // Arrange TasksController controller = new TasksController(new FakeTasksRepository()); // Act JsonResult result = controller.Edit(new Task {ID = 1, Description = "Changed Description"}) as JsonResult; // Assert Assert.IsTrue((bool)result.Data); }
public void Slash_Tasks_Slash_New_Displays_New_Task_Form() { // Arrange TasksController controller = new TasksController(); // Act ViewResult result = controller.New(); // Assert Assert.AreEqual("New Task", result.ViewBag.Title); }
public void Slash_Shows_Todo_List() { // Arrange TasksController controller = new TasksController(); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.IsNotNull(result); Assert.AreEqual("Tasks", result.ViewBag.Title); }
public void Display_Get_The_Correct_Task_From_The_Repository() { // Arrange TasksController controller = new TasksController(repository.Object); // Act ViewResult result = controller.Edit(1) as ViewResult; EditTaskViewModel model = result.Model as EditTaskViewModel; // Assert Assert.IsNotNull(model); Assert.AreEqual(1, model.Task.ID); }
public void POST_To_Slash_Tasks_Slash_New_Redirects_To_Slash_Tasks() { // Arrange TasksController controller = new TasksController(); Task newTask = new Task() { Description = "Description" }; // Act RedirectToRouteResult result = controller.New(newTask) as RedirectToRouteResult; // Assert Assert.AreEqual("tasks", result.RouteValues["controller"]); Assert.AreEqual("index", result.RouteValues["action"]); }
public void Slash_Tasks_Displays_Task() { // Arrange FakeTasksRepository repository = new FakeTasksRepository(); repository.Save(new Task() { Description = "Description1" }); TasksController controller = new TasksController(repository); // Act ViewResult result = controller.Index() as ViewResult; Task task = ((List<Task>)result.Model).Single(x => x.Description == "Description1") as Task; // Assert Assert.AreEqual("Description1", task.Description); }