using System.Net; using KArtSell.Modules.ModelOperations.TradeExecution; using Microsoft.Extensions.Logging.Abstractions; using Xunit; namespace KArtSell.Integration.Tests.TradeExecution; public sealed class KisTradingHardOffTests { [Fact] public async Task Every_kis_trade_operation_fails_before_any_http_call() { var handler = new CountingHandler(); var service = new KisTradeExecutionService(new HttpClient(handler), NullLogger.Instance); var correlationId = Guid.NewGuid(); await Assert.ThrowsAsync(() => service.ExecuteTradeAsync(Guid.NewGuid(), 1, 1m, correlationId)); await Assert.ThrowsAsync(() => service.GetOrderStatusAsync("order", correlationId)); await Assert.ThrowsAsync(() => service.CancelOrderAsync("order", "test", correlationId)); await Assert.ThrowsAsync(() => service.ConfirmSettlementAsync("order", correlationId)); Assert.Equal(0, handler.CallCount); } private sealed class CountingHandler : HttpMessageHandler { public int CallCount { get; private set; } protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { CallCount++; return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)); } } }