Example #1
0
        public void Test_Retries_Execute_And_Should_Fail()
        {
            var expectedCode = 403;

            try
            {
                var transport = new FakeJsonTransport();
                transport.SetReturn(this.Fixture.GetBadLoginJson());
                transport.SetReturn(this.Fixture.GetBadLoginJson());
                transport.SetReturn(this.Fixture.GetBadLoginJson());
                transport.SetReturn(this.Fixture.GetBadLoginJson());

                var loginMan   = new LoginManager("user", "password", transport);
                var retry      = new HttpRetry(transport, loginMan, 3);
                var codeGetter = new FakeCodeGetter(expectedCode);
                var stream     = new MemoryStream();
                var result     = retry.Invoke(this.Fixture.GetApiUrl(), stream, "", null);
                Assert.Fail("Expected ApiException");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ApiException));
                Assert.AreEqual(((ApiException)ex).HttpStatusCode, expectedCode);
            }
        }
Example #2
0
        public void Test_Retries_Execute_And_Should_Fail()
        {
            var expectedCode = -10001;

            try
            {
                var transport = new FakeJsonTransport();
                transport.SetReturn(this.Fixture.GetBadLoginJson());
                transport.SetReturn(this.Fixture.GetBadLoginJson());
                transport.SetReturn(this.Fixture.GetBadLoginJson());
                transport.SetReturn(this.Fixture.GetBadLoginJson());

                var loginMan   = new LoginManager("user", "password", transport);
                var retry      = new RpcRetry(transport, loginMan, 3);
                var argMaker   = new AutoTokenArgMaker("fooarg");
                var codeGetter = new FakeCodeGetter(expectedCode);
                var result     = retry.Invoke("method", argMaker, codeGetter);
                Assert.Fail("Expected ApiException");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ApiException));
                Assert.AreEqual(((ApiException)ex).AgileStatusCode, expectedCode);
            }
        }