public void PostCreate()
        {
            // モック用意
            var mockset = new Mock<DbSet<BoardEntity>>();
            var mockcontext = new Mock<BoardDbContext>();

            // ダミーデータの生成
            var model = new BoardCreateModel {
                Title = "題名",
                Text = "本文"
            };

            // Addの返り値フック
            var dummy = new BoardEntity { Id = 1, Title = model.Title, Text = model.Text };
            mockset.As<IDbSet<BoardEntity>>().Setup( m => m.Add( It.IsAny<BoardEntity>() ) ).Returns( dummy );

            mockcontext.Setup( m => m.Boards ).Returns( mockset.Object );

            var controller = new BoardController(mockcontext.Object);
            var result = controller.Create(model) as RedirectResult;
            Assert.IsNotNull( result );

            // Addが呼ばれたかチェック
            mockset.Verify( m => m.Add( It.Is<BoardEntity>( o => o.Title == model.Title && o.Text == model.Text ) ), Times.Once );

            // SaveChangesがよばれたかチェック
            mockcontext.Verify( m => m.SaveChanges(), Times.Once );

            Assert.AreEqual( result.Url, "/Board/Show/1" );
        }
 public void Create()
 {
     // エラーが無いかだけチェック
     var controller = new BoardController();
     var result = controller.Create() as ViewResult;
     Assert.IsNotNull( result );
 }