コード例 #1
0
        public void Details_ValidRequest_ReturnsVideo()
        {
            // Arrange
            var   id    = 1;
            Video video = null;

            _mockVideoRepository.Setup(x => x.Get(It.IsAny <int>()))
            .Returns <int>(x => video = new Video {
                VideoId = id, Title = "Video 1"
            });

            // Act
            var result = _sut.Details(id);

            // Assert
            Assert.IsInstanceOfType(result, typeof(ActionResult));
            var viewResult  = (ViewResult)result;
            var actualVideo = (Video)viewResult.Model;

            Assert.AreEqual(video.VideoId, actualVideo.VideoId);
            Assert.AreEqual(video.Title, actualVideo.Title);
        }