Ejemplo n.º 1
0
        public void CreateNoteParamOverloadSuccessCreate()
        {
            NotesController controller = new NotesController(_service);
            SetupControllerContext(controller, TestUser3);

            ViewModel<Note> model = new ViewModel<Note>(new Note
                                                           {
                                                               Text = "new note"
                                                           });
            RedirectToRouteResult viewResult = controller.CreateNote(model) as RedirectToRouteResult;
            Note note = _service.MockNotes.List.Last();

            Assert.AreEqual(21, _service.MockNotes.List.Count);
            Assert.AreEqual(TestUser3, note.User);
            Assert.AreEqual("new note", note.Text);
            Assert.IsTrue(_saveCalled);

            Assert.IsNotNull(viewResult, "viewResult");
        }
Ejemplo n.º 2
0
        public void CreateNoteEmptyParamOverload()
        {
            NotesController controller = new NotesController(_service);
            SetupControllerContext(controller, TestUser2);

            ViewResult viewResult = controller.CreateNote() as ViewResult;
            Assert.IsNotNull(viewResult, "viewResult");

            ViewModel<Note> viewModel = viewResult.Model as ViewModel<Note>;
            Assert.IsNotNull(viewModel, "viewModel");
        }
Ejemplo n.º 3
0
        public void CreateNoteParamOverloadFailCreate()
        {
            NotesController controller = new NotesController(_service);
            SetupControllerContext(controller, TestUser3);

            ViewModel<Note> note = new ViewModel<Note>();
            controller.ModelState.AddModelError("testError", "Test error message");

            ViewResult viewResult = controller.CreateNote(note) as ViewResult;
            Assert.AreEqual(20, _service.MockNotes.List.Count);
            Assert.IsFalse(_saveCalled);
            Assert.IsNotNull(viewResult, "viewResult");
        }