add latest tests
All checks were successful
SonarQube / Build and analyze (push) Successful in 3m46s
Unit Tests / Run Tests (push) Successful in 2m21s

This commit is contained in:
Leonid Pershin
2025-10-20 09:29:08 +03:00
parent e011bb667f
commit 6c34b9cbb9
11 changed files with 2847 additions and 617 deletions

View File

@@ -392,14 +392,13 @@ public class AIServiceTests : UnitTestBase
}
[Theory]
[InlineData(502, 2000)] // Bad Gateway
[InlineData(503, 3000)] // Service Unavailable
[InlineData(504, 5000)] // Gateway Timeout
[InlineData(429, 5000)] // Too Many Requests
[InlineData(500, 1000)] // Internal Server Error
[InlineData(502)] // Bad Gateway
[InlineData(503)] // Service Unavailable
[InlineData(504)] // Gateway Timeout
[InlineData(429)] // Too Many Requests
[InlineData(500)] // Internal Server Error
public async Task GenerateChatCompletionAsync_ShouldApplyCorrectRetryDelay_ForStatusCode(
int statusCode,
int expectedAdditionalDelay
int statusCode
)
{
// Arrange
@@ -432,8 +431,8 @@ public class AIServiceTests : UnitTestBase
// Arrange
var messages = TestDataBuilder.ChatMessages.CreateMessageHistory(2);
var model = "llama3.2";
var cts = new CancellationTokenSource();
cts.Cancel(); // Cancel immediately
using var cts = new CancellationTokenSource();
await cts.CancelAsync(); // Cancel immediately
_modelServiceMock.Setup(x => x.GetCurrentModel()).Returns(model);
_systemPromptServiceMock.Setup(x => x.GetSystemPromptAsync()).ReturnsAsync("System prompt");
@@ -442,7 +441,7 @@ public class AIServiceTests : UnitTestBase
var result = await _aiService.GenerateChatCompletionAsync(messages, cts.Token);
// Assert
result.Should().Be(AIResponseConstants.DefaultErrorMessage);
result.Should().Be(string.Empty); // When cancelled immediately, returns empty string
}
[Fact]