示例#1
0
        public void EncodeSuccessfulTest()
        {
            //Arragnge
            var videoMssg = new VideoMessage();
            var videoList = new List<VideoData>();
            var screenshotList = new List<ScreenshotData>();

            var encodeProcess = new EncodeProcess(5, _encoder.Object, _videoRepository.Object, _mediaInfoReader.Object, _queueVideoRepository.Object, _fileSystem.Object);

            _encoder.Setup(m => m.EncodeVideo(It.IsAny<VideoMediaInfo>(), It.IsAny<string>(), It.IsAny<string>())).Returns(videoList);
            _encoder.Setup(m => m.EncodeScreenshot(It.IsAny<VideoMediaInfo>(), It.IsAny<string>(), It.IsAny<string>())).Returns(screenshotList);

            var downloadInfo = new DownloadInformation()
                                   {
                                       LocalPath = "local path",
                                       LocalFilePath = "local file path",
                                       QueueInformation = new QueueInformation()
                                                              {
                                                                  VideoMessage = videoMssg
                                                              }
                                   };

            //Act
            var encodeInfo = encodeProcess.ProcessMethod(downloadInfo, new CancellationToken());

            //Assert
            Assert.AreEqual(downloadInfo.QueueInformation.VideoMessage, videoMssg);
            Assert.AreEqual(downloadInfo.LocalFilePath, encodeInfo.DownloadInformation.LocalFilePath);
            Assert.AreEqual(downloadInfo.LocalPath, encodeInfo.DownloadInformation.LocalPath);
            Assert.AreEqual(videoList, encodeInfo.EncodeVideoList);
            Assert.AreEqual(screenshotList, encodeInfo.EncodeScreenshotList);
        }
        public void EncodeNotExistVideoTest()
        {
            //Arragnge
            var videoMssg = new VideoMessage();

            var encodeProcess = new EncodeProcess(5, _encoder.Object, _videoRepository.Object, _mediaInfoReader.Object, _queueVideoRepository.Object, _fileSystem.Object);

            _videoRepository.Setup(m => m.ExistsEncodedVideo(It.IsAny <string>())).Returns(false);

            var downloadInfo = new DownloadInformation()
            {
                LocalPath        = "local path",
                LocalFilePath    = "local file path",
                QueueInformation = new QueueInformation()
                {
                    VideoMessage = videoMssg
                }
            };

            //Act
            encodeProcess.ProcessMethod(downloadInfo, new CancellationToken());

            //Assert
            _videoRepository.Verify(m => m.SetEncodingState(It.IsAny <string>(), EncodingState.InProcess, EncodingStage.Encoding, null), Times.Once());
            _videoRepository.Verify(m => m.ExistsEncodedVideo(It.IsAny <string>()), Times.Once());
            _mediaInfoReader.Verify(m => m.GetInformation(It.IsAny <string>()), Times.Once());
            _videoRepository.Verify(m => m.FillMediaInfoTables(It.IsAny <Dictionary <Enum, object> >(), It.IsAny <string>()), Times.Once());
            _videoRepository.Verify(m => m.GetVideoMediaInfo(It.IsAny <Dictionary <Enum, object> >()), Times.Once());
            _encoder.Verify(m => m.EncodeVideo(It.IsAny <VideoMediaInfo>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once());
            _encoder.Verify(m => m.EncodeScreenshot(It.IsAny <VideoMediaInfo>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once());
        }
        public void EncodeSuccessfulTest()
        {
            //Arragnge
            var videoMssg      = new VideoMessage();
            var videoList      = new List <VideoData>();
            var screenshotList = new List <ScreenshotData>();

            var encodeProcess = new EncodeProcess(5, _encoder.Object, _videoRepository.Object, _mediaInfoReader.Object, _queueVideoRepository.Object, _fileSystem.Object);

            _encoder.Setup(m => m.EncodeVideo(It.IsAny <VideoMediaInfo>(), It.IsAny <string>(), It.IsAny <string>())).Returns(videoList);
            _encoder.Setup(m => m.EncodeScreenshot(It.IsAny <VideoMediaInfo>(), It.IsAny <string>(), It.IsAny <string>())).Returns(screenshotList);

            var downloadInfo = new DownloadInformation()
            {
                LocalPath        = "local path",
                LocalFilePath    = "local file path",
                QueueInformation = new QueueInformation()
                {
                    VideoMessage = videoMssg
                }
            };

            //Act
            var encodeInfo = encodeProcess.ProcessMethod(downloadInfo, new CancellationToken());

            //Assert
            Assert.AreEqual(downloadInfo.QueueInformation.VideoMessage, videoMssg);
            Assert.AreEqual(downloadInfo.LocalFilePath, encodeInfo.DownloadInformation.LocalFilePath);
            Assert.AreEqual(downloadInfo.LocalPath, encodeInfo.DownloadInformation.LocalPath);
            Assert.AreEqual(videoList, encodeInfo.EncodeVideoList);
            Assert.AreEqual(screenshotList, encodeInfo.EncodeScreenshotList);
        }
        public void BrunchOfDeleteTest()
        {
            //Arragnge
            var videoMsg = new VideoMessage()
            {
                Delete = true
            };

            var encodeProcess = new EncodeProcess(5, _encoder.Object, _videoRepository.Object, _mediaInfoReader.Object, _queueVideoRepository.Object, _fileSystem.Object);
            var downloadInfo  = new DownloadInformation()
            {
                QueueInformation = new QueueInformation()
                {
                    VideoMessage = videoMsg
                }
            };
            //Act
            var encodeInfo = encodeProcess.ProcessMethod(downloadInfo, new CancellationToken());

            //Assert
            Assert.AreEqual(downloadInfo, encodeInfo.DownloadInformation);

            _videoRepository.Verify(m => m.SetEncodingState(It.IsAny <string>(), EncodingState.InProcess, EncodingStage.Encoding, null), Times.Never());
            _mediaInfoReader.Verify(m => m.GetInformation(It.IsAny <string>()), Times.Never());
            _videoRepository.Verify(m => m.FillMediaInfoTables(It.IsAny <Dictionary <Enum, object> >(), It.IsAny <string>()), Times.Never());
            _videoRepository.Verify(m => m.GetVideoMediaInfo(It.IsAny <Dictionary <Enum, object> >()), Times.Never());
            _encoder.Verify(m => m.EncodeVideo(It.IsAny <VideoMediaInfo>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never());
            _encoder.Verify(m => m.EncodeScreenshot(It.IsAny <VideoMediaInfo>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never());
        }
示例#5
0
        public void EncodeNotExistVideoTest()
        {
            //Arragnge
            var videoMssg = new VideoMessage();

            var encodeProcess = new EncodeProcess(5, _encoder.Object, _videoRepository.Object, _mediaInfoReader.Object, _queueVideoRepository.Object, _fileSystem.Object);

            _videoRepository.Setup(m => m.ExistsEncodedVideo(It.IsAny<string>())).Returns(false);

            var downloadInfo = new DownloadInformation()
                                   {
                                       LocalPath = "local path",
                                       LocalFilePath = "local file path",
                                       QueueInformation = new QueueInformation()
                                                              {
                                                                  VideoMessage = videoMssg
                                                              }
                                   };

            //Act
            encodeProcess.ProcessMethod(downloadInfo, new CancellationToken());

            //Assert
            _videoRepository.Verify(m => m.SetEncodingState(It.IsAny<string>(), EncodingState.InProcess, EncodingStage.Encoding, null), Times.Once());
            _videoRepository.Verify(m => m.ExistsEncodedVideo(It.IsAny<string>()), Times.Once());
            _mediaInfoReader.Verify(m => m.GetInformation(It.IsAny<string>()), Times.Once());
            _videoRepository.Verify(m => m.FillMediaInfoTables(It.IsAny<Dictionary<Enum, object>>(), It.IsAny<string>()), Times.Once());
            _videoRepository.Verify(m => m.GetVideoMediaInfo(It.IsAny<Dictionary<Enum, object>>()), Times.Once());
            _encoder.Verify(m => m.EncodeVideo(It.IsAny<VideoMediaInfo>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once());
            _encoder.Verify(m => m.EncodeScreenshot(It.IsAny<VideoMediaInfo>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once());
        }
示例#6
0
        public void BrunchOfDeleteTest()
        {
            //Arragnge
            var videoMsg = new VideoMessage() {Delete = true};

            var encodeProcess = new EncodeProcess(5, _encoder.Object, _videoRepository.Object, _mediaInfoReader.Object, _queueVideoRepository.Object, _fileSystem.Object);
            var downloadInfo = new DownloadInformation()
                                   {
                                       QueueInformation = new QueueInformation()
                                                              {
                                                                  VideoMessage = videoMsg
                                                              }
                                   };
            //Act
            var encodeInfo = encodeProcess.ProcessMethod(downloadInfo, new CancellationToken());

            //Assert
            Assert.AreEqual(downloadInfo, encodeInfo.DownloadInformation);

            _videoRepository.Verify(m => m.SetEncodingState(It.IsAny<string>(), EncodingState.InProcess, EncodingStage.Encoding, null), Times.Never());
            _mediaInfoReader.Verify(m => m.GetInformation(It.IsAny<string>()), Times.Never());
            _videoRepository.Verify(m => m.FillMediaInfoTables(It.IsAny<Dictionary<Enum, object>>(), It.IsAny<string>()), Times.Never());
            _videoRepository.Verify(m => m.GetVideoMediaInfo(It.IsAny<Dictionary<Enum, object>>()), Times.Never());
            _encoder.Verify(m => m.EncodeVideo(It.IsAny<VideoMediaInfo>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never());
            _encoder.Verify(m => m.EncodeScreenshot(It.IsAny<VideoMediaInfo>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never());

        }