public virtual ActionResult Create(BookViewModel bookViewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(bookViewModel);
            }

            var book = Map<BookViewModel, Book>(bookViewModel);
            bookRepository.Add(book);

            return RedirectToAction("Index");
        }
 public virtual ViewResult Create()
 {
     var bookViewModel = new BookViewModel();
     return View(bookViewModel);
 }
        public void ShouldPostCreateWhereNotValid()
        {
            var bookViewModel = new BookViewModel();
            controller.ModelState.AddModelError("key", "model is invalid");

            mocks.ReplayAll();
            var result = (ViewResult)controller.Create(bookViewModel);
            mocks.VerifyAll();

            Assert.Equal(bookViewModel, result.Model);
        }
        public virtual ActionResult Edit(BookViewModel bookViewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(bookViewModel);
            }

            var book = bookRepository.Get(bookViewModel.Id);
            if (book == null)
            {
                return ViewNotFound("No book with id: " + bookViewModel.Id);
            }

            Map(bookViewModel, book);

            return RedirectToAction("Index");
        }
        public void ShouldPostCreate()
        {
            var bookViewModel = new BookViewModel();

            Expect.Call(() => bookRepositoryMock.Add(Arg<Book>.Is.Anything));

            mocks.ReplayAll();
            var result = (RedirectToRouteResult)controller.Create(bookViewModel);
            mocks.VerifyAll();

            Assert.True(result.RouteValues.ContainsValue("Index"));
        }