Exemplo n.º 1
0
        public void BeginGetTweet_WhichFindsATweet_ReturnsSuccessfulTweet()
        {
            var wasCalled = false;
            var twitterClient = Substitute.For<IBaseTwitterClient>();
            twitterClient.SetResponse(File.ReadAllText(@".\Data\statuses\show-existing.txt"));
            var statuses = new Statuses(twitterClient);

            // assert
            GenericResponseDelegate endGetTweet = (a, b, c) =>
                                                      {
                                                          wasCalled = true;
                                                          var tweet = c as Tweet;
                                                          Assert.That(tweet, Is.Not.Null);
                                                          Assert.That(tweet.Id, Is.EqualTo(16381619317248000));
                                                      };

            // act
            statuses.BeginGetTweet("16381619317248000", endGetTweet);

            Assert.That(wasCalled, Errors.CallbackDidNotFire);
        }
Exemplo n.º 2
0
        public void BeginGetTweet_WhichDoesNotFindATweet_ReturnsExceptionResponse()
        {
            // arrange
            var wasCalled = false;
            var twitterClient = Substitute.For<IBaseTwitterClient>();
            twitterClient.SetResponse(File.ReadAllText(@".\Data\statuses\show-missing.txt"));
            var statuses = new Statuses(twitterClient);

            // assert
            GenericResponseDelegate endGetTweet = (a, b, c) =>
                                                                    {
                                                                        wasCalled = true;

                                                                        var exception = c as ExceptionResponse;
                                                                        Assert.That(exception, Is.Not.Null);
                                                                    };

            // act
            statuses.BeginGetTweet("12345", endGetTweet);

            Assert.That(wasCalled, Errors.CallbackDidNotFire);
        }