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

            var author = Map<AuthorViewModel, Author>(authorViewModel);
            authorRepository.Add(author);

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

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

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

            var author = authorRepository.Get(authorViewModel.Id);
            if (author == null)
            {
                return ViewNotFound("No author with id: " + authorViewModel.Id);
            }

            Map(authorViewModel, author);

            return RedirectToAction("Index");
        }
        public void ShouldPostCreate()
        {
            var authorViewModel = new AuthorViewModel();

            Expect.Call(() => authorRepositoryMock.Add(Arg<Author>.Is.Anything));

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

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