47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
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
|
|
}
|
|
}
|