コード例 #1
0
ファイル: Error_Handler.cs プロジェクト: trasa/TwitDegrees
        public void When_Gateway_Timeout_Too_Many_Times()
        {
            var comm = new Mock<ITwitterComm>();
            const int expectedTries = 2;
            comm.Setup(c => c.ExecuteGet(It.IsAny<string>())).Throws(new TwitterException("timeout") {StatusCode = HttpStatusCode.GatewayTimeout});
            var clientUnderTest = new TwitterClient(comm.Object) {MaxCommunicationTries = expectedTries};

            Expect.Exception<TwitterException>(() => clientUnderTest.GetUser("test"));
            comm.Verify(c => c.ExecuteGet(It.IsAny<string>()), Times.Exactly(expectedTries));
        }
コード例 #2
0
ファイル: Error_Handler.cs プロジェクト: trasa/TwitDegrees
 public void When_Gateway_Timeout_Once()
 {
     const string commResult = "heres a message";
     var comm = new CommFailsFirstTime
                    {
                        Exception = new TwitterException("(504) Timeout") {StatusCode = HttpStatusCode.GatewayTimeout},
                        Result = commResult,
                    };
     var clientUnderTest = new TwitterClient(comm);
     string result = clientUnderTest.GetUser("test");
     Assert.That(result, Is.EqualTo(commResult));
     Assert.That(comm.ThrewException, Is.True);
 }
コード例 #3
0
 public void SetUp()
 {
     client = new TwitterClient(new TwitterComm());
 }