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 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());
        }
示例#4
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());
        }
示例#5
0
        private void HandleNonObsStream(AbstractRtmpMediaMessage msg)
        {
            if (msg is VideoMessage)
            {
                VideoMessage vm = (VideoMessage)msg;
                if (vm.Timestamp != null)
                {
                    vm.TimestampDelta = (vm.Timestamp - _videoTimestamp);
                    _videoTimestamp   = vm.Timestamp.Value;
                }
                else if (vm.TimestampDelta != null)
                {
                    _videoTimestamp += vm.TimestampDelta.Value;
                    vm.Timestamp     = _videoTimestamp;
                }
            }

            if (msg is AudioMessage)
            {
                AudioMessage am = (AudioMessage)msg;
                if (am.Timestamp != null)
                {
                    am.TimestampDelta = (am.Timestamp - _audioTimestamp);
                    _audioTimestamp   = am.Timestamp.Value;
                }
                else if (am.TimestampDelta != null)
                {
                    _audioTimestamp += am.TimestampDelta.Value;
                    am.Timestamp     = _audioTimestamp;
                }
            }
        }
示例#6
0
        /// <summary>
        /// Upload the received data to blob and returns the address
        /// </summary>
        private async Task HandleMediaAsync(EventMessageType type, string replyToken, string messageId, string blobDirectoryName, string blobName)
        {
            var stream = await messagingClient.GetContentStreamAsync(messageId);

            var ext = GetFileExtension(stream.ContentHeaders.ContentType.MediaType);
            var uri = await blobStorage.UploadFromStreamAsync(stream, blobDirectoryName, blobName + ext);

            ISendMessage reply = null;

            switch (type)
            {
            case EventMessageType.Audio:
                reply = new AudioMessage(uri.ToString(), 100);
                break;

            case EventMessageType.Image:
                reply = new ImageMessage(uri.ToString(), uri.ToString());
                break;

            case EventMessageType.Video:
                reply = new VideoMessage(uri.ToString(), "https://linetestbot123.blob.core.windows.net/linebotcontainer/User_U21d2cd1795be4caa1a32d069fe7b323f/7015056697532.jpeg");
                break;

            case EventMessageType.File:
                reply = new TextMessage(uri.ToString());
                break;
            }
            await messagingClient.ReplyMessageAsync(replyToken, new List <ISendMessage> {
                reply
            });

            //await messagingClient.ReplyMessageAsync(replyToken, uri.ToString());
        }
            public void ShouldSetTheProperties()
            {
                var message = new VideoMessage(new Uri("https://foo.url"), new Uri("https://foo.previewUrl"));

                Assert.AreEqual("https://foo.url/", message.Url.ToString());
                Assert.AreEqual("https://foo.previewurl/", message.PreviewUrl.ToString());
            }
            public void ShouldConvertStringUrl()
            {
                var message = new VideoMessage("https://foo.url", "https://foo.previewUrl");

                Assert.AreEqual("https://foo.url/", message.Url.ToString());
                Assert.AreEqual("https://foo.previewurl/", message.PreviewUrl.ToString());
            }
示例#9
0
 public virtual Task <Message> SendVideoAsync(VideoMessage message,
                                              CancellationToken cancellationToken = default)
 {
     return(Client.SendVideoAsync(message.ChatId, message.InputOnlineFile, message.Duration, message.Width,
                                  message.Height, message.Caption, message.ParseMode, message.SupportsStreaming,
                                  message.DisableNotification, message.ReplyToMessageId, message.ReplyMarkup, cancellationToken));
 }
示例#10
0
 /// <summary>
 /// Create new unified video message from viber video message
 /// </summary>
 /// <param name="message">Viber video message</param>
 /// <returns>Unified message</returns>
 private InMessage CreateVideoMessage(VideoMessage message)
 {
     return(new InMessage
     {
         Video = message.Media
     });
 }
示例#11
0
        public Response SendVideo(VideoMessage message)
        {
            string url = baseUrl + "sendVideo";

            MultipartFormDataContent multiContent = new MultipartFormDataContent
            {
                { new StringContent(message.ChatId.ToString()), "chat_id" },
                { new StringContent(message.Caption), "caption" },
            };

            if (message.ReplyToMessageId != null)
            {
                multiContent.Add(new StringContent("reply_to_message_id"), message.ReplyToMessageId?.ToString());
            }

            ByteArrayContent videoContent = new ByteArrayContent(message.Video);

            videoContent.Headers.ContentType = new MediaTypeHeaderValue("video/mp4");

            multiContent.Add(videoContent, "video");


            HttpResponseMessage response = client.PostAsync(url, multiContent).Result;

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                Response result = Utils.Deserialize <Response>(response.Content.ReadAsStringAsync().Result);
                return(result);
            }


            return(new Response());
        }
示例#12
0
        public async Task <HttpResponseMessage> SendVideoMessage(VideoMessage videoMessage)
        {
            ResponseBase <IList <MMPro.MM.UploadVideoResponse> > response = new ResponseBase <IList <MMPro.MM.UploadVideoResponse> >();

            try
            {
                IList <MMPro.MM.UploadVideoResponse> list = new List <MMPro.MM.UploadVideoResponse>();
                byte[] buffer = await FileStorageHelper.DownloadToBufferAsync(videoMessage.ObjectName);

                byte[] imageBuffer = await FileStorageHelper.DownloadToBufferAsync(videoMessage.ImageObjectName);

                foreach (var item in videoMessage.ToWxIds)
                {
                    var result = wechat.SendVideoMessage(videoMessage.WxId, item, videoMessage.PlayLength, buffer, imageBuffer);
                    list.Add(result);
                }
                response.Data = list;
            }
            catch (ExpiredException ex)
            {
                response.Success = false;
                response.Code    = "401";
                response.Message = ex.Message;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Code    = "500";
                response.Message = ex.Message;
            }
            return(await response.ToHttpResponseAsync());
        }
示例#13
0
        public void FinishNotExistVideoTest()
        {
            //Arrange
            var videoMsg = new VideoMessage();
            var finishProcess = new FinishProcess(_queueVideoRepository.Object, _videoRepository.Object, _fileSystem.Object);

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

            var uploadInfo = new UploadInformation()
            {
                DownloadInformation = new DownloadInformation()
                {
                    QueueInformation = new QueueInformation()
                    {
                        VideoMessage = videoMsg
                    }
                }
            };

            //Act
            finishProcess.ProcessMethod(uploadInfo, new CancellationToken());

            //Assert
            _videoRepository.Verify(m => m.SetEncodingState(It.IsAny<string>(),EncodingState.InProcess, EncodingStage.CleanUp, null), Times.Once());
            _videoRepository.Verify(m=>m.ExistsEncodedVideo(It.IsAny<string>()), Times.Once());
            _fileSystem.Verify(m => m.DirectoryDelete(It.IsAny<string>()), Times.Once());
            _queueVideoRepository.Verify(m => m.DeleteMessage(videoMsg));
            _videoRepository.Verify(m => m.SetEncodingState(It.IsAny<string>(), EncodingState.Successed, EncodingStage.CleanUp, null), Times.Once());
        }
示例#14
0
        public void FinishExistVideoTest()
        {
            //Arrange
            var videoMsg      = new VideoMessage();
            var finishProcess = new FinishProcess(_queueVideoRepository.Object, _videoRepository.Object, _fileSystem.Object);

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

            var uploadInfo = new UploadInformation()
            {
                DownloadInformation = new DownloadInformation()
                {
                    QueueInformation = new QueueInformation()
                    {
                        VideoMessage = videoMsg
                    }
                }
            };

            //Act
            finishProcess.ProcessMethod(uploadInfo, new CancellationToken());

            //Assert
            _videoRepository.Verify(m => m.SetEncodingState(It.IsAny <string>(), EncodingState.InProcess, EncodingStage.CleanUp, null), Times.Once());
            _videoRepository.Verify(m => m.ExistsEncodedVideo(It.IsAny <string>()), Times.Once());
            _fileSystem.Verify(m => m.DirectoryDelete(It.IsAny <string>()), Times.Never());
            _queueVideoRepository.Verify(m => m.DeleteMessage(videoMsg));
            _videoRepository.Verify(m => m.SetEncodingState(It.IsAny <string>(), EncodingState.Successed, EncodingStage.CleanUp, null), Times.Once());
        }
        /// <summary>
        /// Keep the message in abandon queue until a new subscriber becomes available
        /// </summary>
        private static void PutMessageIntoQueue(VideoMessage message)
        {
            var formatter = new BinaryMessageFormatter();

            using (var queue = new MessageQueue(Program.AbandonMessagesQueuePath))
            {
                queue.Formatter = formatter;

                // transactional queue
                using (var transaction = new MessageQueueTransaction())
                {
                    transaction.Begin();

                    if (message is DeliveryRequestMessage)
                    {
                        using (var msg = new Message(message, formatter)
                        {
                            ResponseQueue = queue,
                            Priority = MessagePriority.Normal,
                            Label = message.TopicName + "/" + (message as DeliveryRequestMessage).RegionName,
                            Recoverable = true,
                        })
                        {
                            queue.Send(msg, transaction);
                        }
                        ConsoleHelper.WriteLine(ConsoleColor.Cyan, "Request stored in queue until proper service becomes available");
                    }
                    transaction.Commit();
                } // using (transaction)
            }     // using (queue)
        }
示例#16
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);
        }
示例#17
0
 private void HandleVideoMessage(VideoMessage videoData)
 {
     if (AVCConfigureRecord == null && videoData.Data.Length >= 2)
     {
         AVCConfigureRecord = videoData;
     }
     OnVideoMessage?.Invoke(videoData);
 }
        public void Constructor_SerializedCorrectly()
        {
            VideoMessage message = new VideoMessage("https://foo.url", "https://foo.previewUrl");

            string serialized = JsonConvert.SerializeObject(message);

            Assert.AreEqual(@"{""type"":""video"",""originalContentUrl"":""https://foo.url"",""previewImageUrl"":""https://foo.previewUrl""}", serialized);
        }
示例#19
0
        private void ShowVideoEventHandler(object sender, VideoMessage videoMessage)
        {
            var hightlightsTool = new LiveVideoToolItemViewModel {
                DefaultDock = Dock.Bottom, IsInitiallyHidden = true, DockGroup = "Group1"
            };

            ToolItems.Add(hightlightsTool);
        }
示例#20
0
            public void ShouldThrowExceptionWhenValueIsNull()
            {
                var message = new VideoMessage();

                ExceptionAssert.Throws <InvalidOperationException>("The url cannot be null.", () =>
                {
                    message.PreviewUrl = null;
                });
            }
        public void Url_MoreThan1000Chars_ThrowsException()
        {
            VideoMessage message = new VideoMessage();

            ExceptionAssert.Throws <InvalidOperationException>("The url cannot be longer than 1000 characters.", () =>
            {
                message.Url = new Uri("https://foo.bar/" + new string('x', 985));
            });
        }
        public void PreviewUrl_Null_ThrowsException()
        {
            VideoMessage message = new VideoMessage();

            ExceptionAssert.Throws <InvalidOperationException>("The url cannot be null.", () =>
            {
                message.PreviewUrl = null;
            });
        }
示例#23
0
            public void ShouldThrowExceptionWhenValueIsNotHttps()
            {
                var message = new VideoMessage();

                ExceptionAssert.Throws <InvalidOperationException>("The url should use the https scheme.", () =>
                {
                    message.PreviewUrl = new Uri("http://foo.bar");
                });
            }
示例#24
0
            public void ShouldThrowExceptionWhenValueIsMoreThan1000Chars()
            {
                var message = new VideoMessage();

                ExceptionAssert.Throws <InvalidOperationException>("The url cannot be longer than 1000 characters.", () =>
                {
                    message.PreviewUrl = new Uri("https://foo.bar/" + new string('x', 985));
                });
            }
示例#25
0
 public void SendMessage(ref VideoMessage m)
 {
     //	currentFrame=m;
     ((IMessageReceiver)this._dispatcher.TransparentProxy).ReceiveVideoMessage(m);
     //	foreach( IMessageReceiver iMessageReceiver in clientList)
     //	{
     //		iMessageReceiver.ReceiveVideoMessage(m);
     //	}
 }
        public void PreviewUrl_NotHttps_ThrowsException()
        {
            VideoMessage message = new VideoMessage();

            ExceptionAssert.Throws <InvalidOperationException>("The url should use the https scheme.", () =>
            {
                message.PreviewUrl = new Uri("http://foo.bar");
            });
        }
示例#27
0
文件: Video.cs 项目: zaeem/FlexCollab
 public void SendMessage(ref VideoMessage m)
 {
     //	currentFrame=m;
     ((IMessageReceiver) this._dispatcher.TransparentProxy).ReceiveVideoMessage(m);
     //	foreach( IMessageReceiver iMessageReceiver in clientList)
     //	{
     //		iMessageReceiver.ReceiveVideoMessage(m);
     //	}
 }
            public void ShouldConvertCustomIAudioMessageToAudioMessage()
            {
                var message = new TestVideoMessage();

                var videoMessage = VideoMessage.Convert(message);

                Assert.AreNotEqual(message, videoMessage);
                Assert.AreEqual(new Uri("https://foo.url"), videoMessage.Url);
                Assert.AreEqual(new Uri("https://foo.previewUrl"), videoMessage.PreviewUrl);
            }
示例#29
0
        private void ShowVideoEventHandler(object sender, VideoMessage e)
        {
            var reviewVideoTool = new ReviewVideoToolItemViewModel
            {
                Name        = "ReviewVideo",
                DefaultDock = Dock.Right,
            };

            ToolItems.Add(reviewVideoTool);
        }
示例#30
0
            public void ShouldNotThrowExceptionWhenValid()
            {
                ISendMessage message = new VideoMessage()
                {
                    PreviewUrl = new Uri("https://foo.previewUrl"),
                    Url        = new Uri("https://foo.url")
                };

                message.Validate();
            }
示例#31
0
        static void Main(string[] args)
        {
            InstantMessage plainTextMessage = new PlainTextMessage();
            InstantMessage videoMessage     = new VideoMessage();

            plainTextMessage.ProcessMessage();
            videoMessage.ProcessMessage();

            Console.ReadLine();
        }
示例#32
0
        public FlvVideoData DemultiplexVideoData(VideoMessage message)
        {
            var ret  = new FlvVideoData();
            var head = message.Data.Span[0];

            ret.FrameType = (FrameType)(head >> 4);
            ret.CodecId   = (CodecId)(head & 0x0F);
            ret.VideoData = message.Data.Slice(1);
            return(ret);
        }
        public void Url_1000Chars_ThrowsNoException()
        {
            Uri value = new Uri("https://foo.bar/" + new string('x', 984));

            VideoMessage message = new VideoMessage()
            {
                Url = value
            };

            Assert.AreEqual(value, message.Url);
        }
示例#34
0
            public void ShouldNotThrowExceptionWhenUrlIs1000Chars()
            {
                var value = new Uri("https://foo.bar/" + new string('x', 984));

                var message = new VideoMessage()
                {
                    PreviewUrl = value
                };

                Assert.AreEqual(value, message.PreviewUrl);
            }
示例#35
0
        public void QueuedSuccessfulTest()
        {
            //Arrange
            var queueMsg = new VideoMessage();
            var queueVideoRepository = new Mock<IQueueVideoRepository>();
            var queueProcess = new QueueProcess(1000, queueVideoRepository.Object);

            queueVideoRepository.Setup(m => m.GetMessage()).Returns(queueMsg);

            //Act
            var queueInfo = queueProcess.ProcessMethod(null, new CancellationToken());

            //Asert
            queueVideoRepository.Verify(m => m.GetMessage(), Times.Once());

            Assert.AreEqual(1, queueProcess.BlockingCollection.Count);
            Assert.AreEqual(queueMsg, queueInfo.VideoMessage);
        }
示例#36
0
        public void FinishSuccessfulTest()
        {
            //Arrange
            var videoMssg = new VideoMessage();
            var finishProcess = new FinishProcess(_queueVideoRepository.Object, _videoRepository.Object, _fileSystem.Object);

            var uploadInfo = new UploadInformation()
                                 {
                                     DownloadInformation = new DownloadInformation()
                                                               {
                                                                   QueueInformation = new QueueInformation()
                                                                                          {
                                                                                              VideoMessage = new VideoMessage()
                                                                                          }
                                                               }
                                 };

            //Act
            var obj = finishProcess.ProcessMethod(uploadInfo, new CancellationToken());

            //Assert
            Assert.AreEqual(null, obj);
        }
        private void StartQueueWork()
        {
            var cloudStorageConfiguration = new CloudStorageConfiguration(CloudStorageAccount.DevelopmentStorageAccount, new Version());
            var queueVideoRepository = new QueueVideoRepository(cloudStorageConfiguration.StorageAccount.CreateCloudQueueClient());

            string[] filePathes = Directory.GetFiles(_blobSource);

            foreach (string filePath in filePathes)
            {
                var message = new VideoMessage
                    {
                        VideoFileHash = filePath
                    };

                queueVideoRepository.AddMessage(message);
            }
        }
示例#38
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());

        }
示例#39
0
        public void EncodeExceptionHandlerTest()
        {
            //Arrange
            const string localPath = "local path";
            var videoMsg = new VideoMessage();
            var encodeProcess = new EncodeProcess(5, _encoder.Object, _videoRepository.Object, _mediaInfoReader.Object, _queueVideoRepository.Object, _fileSystem.Object);

             var downloadInfo = new DownloadInformation()
                                   {
                                       LocalPath=localPath,
                                       QueueInformation = new QueueInformation()
                                                              {
                                                                  VideoMessage = videoMsg
                                                              }
                                   };

            //Act
            encodeProcess.ExceptionHandler(new Exception(), downloadInfo);

            //Asert
            _videoRepository.Verify(m=>m.SetEncodingState(It.IsAny<string>(),EncodingState.Failed, EncodingStage.Encoding, null), Times.Once());
            _fileSystem.Verify(m=>m.DirectoryDelete(localPath), Times.Once());
            _queueVideoRepository.Verify(m=>m.DeleteMessage(videoMsg), Times.Once());
        }