finished writing integration tests for seasons controller
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
using server.tests.Http;
|
||||
using FluentAssertions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using server.Models;
|
||||
using server.tests.Helpers;
|
||||
using server.tests.Http;
|
||||
using server.tests.Options;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace server.tests.v1.integrationTests
|
||||
@@ -22,25 +27,72 @@ namespace server.tests.v1.integrationTests
|
||||
[Fact]
|
||||
public async Task GetSeasonsAsync_AllSeasons_Returns200StatusCodeWithSeasons()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var response = await _client.GetAsync(_endpoint);
|
||||
|
||||
var data = await response.Content.ReadAsStreamAsync();
|
||||
|
||||
var seasons = JsonSerializer.Deserialize<List<Season>>(data, _serializerOptions);
|
||||
|
||||
response.StatusCode.Should().Be(System.Net.HttpStatusCode.OK);
|
||||
AssertHelper.CheckForRateLimitingHeaders(response.Headers);
|
||||
|
||||
seasons.Should().NotBeNull();
|
||||
seasons.Should().BeOfType<List<Season>>();
|
||||
seasons.Should().HaveCountGreaterThan(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetSeasonByNumberAsync_SeasonOne_Returns200StatusCodeWithSeason()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var seasonNumber = 1;
|
||||
|
||||
var url = $"{_endpoint}/{seasonNumber}";
|
||||
|
||||
var response = await _client.GetAsync(url);
|
||||
|
||||
var data = await response.Content.ReadAsStreamAsync();
|
||||
|
||||
var season = JsonSerializer.Deserialize<Season>(data, _serializerOptions);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
AssertHelper.CheckForRateLimitingHeaders(response.Headers);
|
||||
|
||||
season.Should().NotBeNull();
|
||||
season.Should().BeOfType<Season>();
|
||||
season.SeasonNumber.Should().Be(seasonNumber);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetSeasonByNumberAsync_InvalidSeason_Returns404StatusCode()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
{
|
||||
var seasonNumber = "test";
|
||||
|
||||
var url = $"{_endpoint}/{seasonNumber}";
|
||||
|
||||
var response = await _client.GetAsync(url);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
|
||||
AssertHelper.CheckForRateLimitingHeaders(response.Headers);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetSeasonByNumberAsync_ValidSeasonNumberForNonExistentSeason_Returns404StatusCode()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var seasonNumber = 20;
|
||||
|
||||
var url = $"{_endpoint}/{seasonNumber}";
|
||||
|
||||
var response = await _client.GetAsync(url);
|
||||
|
||||
var data = await response.Content.ReadAsStreamAsync();
|
||||
|
||||
var details = JsonSerializer.Deserialize<ProblemDetails>(data, _serializerOptions);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
|
||||
AssertHelper.CheckForRateLimitingHeaders(response.Headers);
|
||||
|
||||
details.Should().NotBeNull();
|
||||
details.Should().BeOfType<ProblemDetails>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace server.tests.v1.unitTests
|
||||
response.StatusCode.Should().Be((int)HttpStatusCode.OK);
|
||||
|
||||
season.Should().NotBeNull();
|
||||
season.Should().BeOfType<Episode>();
|
||||
season.Should().BeOfType<Season>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user