mirror of
https://github.com/farcasclaudiu/PracticeCalendar.git
synced 2026-06-22 07:01:16 +03:00
50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using System.Net;
|
|
using FluentAssertions;
|
|
using PracticeCalendar.Domain.Entities.PracticeEvent;
|
|
using PracticeCalendar.UnitTests.Integration;
|
|
using static PracticeCalendar.UnitTests.Integration.Testing;
|
|
|
|
public class ControllerApiTest : BaseTest
|
|
{
|
|
[Fact]
|
|
public async Task GetAllEventsEmptyTestAsync()
|
|
{
|
|
await RunBeforeAnyTests();
|
|
var http = GetHttpClient();
|
|
|
|
var httpResponse = await http.GetAsync("/api/events");
|
|
|
|
httpResponse.IsSuccessStatusCode.Should().BeTrue();
|
|
httpResponse.StatusCode.Should().Be(HttpStatusCode.OK);
|
|
|
|
var responseStr = await httpResponse.Content.ReadAsStringAsync();
|
|
responseStr.Should().Be("[]");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetAllEventsManyTestAsync()
|
|
{
|
|
await RunBeforeAnyTests();
|
|
await AddAsync(new PracticeEvent("Test Event", "Event description",
|
|
DateTime.Now.AddHours(-1), DateTime.Now.AddHours(1))
|
|
{
|
|
Id = 1,
|
|
Attendees = {
|
|
new Attendee("Claudiu F", "claudiuf@busybee.com")
|
|
{
|
|
Id = 1
|
|
}
|
|
}
|
|
});
|
|
|
|
var http = GetHttpClient();
|
|
|
|
var httpResponse = await http.GetAsync("/api/events");
|
|
|
|
httpResponse.IsSuccessStatusCode.Should().BeTrue();
|
|
httpResponse.StatusCode.Should().Be(HttpStatusCode.OK);
|
|
|
|
var responseStr = await httpResponse.Content.ReadAsStringAsync();
|
|
responseStr.Length.Should().Be(257);
|
|
}
|
|
} |