public async Task Options_returns_allowed_methods() { var client = _factory.CreateClientNoRedirects(); var response = await client.OptionsAsync(_endpoint); Assert.Equal(HttpStatusCode.OK, response.StatusCode); }
public async Task Get_by_id_returns_result() { var client = _factory.CreateClientNoRedirects(); var response = await client.GetAsync($"{_endpoint}/{Id}"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); response.ShouldNotHaveHeader(ApiHeaderNames.PreferenceApplied); response.ShouldHaveHeader(HeaderNames.ETag); response.ShouldHaveContentHeader(HeaderNames.LastModified); var model = await response.Content.ReadFromJsonAsync <TModel>(); Assert.NotNull(model ?? throw new NullReferenceException()); Assert.Equal(Id, model.GetId()); }
public async Task Ping_returns_response() { var client = _factory.CreateClientNoRedirects(); var response = await client.GetAsync("ping"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); response.ShouldHaveValidDateHeader(); response.ShouldHaveHeader(HeaderNames.Server); response.ShouldHaveHeader(HeaderNames.Connection); response.ShouldHaveContentHeader(HeaderNames.ContentLength); var options = _factory.Services.GetRequiredService <IOptions <ApiOptions> >(); Assert.Equal(options.Value.ApiServer, response.Headers.GetValues(HeaderNames.Server).FirstOrDefault()); }
public async Task Can_get_cache_info() { var client = _factory.CreateClientNoRedirects(); var response = await client.OptionsAsync("cache"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var body = await response.Content.ReadFromJsonAsync <CacheInfo>(); Assert.Equal(0, body.KeyCount); Assert.Equal(0, body.SizeBytes); }
public async Task Get_without_order_by_returns_sorted_by_id_ascending() { var client = _factory.CreateClientNoRedirects(); var response = await client.GetAsync($"{_endpoint}"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); response.ShouldNotHaveHeader(ApiHeaderNames.PreferenceApplied); response.ShouldHaveHeader(HeaderNames.ETag); response.ShouldHaveContentHeader(HeaderNames.LastModified); var model = await response.Content.ReadFromJsonAsync <Many <TModel> >(); Assert.NotNull(model ?? throw new NullReferenceException()); var ordered = model.Value.ToList(); Assert.Equal(2, ordered.Count); Assert.Equal(ordered[0]?.GetId(), IdLessThanInsertedSecond); Assert.Equal(ordered[1]?.GetId(), IdGreaterThanInsertedFirst); }