Exemplo n.º 1
0
        public ActionResult Convert(Thought thought, string outcome)
        {
            var newTodo = new Todo
                              {
                                  Title = thought.Name,
                                  Outcome = outcome,
                                  Topic = Topic.Topics.Find(topic => topic.Id == thought.Topic.Id)
                              };

            CreateTodo(newTodo);

            Thought.Thoughts.RemoveAll(thoughtToRemove => thoughtToRemove.Name == thought.Name);

            return RedirectToAction("Process", "Thought");
        }
        public void ShouldConvertAThoughtToATodo()
        {
            var expectedTodo = new Todo
                                   {
                                       Title = "Build a killer web site",
                                       Outcome = "Site has 100 visitors per day",
                                       Topic = Topic.Topics[0]
                                   };

            var thought = new Thought {Name = "Build a killer web site", Topic = Topic.Topics[0]};

            var result = (RedirectToRouteResult)new TodoController().Convert(thought, "Site has 100 visitors per day");

            //Assert.Contains(expectedTodo, Todo.ThingsToBeDone); //can't see why this wouldn't work!!?
            Assert.IsFalse(Thought.Thoughts.Contains(thought));
            Assert.AreEqual("Process", result.RouteValues["action"]);
            Assert.AreEqual("Thought", result.RouteValues["controller"]);
        }