Exemple #1
0
        //
        // GET: /Session/
        public ActionResult Index()
        {
            if (Session["SessionSummary"] == null)
                Session["SessionSummary"] = new SessionSummary();

            return View(Session["SessionSummary"]);
        }
        public void Should_Display_SessionSummary_On_Index()
        {
            var summary = new SessionSummary { AddedTodos = { new Todo { Title = "Complete Management Report" } } };

            var sessionController = new SessionController();
            var builder = new TestControllerBuilder();
            builder.InitializeController(sessionController);
            builder.Session["SessionSummary"] = summary;

            Assert.AreEqual(summary, sessionController.Index().AssertViewRendered().ViewData.Model);
        }
        public void Should_Add_Todo_Item()
        {
            var todo = new Todo {Title = "Learn MVC Controllers"};

            var sessionSummary = new SessionSummary();
            sessionSummary.AddedTodos.Add(todo);

            todoRepository.SaveOrUpdate(todo);
            LastCall.Repeat.Once();

            todoController.Create(todo).AssertActionRedirect().ToAction("Index");
            Assert.AreEqual(sessionSummary, todoController.Session["SessionSummary"]);
        }
Exemple #4
0
        public bool Equals(SessionSummary other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;

            //This Equals makes sure what's in the lists is compared, not the reference
            //equality on the List<T> itself
            if (other.AddedTodos.Count != other.AddedTodos.Count) return false;
            for (int i = 0; i < other.AddedTodos.Count; i++)
            {
                if (!other.AddedTodos[i].Equals(AddedTodos[i]))
                    return false;
            }
            return true;
        }
Exemple #5
0
        private void CreateTodo(Todo todo)
        {
            repository.SaveOrUpdate(todo);
            if (Session["SessionSummary"] == null)
                Session["SessionSummary"] = new SessionSummary();

            var summary = ((SessionSummary) Session["SessionSummary"]);
            summary.AddedTodos.Add(todo);
        }