autobus-api_old/AutobusApi.IntegrationTests/Tests/RouteSearchTests.cs

32 lines
974 B
C#

using System.Net;
using Newtonsoft.Json;
namespace AutobusApi.IntegrationTests.Tests;
public class RouteSearchTests : TestsBase
{
public RouteSearchTests(CustomWebApplicationFactory<Program> factory)
: base(factory) {}
[Theory]
[InlineData(1, 10)]
public async Task RouteSearch_ValidStationsAndDate_Returns200OK(int fromId, int toId)
{
var query = new
{
DepartureAddressId = fromId,
ArrivalAddressId = toId,
DepartureDate = DateOnly.FromDateTime(DateTime.UtcNow.Date),
MinTransferTime = TimeSpan.FromMinutes(15),
MaxTransferTime = TimeSpan.FromHours(12),
MaxTransferDistanceInMeters = 1000
};
var response = await _httpClient.PostAsJsonAsync("search", query);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var content = JsonConvert.DeserializeObject<dynamic>(await response.Content.ReadAsStringAsync());
}
}