public async void AddVideo_CalledAndRoleIsNotAdmin_ReturnsBadRequestWithError()
        {
            IUnitOfWork    unitOfWork    = Substitute.For <IUnitOfWork>();
            IVideoManager  videoManager  = Substitute.For <IVideoManager>();
            ICookieManager cookieManager = Substitute.For <ICookieManager>();
            var            context       = Substitute.For <HttpContext>();

            long          testId            = 1;
            var           testVideo         = new VideoViewModel();
            ModuleContent nullModuleContent = null;
            string        testUrl           = "testurl";
            string        convertedUrl      = "converted";
            string        testyoutubeId     = "youtubeid";
            string        error             = "Only Admins can add videos.";

            unitOfWork.ModuleContents.GetById(testId).Returns(nullModuleContent);
            videoManager.ConvertUrl(testUrl).Returns(convertedUrl);
            videoManager.GetYoutubeId(convertedUrl).Returns(testyoutubeId);
            cookieManager.GetRoleFromToken(Arg.Any <string>()).Returns(Role.Student.ToString());

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

            videosController.ControllerContext = new ControllerContext()
            {
                HttpContext = context
            };

            var result = await videosController.AddVideo(testVideo);

            var badRequestObjectResult = Assert.IsType <BadRequestObjectResult>(result);
            var returnValue            = Assert.IsType <string>(badRequestObjectResult.Value);

            Assert.Equal(error, returnValue);
        }
        public async void AddVideo_CalledWithValidVideo_ReturnsOk()
        {
            IUnitOfWork    unitOfWork    = Substitute.For <IUnitOfWork>();
            IVideoManager  videoManager  = Substitute.For <IVideoManager>();
            ICookieManager cookieManager = Substitute.For <ICookieManager>();
            var            context       = Substitute.For <HttpContext>();

            long testId    = 1;
            var  testVideo = new VideoViewModel()
            {
                ModuleContentId = testId
            };
            var    testModuleContent = new ModuleContent();
            string testUrl           = "testurl";
            string convertedUrl      = "converted";
            string testyoutubeId     = "youtubeid";

            unitOfWork.ModuleContents.GetById(testId).Returns(testModuleContent);
            videoManager.ConvertUrl(testUrl).Returns(convertedUrl);
            videoManager.GetYoutubeId(convertedUrl).Returns(testyoutubeId);
            cookieManager.GetRoleFromToken(Arg.Any <string>()).Returns(Role.Admin.ToString());

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

            videosController.ControllerContext = new ControllerContext()
            {
                HttpContext = context
            };

            var result = await videosController.AddVideo(testVideo);

            var okResult = Assert.IsType <OkResult>(result);

            Assert.Equal(200, okResult.StatusCode);
        }
        public async void AddVideo_CalledWithInvalidContentId_RetrunsNotFoundWithId()
        {
            IUnitOfWork    unitOfWork    = Substitute.For <IUnitOfWork>();
            IVideoManager  videoManager  = Substitute.For <IVideoManager>();
            ICookieManager cookieManager = Substitute.For <ICookieManager>();
            var            context       = Substitute.For <HttpContext>();

            long testId    = 1;
            var  testVideo = new VideoViewModel()
            {
                ModuleContentId = testId
            };
            ModuleContent nullModuleContent = null;
            string        testUrl           = "testurl";
            string        convertedUrl      = "converted";
            string        testyoutubeId     = "youtubeid";

            unitOfWork.ModuleContents.GetById(testId).Returns(nullModuleContent);
            videoManager.ConvertUrl(testUrl).Returns(convertedUrl);
            videoManager.GetYoutubeId(convertedUrl).Returns(testyoutubeId);
            cookieManager.GetRoleFromToken(Arg.Any <string>()).Returns(Role.Admin.ToString());

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

            videosController.ControllerContext = new ControllerContext()
            {
                HttpContext = context
            };

            var result = await videosController.AddVideo(testVideo);

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

            Assert.Equal(testId, retrunValue);
        }