public void TestCreateGetActionAndRedirectToCreateView()
        {
            var cardServiceMock = new Mock<ICardService>();
            var controller = new CardController(cardServiceMock.Object);
            var actual = controller.Create() as ViewResult;

            Assert.NotNull(actual);
        }
        public void TestCreatePostActionAndRedirectToIndexView()
        {
            var cardServiceMock = new Mock<ICardService>();
            var card = TestHelper.CreateRandomCardWithId(TestHelper.CreateRandomId());

            var controller = new CardController(cardServiceMock.Object);
            var actual = controller.Create(card);

            cardServiceMock.Verify(service => service.Add(card), Times.Once());

            actual.ShouldBeRedirectionTo(new { action = "Index" });
        }
        public void TestCreateActionRedirectToCreateViewAgainIfModelStateIsInvalid()
        {
            var cardServiceMock = new Mock<ICardService>();
            var cardId = TestHelper.CreateRandomId();
            var card = TestHelper.CreateRandomCardWithId(cardId);

            var controller = new CardController(cardServiceMock.Object);
            controller.ModelState.AddModelError("Some Error", new Exception());
            var actual = controller.Create(card) as ViewResult;

            cardServiceMock.Verify(service => service.Add(card), Times.Never());

            Assert.NotNull(actual);
            Assert.False(controller.ModelState.IsReadOnly);
            actual.WithNameHasModelType<Card>(string.Empty);
        }