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,46 @@
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 ModelServiceTests : UnitTestBase
{
private readonly Mock<ILogger<ModelService>> _loggerMock;
private readonly Mock<IOptions<OllamaSettings>> _optionsMock;
private readonly ModelService _modelService;
public ModelServiceTests()
{
_loggerMock = TestDataBuilder.Mocks.CreateLoggerMock<ModelService>();
var ollamaSettings = TestDataBuilder.Configurations.CreateOllamaSettings();
_optionsMock = TestDataBuilder.Mocks.CreateOptionsMock(ollamaSettings);
_modelService = new ModelService(_loggerMock.Object, _optionsMock.Object);
}
[Fact]
public void GetCurrentModel_ShouldReturnDefaultModel()
{
// Act
var result = _modelService.GetCurrentModel();
// Assert
result.Should().Be("llama3.2");
}
[Fact]
public async Task InitializeAsync_ShouldLogModelInformation()
{
// Act
await _modelService.InitializeAsync();
// Assert
// The method should complete without throwing exceptions
// In a real test, we might verify logging calls
}
}