Beispiel #1
0
        private void MethodGetVideoWithVideoIdReturnsVideo()
        {
            _videoServiceMock.Setup(repo => repo.GetById(1)).Returns(_video1);

            var actionResult = _controller.GetVideo(1);

            Assert.IsType <OkObjectResult>(actionResult);

            var result         = (OkObjectResult)actionResult;
            var responseObject = (ResponseObject)result.Value;

            Assert.Equal(_video1, responseObject.Data);
        }
        public async void GetVideo_CalledWithInvalidId_ReturnsNotFoundWithId()
        {
            IUnitOfWork    unitOfWork    = Substitute.For <IUnitOfWork>();
            IVideoManager  videoManager  = Substitute.For <IVideoManager>();
            ICookieManager cookieManager = Substitute.For <ICookieManager>();

            long  notValidId = 1;
            Video video      = null;

            unitOfWork.Videos.GetById(notValidId).Returns(video);

            var videosController = new VideosController(unitOfWork, videoManager, cookieManager);

            var result = await videosController.GetVideo(notValidId);

            var notFoundObjectResult = Assert.IsType <NotFoundObjectResult>(result);
            var returnValue          = Assert.IsType <long>(notFoundObjectResult.Value);

            Assert.Equal(notValidId, returnValue);
        }
        public async void GetVideo_CalledWithValidId_ReturnsOkWithVideo()
        {
            IUnitOfWork    unitOfWork    = Substitute.For <IUnitOfWork>();
            IVideoManager  videoManager  = Substitute.For <IVideoManager>();
            ICookieManager cookieManager = Substitute.For <ICookieManager>();

            long testId = 1;
            var  video  = new Video()
            {
                Id = testId
            };

            unitOfWork.Videos.GetById(testId).Returns(video);

            var videosController = new VideosController(unitOfWork, videoManager, cookieManager);

            var result = await videosController.GetVideo(testId);

            var okObjectResult = Assert.IsType <OkObjectResult>(result);
            var returnValue    = Assert.IsType <Video>(okObjectResult.Value);

            Assert.Equal(testId, returnValue.Id);
        }