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); } }
public void Test_Retries_Execute_And_Can_Complete_Successfully() { var returnMe = new WebHeaderCollection(); returnMe.Add("X-Agile-Status", "0"); var transport = new FakeJsonTransport(); transport.SetReturn(this.Fixture.GetBadLoginJson()); transport.SetReturn(this.Fixture.GetBadLoginJson()); transport.SetReturn(this.Fixture.GetGoodLoginJson()); transport.SetReturn(returnMe); var loginMan = new LoginManager("user", "password", transport); var retry = new HttpRetry(transport, loginMan, 3); var codeGetter = new NullCodeGetter(); var stream = new MemoryStream(new byte[] { 100 }); var result = retry.Invoke("http://", stream, "", new Dictionary <string, string>()); Assert.AreEqual(result, returnMe); }