public void SendTweet_ShouldUpdateTheUserStatus_AndReturnNewTweeterStatusTest()
        {
            OAuthAccessToken accessToken = new OAuthAccessToken {
                Token = "abcd", TokenSecret = "A@c#"
            };

            Mock.Get(_mockTwitterService).Setup(mockService => mockService.AuthenticateWith(accessToken.Token, accessToken.TokenSecret));

            SendTweetRequest request = new SendTweetRequest {
                AccessToken = accessToken, Status = "Hello World"
            };

            TwitterStatus twitterStatusStatus =
                Builder <TwitterStatus>
                .CreateNew()
                .With(x => x.Text = request.Status)
                .With(x => x.User = Builder <TwitterUser> .CreateNew().Build())
                .Build();

            Mock.Get(_mockTwitterService).Setup(mockService => mockService.SendTweet(request.Status)).Returns(twitterStatusStatus);

            SendTweetResponse sendTweetResponse = _authenticationService.SendTweet(request);

            Assert.IsNotNull(sendTweetResponse);
            Assert.AreSame(request.Status, sendTweetResponse.TweeterStatus.Tweet);
        }
Beispiel #2
0
        public SendTweetResponse SendTweet(SendTweetRequest request)
        {
            _twitterService.AuthenticateWith(request.AccessToken.Token, request.AccessToken.TokenSecret);

            TwitterStatus twitterStatus = _twitterService.SendTweet(request.Status);

            TweeterStatusAdapter tweeterStatusAdapter = new TweeterStatusAdapter();

            SendTweetResponse response = new SendTweetResponse {
                TweeterStatus = tweeterStatusAdapter.Convert(twitterStatus)
            };

            return(response);
        }
        internal void SendTweetCallback(IAsyncResult ar)
        {
            DispatcherHelper.CheckBeginInvokeOnUI(
                () =>
            {
                IsBusy = false;

                SendTweetResponse sendTweetResponse = _authenticationService.EndSendTweet(ar);

                TweetText = string.Empty;

                Messenger.Default.Send(sendTweetResponse.TweeterStatus, "SendTweetSuccess");
            });
        }
        public void TweetActionViewModel_SendTweetCallBack_ShouldReturnNewTweetTest()
        {
            viewModel.IsBusy = true;

            viewModel.TweetText = "Hello World";

            viewModel.CanPerformTweetAction = true;

            SendTweetResponse sendTweetResponse = new SendTweetResponse();

            Mock.Get(_mockAuthenticationService)
            .Setup(m => m.EndSendTweet(null))
            .Returns(sendTweetResponse);

            viewModel.SendTweetCallback(null);

            Assert.IsFalse(viewModel.IsBusy);

            Assert.AreEqual(0, viewModel.TweetText.Length);

            Assert.IsFalse(viewModel.CanPerformTweetAction);

            Mock.Get(_mockAuthenticationService).VerifyAll();
        }
        public void TweetActionViewModel_SendTweetCallBack_ShouldReturnNewTweetTest()
        {
            viewModel.IsBusy = true;

            viewModel.TweetText = "Hello World";

            viewModel.CanPerformTweetAction = true;

            SendTweetResponse sendTweetResponse = new SendTweetResponse();

            Mock.Get(_mockAuthenticationService)
                .Setup(m => m.EndSendTweet(null))
                .Returns(sendTweetResponse);

            viewModel.SendTweetCallback(null);

            Assert.IsFalse(viewModel.IsBusy);

            Assert.AreEqual(0, viewModel.TweetText.Length);

            Assert.IsFalse(viewModel.CanPerformTweetAction);

            Mock.Get(_mockAuthenticationService).VerifyAll();
        }