audit, advisories and doctors/setup work
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using FluentAssertions;
|
||||
using StellaOps.TestKit;
|
||||
using StellaOps.TestKit.Connectors;
|
||||
using StellaOps.TestKit.Fixtures;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.TestKit.Tests;
|
||||
|
||||
public sealed class TestKitFixtureTests
|
||||
{
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
public async Task ConnectorHttpFixture_CreateClient_ReturnsCannedResponse()
|
||||
{
|
||||
using var fixture = new ConnectorHttpFixture();
|
||||
fixture.AddJsonResponse("https://example.test/api", "{\"status\":\"ok\"}");
|
||||
|
||||
using var client = fixture.CreateClient();
|
||||
var response = await client.GetAsync("https://example.test/api");
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var body = await response.Content.ReadAsStringAsync();
|
||||
body.Should().Be("{\"status\":\"ok\"}");
|
||||
fixture.CapturedRequests.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
public void TestRequestContext_UsesTimeProvider()
|
||||
{
|
||||
var fixedTime = new DateTimeOffset(2025, 1, 1, 10, 0, 0, TimeSpan.Zero);
|
||||
var timeProvider = new FixedTimeProvider(fixedTime);
|
||||
var context = new TestRequestContext(timeProvider);
|
||||
|
||||
context.RecordRequest("GET", "/health", 200);
|
||||
|
||||
var record = context.GetRequests().Single();
|
||||
record.Timestamp.Should().Be(fixedTime.UtcDateTime);
|
||||
}
|
||||
|
||||
private sealed class FixedTimeProvider : TimeProvider
|
||||
{
|
||||
private readonly DateTimeOffset _utcNow;
|
||||
|
||||
public FixedTimeProvider(DateTimeOffset utcNow)
|
||||
{
|
||||
_utcNow = utcNow;
|
||||
}
|
||||
|
||||
public override DateTimeOffset GetUtcNow() => _utcNow;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user