예제 #1
0
        public void Find_ZeroId_ThrowsOutOfRangeException()
        {
            var boardRepo  = Mock.Of <IBoardRepository>();
            var controller = new BoardsController(boardRepo);

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                controller.Find(0);
            });
        }
예제 #2
0
        public void Find_ValidId_DoesLookupThroughRepository()
        {
            var boardRepo = new Mock <IBoardRepository>();

            boardRepo.Setup(x => x.Find(It.IsAny <int>())).Returns(new Board());

            var controller = new BoardsController(boardRepo.Object);

            controller.Find(1);

            boardRepo.Verify(x => x.Find(1), Times.Once);
        }