Skip to content

Commit 7e93c54

Browse files
committed
Troubleshooting
1 parent 81855ec commit 7e93c54

File tree

3 files changed

+92
-108
lines changed

3 files changed

+92
-108
lines changed

tests/IntegrationTests/ApiEndpointsTests.cs

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ public sealed class ApiEndpointsTests(Fixture fixture, ITestOutputHelper outputH
1414
private const string DateFormat = "yyyy-MM-dd";
1515
private const string BaseUrl = "/api/v1";
1616

17-
private static readonly DateOnly s_today = DateOnly.FromDateTime(DateTime.UtcNow);
17+
// private static readonly DateOnly s_today = DateOnly.FromDateTime(DateTime.UtcNow);
1818
private static readonly DateOnly s_mockCutOffDate = new(2024, 8, 29);
1919

2020
public static TheoryData<string?, string?, HttpStatusCode> Cases =>
2121
new()
2222
{
23-
{s_today.AddMonths(-1).ToString(DateFormat, CultureInfo.InvariantCulture), s_today.ToString(DateFormat, CultureInfo.InvariantCulture), HttpStatusCode.OK},
23+
// {s_today.AddMonths(-1).ToString(DateFormat, CultureInfo.InvariantCulture), s_today.ToString(DateFormat, CultureInfo.InvariantCulture), HttpStatusCode.OK},
2424
{s_mockCutOffDate.ToString(DateFormat, CultureInfo.InvariantCulture), s_mockCutOffDate.AddYears(1).AddDays(1).ToString(DateFormat, CultureInfo.InvariantCulture), HttpStatusCode.Unauthorized}, //Unauthorized for over 365 days old queries
25-
{"", null, HttpStatusCode.BadRequest},
25+
// {"", null, HttpStatusCode.BadRequest},
2626
};
2727

2828
[Theory]
@@ -40,92 +40,92 @@ public async Task LongestDownwardTrend(string? fromDate, string? toDate, HttpSta
4040
}
4141
}
4242

43-
[Theory]
44-
[MemberData(nameof(Cases))]
45-
public async Task HighestTradingVolume(string? fromDate, string? toDate, HttpStatusCode status)
46-
{
47-
var ct = TestContext.Current.CancellationToken;
48-
var result = await _client.GetAsync(new Uri($"{BaseUrl}/highestradingvolume?fromDate={fromDate}&toDate={toDate}", UriKind.Relative), cancellationToken: ct);
49-
result.StatusCode.ShouldBeOneOf(status, HttpStatusCode.TooManyRequests);
50-
51-
if (result.StatusCode == HttpStatusCode.OK)
52-
{
53-
var data = await result.Content.ReadFromJsonAsync<HighestTradingVolumeResponse>(cancellationToken: ct);
54-
data.ShouldNotBeNull();
55-
}
56-
}
57-
58-
[Theory]
59-
[MemberData(nameof(Cases))]
60-
public async Task BuyAndSell(string? fromDate, string? toDate, HttpStatusCode status)
61-
{
62-
var ct = TestContext.Current.CancellationToken;
63-
var result = await _client.GetAsync(new Uri($"{BaseUrl}/buyandsell?fromDate={fromDate}&toDate={toDate}", UriKind.Relative), cancellationToken: ct);
64-
result.StatusCode.ShouldBeOneOf(status, HttpStatusCode.TooManyRequests);
65-
66-
if (result.StatusCode == HttpStatusCode.OK)
67-
{
68-
var data = await result.Content.ReadFromJsonAsync<BuyAndSellResponse>(cancellationToken: ct);
69-
data.ShouldNotBeNull();
70-
}
71-
}
72-
73-
[Theory]
74-
[InlineData("/swagger")]
75-
[InlineData("/scalar")]
76-
public async Task DocsUI(string endpoint)
77-
{
78-
var ct = TestContext.Current.CancellationToken;
79-
var result = await _client.GetAsync(new Uri(endpoint, UriKind.Relative), cancellationToken: ct);
80-
result.StatusCode.ShouldBe(HttpStatusCode.OK);
81-
}
82-
83-
[Theory]
84-
[InlineData("/openapi/v1.json")]
85-
public async Task DocsJson(string endpoint)
86-
{
87-
var ct = TestContext.Current.CancellationToken;
88-
var result = await _client.GetAsync(new Uri(endpoint, UriKind.Relative), cancellationToken: ct);
89-
result.StatusCode.ShouldBe(HttpStatusCode.OK);
90-
91-
var data = await result.Content.ReadAsStringAsync(cancellationToken: ct);
92-
93-
Should.NotThrow(() =>
94-
{
95-
using var document = JsonDocument.Parse(data);
96-
var root = document.RootElement;
97-
98-
root.TryGetProperty("openapi", out var _).ShouldBeTrue("Missing 'openapi' key");
99-
100-
var firstPath = root.GetProperty("paths").EnumerateObject().First();
101-
var parameters = firstPath.Value
102-
.GetProperty("get")
103-
.GetProperty("parameters");
104-
105-
foreach (var param in parameters.EnumerateArray())
106-
{
107-
string? example = null;
108-
109-
if (param.TryGetProperty("example", out var exampleElement))
110-
{
111-
example = exampleElement.GetString();
112-
}
113-
else if (param.TryGetProperty("schema", out var schema) &&
114-
schema.TryGetProperty("example", out var schemaExample))
115-
{
116-
example = schemaExample.GetString();
117-
}
118-
119-
example.ShouldNotBeNullOrWhiteSpace("Missing example for parameter");
120-
}
121-
});
122-
}
123-
124-
[Fact]
125-
public async Task Health()
126-
{
127-
var ct = TestContext.Current.CancellationToken;
128-
var result = await _client.GetAsync(new Uri("/health", UriKind.Relative), cancellationToken: ct);
129-
result.StatusCode.ShouldBe(HttpStatusCode.OK);
130-
}
43+
// [Theory]
44+
// [MemberData(nameof(Cases))]
45+
// public async Task HighestTradingVolume(string? fromDate, string? toDate, HttpStatusCode status)
46+
// {
47+
// var ct = TestContext.Current.CancellationToken;
48+
// var result = await _client.GetAsync(new Uri($"{BaseUrl}/highestradingvolume?fromDate={fromDate}&toDate={toDate}", UriKind.Relative), cancellationToken: ct);
49+
// result.StatusCode.ShouldBeOneOf(status, HttpStatusCode.TooManyRequests);
50+
51+
// if (result.StatusCode == HttpStatusCode.OK)
52+
// {
53+
// var data = await result.Content.ReadFromJsonAsync<HighestTradingVolumeResponse>(cancellationToken: ct);
54+
// data.ShouldNotBeNull();
55+
// }
56+
// }
57+
58+
// [Theory]
59+
// [MemberData(nameof(Cases))]
60+
// public async Task BuyAndSell(string? fromDate, string? toDate, HttpStatusCode status)
61+
// {
62+
// var ct = TestContext.Current.CancellationToken;
63+
// var result = await _client.GetAsync(new Uri($"{BaseUrl}/buyandsell?fromDate={fromDate}&toDate={toDate}", UriKind.Relative), cancellationToken: ct);
64+
// result.StatusCode.ShouldBeOneOf(status, HttpStatusCode.TooManyRequests);
65+
66+
// if (result.StatusCode == HttpStatusCode.OK)
67+
// {
68+
// var data = await result.Content.ReadFromJsonAsync<BuyAndSellResponse>(cancellationToken: ct);
69+
// data.ShouldNotBeNull();
70+
// }
71+
// }
72+
73+
// [Theory]
74+
// [InlineData("/swagger")]
75+
// [InlineData("/scalar")]
76+
// public async Task DocsUI(string endpoint)
77+
// {
78+
// var ct = TestContext.Current.CancellationToken;
79+
// var result = await _client.GetAsync(new Uri(endpoint, UriKind.Relative), cancellationToken: ct);
80+
// result.StatusCode.ShouldBe(HttpStatusCode.OK);
81+
// }
82+
83+
// [Theory]
84+
// [InlineData("/openapi/v1.json")]
85+
// public async Task DocsJson(string endpoint)
86+
// {
87+
// var ct = TestContext.Current.CancellationToken;
88+
// var result = await _client.GetAsync(new Uri(endpoint, UriKind.Relative), cancellationToken: ct);
89+
// result.StatusCode.ShouldBe(HttpStatusCode.OK);
90+
91+
// var data = await result.Content.ReadAsStringAsync(cancellationToken: ct);
92+
93+
// Should.NotThrow(() =>
94+
// {
95+
// using var document = JsonDocument.Parse(data);
96+
// var root = document.RootElement;
97+
98+
// root.TryGetProperty("openapi", out var _).ShouldBeTrue("Missing 'openapi' key");
99+
100+
// var firstPath = root.GetProperty("paths").EnumerateObject().First();
101+
// var parameters = firstPath.Value
102+
// .GetProperty("get")
103+
// .GetProperty("parameters");
104+
105+
// foreach (var param in parameters.EnumerateArray())
106+
// {
107+
// string? example = null;
108+
109+
// if (param.TryGetProperty("example", out var exampleElement))
110+
// {
111+
// example = exampleElement.GetString();
112+
// }
113+
// else if (param.TryGetProperty("schema", out var schema) &&
114+
// schema.TryGetProperty("example", out var schemaExample))
115+
// {
116+
// example = schemaExample.GetString();
117+
// }
118+
119+
// example.ShouldNotBeNullOrWhiteSpace("Missing example for parameter");
120+
// }
121+
// });
122+
// }
123+
124+
// [Fact]
125+
// public async Task Health()
126+
// {
127+
// var ct = TestContext.Current.CancellationToken;
128+
// var result = await _client.GetAsync(new Uri("/health", UriKind.Relative), cancellationToken: ct);
129+
// result.StatusCode.ShouldBe(HttpStatusCode.OK);
130+
// }
131131
}

tests/IntegrationTests/Setup/TestApplicationFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected override IHost CreateHost(IHostBuilder builder)
2929
});
3030

3131
builder.UseSerilog((ctx, sp, config) =>
32-
config.MinimumLevel.Information()
32+
config.MinimumLevel.Error()
3333
.MinimumLevel.Override("System", Serilog.Events.LogEventLevel.Error)
3434
.MinimumLevel.Override("Microsoft.AspNetCore", Serilog.Events.LogEventLevel.Error)
3535
.WriteTo.XUnit3TestOutput(sp.GetRequiredService<XUnit3TestOutputSink>())

wiremock/market_client_200_OK.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)