public void CustomVerb_Works() { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; _ = sut.Execute("p", exVerb: new HttpMethod("customMethodThatDoesNotExist")); Assert.Equal("customMethodThatDoesNotExist", hh.LastUsedVerb); }
public void Verb_DefaultIs_Get() { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; _ = sut.Execute("p"); Assert.Equal("GET", hh.LastUsedVerb); }
public void Verb_ExecuteSet_Arrives() { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; _ = sut.Execute("p", exVerb: HttpMethod.Delete); Assert.Equal("DELETE", hh.LastUsedVerb); }
public void GetUri_ReturnsUri(string baseval, string stem, string qparam, string expected) { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; var result = sut.GetUri(baseval, stem, qparam); Assert.Equal(expected, result); }
public async Task Body_IsPresent() { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; await sut.Execute("qparam", "body"); var s = hh.GetBodyValue(); Assert.Equal("body", s); }
public async void HttpSucces_ReturnsSuccess() { var hh = new MockHttpHelper("dummy"); hh.SetResponse(HttpStatusCode.OK); var f = await hh.Execute(""); Assert.True(f.Success); Assert.True(f.Status == HttpStatusCode.OK); }
public async Task Retry_404_DoesNotRetry() { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; hh.SetResponse(HttpStatusCode.NotFound); sut.RetryCount = 5; await sut.Execute(null); Assert.Equal(1, hh.CallsMade); }
public void Header_IsPresent() { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; sut.AddHeader("name", "value"); var s = hh.GetHeaderValue("name"); Assert.Equal("value", s); }
public void Verb_PropSet_Persists() { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; sut.Verb = HttpMethod.Post; _ = sut.Execute("p"); Assert.Equal("POST", hh.LastUsedVerb); }
public async Task Retry_500_DoesRetry() { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; hh.SetResponse(HttpStatusCode.InternalServerError); sut.RetryCount = 5; await sut.Execute(null); Assert.Equal(5, hh.CallsMade); }
public void Auth_Bearer_AddsCreds() { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; sut.AddBearerAuthHeader("secret"); var s = hh.GetHeaderValue("Authorization"); Assert.Contains("Bearer", s); Assert.Contains("secret", s); // cant contain it in plain text. }
public void Auth_Basic_AddsB64Creds() { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; sut.AddBasicAuthHeader("secret"); var s = hh.GetHeaderValue("Authorization"); Assert.Contains("Basic", s); Assert.True(!s.Contains("secret")); // cant contain it in plain text. }
public void GetUri_BaseCanNotBeNull() { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; Assert.Throws <ArgumentNullException>(() => { var result = sut.GetUri(null, "dummy", "dummy"); }); Assert.Throws <ArgumentOutOfRangeException>(() => { var result = sut.GetUri("", "dummy", "dummy"); }); }
public async void MockHelper_SetResponse_ReturnsResponse() { var hh = new MockHttpHelper("dummy"); hh.SetResponse(HttpStatusCode.InternalServerError); var wcr = new WebCallRequest { // Normally done in the Helper but this test exercises the mock directly. Verb = HttpMethod.Get }; var r = await hh.ActualCall_Test(wcr); Assert.Equal(HttpStatusCode.InternalServerError, r.Status); }
public void Verb_ArivesUpperCase() { var hh = new MockHttpHelper("dummyuri"); HttpHelper sut = hh; _ = sut.Execute("p", exVerb: HttpMethod.Post); Assert.Equal("POST", hh.LastUsedVerb); _ = sut.Execute("p", exVerb: HttpMethod.Get); Assert.Equal("GET", hh.LastUsedVerb); sut.Verb = HttpMethod.Delete; _ = sut.Execute("p"); Assert.Equal("DELETE", hh.LastUsedVerb); }
public void MockHelper_StartsZeroCallsMade() { var hh = new MockHttpHelper("dummy"); Assert.Equal(0, hh.CallsMade); }