public async Task GivenRedditMessageHandler_WhenOnUnreadMessagesUpdatedIsCalledWithOnePrivateMessage_ThenMessageWasHandled()
        {
            // Arrange
            var messagesUpdateEventArgs = GetMessagesUpdateEventArgsWithOneNonUsernameMentionMessage();

            // Act
            await _redditMessageHandler.OnUnreadMessagesUpdated(new object(), messagesUpdateEventArgs);

            // Assert
            A.CallTo(() => _fakeRedditClientWrapper.ReadMessage(PrivateMessageFullname)).MustHaveHappenedOnceExactly();
            A.CallTo(() => _fakeMediaProcessor.DownloadAndRotateAndUploadVideo(A <MediaProcessorParameters> ._)).MustNotHaveHappened();
        }
Пример #2
0
        private async Task RotateAndUploadVideo(Message message)
        {
            Console.WriteLine($"Processing message: {message.Fullname}...");
            var rotationArgument = GetRotationArgument(message);

            var post = GetCommentRootPost(message);

            ThrowExceptionIfPostIsNsfw(post);

            string videoUrl = GetVideoUrlFromPost(post);
            string audioUrl = GetAudioUrlFromPost(post);

            var uploadedVideoUrl = await _mediaProcessor.DownloadAndRotateAndUploadVideo(
                new MediaProcessorParameters
            {
                RotationArgument = rotationArgument,
                VideoUrl         = videoUrl,
                AudioUrl         = audioUrl
            });

            ReplyToComment(message, _replyBuilder.BuildReply(new RedditReplyBuilderParameters
            {
                UploadedVideoUrl   = uploadedVideoUrl,
                RotationMessageArg = rotationArgument
            }));
        }
Пример #3
0
        public async Task GivenValidMediaProcessorParameters_WhenAllOperationsSucceed_ThenUrlOfUploadedVideoIsReturned()
        {
            // Arrange
            A.CallTo(() => _fakeGfyCatVideoUploader.UploadAsync()).Returns(UploadUrl);

            // Act
            var uploadUrl = await _mediaProcessor.DownloadAndRotateAndUploadVideo(GetValidMediaProcessorParameters());

            // Assert
            A.CallTo(() => _fakeAudioDownloader.DownloadFromUrl(AudioUrlString)).MustHaveHappenedOnceExactly();
            A.CallTo(() => _fakeVideoDownloader.DownloadFromUrl(VideoUrlString)).MustHaveHappenedOnceExactly();
            A.CallTo(() => _fakeMediaMuxer.CombineVideoAndAudio()).MustHaveHappenedOnceExactly();
            A.CallTo(() => _fakeVideoRotator.Rotate(RotationArgumentString)).MustHaveHappenedOnceExactly();
            A.CallTo(() => _fakeGfyCatVideoUploader.UploadAsync()).MustHaveHappenedOnceExactly();
            Assert.Equal(UploadUrl, uploadUrl);
        }