public void GetAsyncWithBadRequest() { var message = "This was bad"; var statusCode = HttpStatusCode.BadRequest; var mockHttp = MockHttpClient.Create(message, statusCode); var apiClient = new ApiClientBase(new Uri("http://example.com/"), mockHttp); Assert.Throws <MastodonApiException>(async() => await apiClient.GetAsync("/test")); }
public async void GetAsyncWithStatusAndMessage() { var message = "Hello"; var statusCode = HttpStatusCode.OK; var mockHttp = MockHttpClient.Create(message, statusCode); var apiClient = new ApiClientBase(new Uri("http://example.com/"), mockHttp); var response = await apiClient.GetAsync("/test"); Assert.AreEqual(message, await response.Content.ReadAsStringAsync()); Assert.AreEqual(statusCode, response.StatusCode); }