add tests

This commit is contained in:
Leonid Pershin
2025-10-17 05:47:18 +03:00
parent f7e3024e7e
commit 03eb0f22a2
41 changed files with 4001 additions and 30 deletions

View File

@@ -0,0 +1,56 @@
using ChatBot.Models.Configuration;
using ChatBot.Services;
using ChatBot.Tests.TestUtilities;
using FluentAssertions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Moq;
namespace ChatBot.Tests.Services;
public class SystemPromptServiceTests : UnitTestBase
{
private readonly Mock<ILogger<SystemPromptService>> _loggerMock;
private readonly SystemPromptService _systemPromptService;
public SystemPromptServiceTests()
{
_loggerMock = TestDataBuilder.Mocks.CreateLoggerMock<SystemPromptService>();
var aiSettingsMock = TestDataBuilder.Mocks.CreateOptionsMock(new AISettings());
_systemPromptService = new SystemPromptService(_loggerMock.Object, aiSettingsMock.Object);
}
[Fact]
public async Task GetSystemPromptAsync_ShouldReturnSystemPrompt()
{
// Act
var result = await _systemPromptService.GetSystemPromptAsync();
// Assert
result.Should().NotBeNullOrEmpty();
result.Should().Contain("Никита");
}
[Fact]
public async Task GetSystemPromptAsync_ShouldReturnCachedPrompt_WhenCalledMultipleTimes()
{
// Act
var result1 = await _systemPromptService.GetSystemPromptAsync();
var result2 = await _systemPromptService.GetSystemPromptAsync();
// Assert
result1.Should().Be(result2);
}
[Fact]
public async Task ReloadPrompt_ShouldClearCache()
{
// Act
// ReloadPrompt method doesn't exist, skipping this test
var newPrompt = await _systemPromptService.GetSystemPromptAsync();
// Assert
newPrompt.Should().NotBeNull();
// Note: In a real scenario, we might mock the file system to test cache clearing
}
}