26ff8d9b4f
Set up repository with legacy .NET Framework 4.8 source (OLD/), new .NET 10 Blazor solution (NEW/), OpenSpec specifications, documentation, and project configuration.
52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using System.Net;
|
|
using System.Net.Http.Json;
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
using Shouldly;
|
|
|
|
namespace JdeScoping.Api.IntegrationTests;
|
|
|
|
/// <summary>
|
|
/// Integration tests for file controller cache behavior.
|
|
/// </summary>
|
|
public class FileControllerIntegrationTests : IClassFixture<TestWebApplicationFactory>
|
|
{
|
|
private readonly TestWebApplicationFactory _factory;
|
|
private readonly HttpClient _client;
|
|
|
|
public FileControllerIntegrationTests(TestWebApplicationFactory factory)
|
|
{
|
|
_factory = factory;
|
|
_client = factory.CreateClient(new WebApplicationFactoryClientOptions
|
|
{
|
|
HandleCookies = true,
|
|
AllowAutoRedirect = false
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public async Task DownloadTemplate_WithInvalidCacheKey_Returns404()
|
|
{
|
|
// Arrange - use a random GUID that won't be in cache
|
|
var invalidKey = Guid.NewGuid();
|
|
|
|
// Act
|
|
var response = await _client.GetAsync($"/api/file/work-orders/template/{invalidKey}");
|
|
|
|
// Assert
|
|
response.StatusCode.ShouldBe(HttpStatusCode.NotFound);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task DownloadTemplate_WithExpiredOrMissingKey_Returns404()
|
|
{
|
|
// Arrange - attempt to download with non-existent key
|
|
var expiredKey = Guid.NewGuid();
|
|
|
|
// Act
|
|
var response = await _client.GetAsync($"/api/file/part-numbers/template/{expiredKey}");
|
|
|
|
// Assert
|
|
response.StatusCode.ShouldBe(HttpStatusCode.NotFound);
|
|
}
|
|
}
|