begin writing tests for episodes controller
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using FluentAssertions;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using server.Models;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace server.tests.integrationTests
|
||||
@@ -24,5 +27,24 @@ namespace server.tests.integrationTests
|
||||
|
||||
_endpoint = "/api/episodes";
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetEpisodesAsync_AllEpisodes_Returns200StatusCodeWithEpisodes()
|
||||
{
|
||||
var response = await _client.GetAsync(_endpoint);
|
||||
|
||||
var data = await response.Content.ReadAsStreamAsync();
|
||||
|
||||
var episodes = JsonSerializer.Deserialize<List<Episode>>(data, _serializerOptions);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
response.Headers.Should().ContainKey("X-Rate-Limit-Limit");
|
||||
response.Headers.Should().ContainKey("X-Rate-Limit-Remaining");
|
||||
response.Headers.Should().ContainKey("X-Rate-Limit-Reset");
|
||||
|
||||
episodes.Should().NotBeNull();
|
||||
episodes.Should().BeOfType<List<Episode>>();
|
||||
episodes.Should().HaveCountGreaterThan(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user