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> _loggerMock; private readonly Mock> _optionsMock; private readonly ModelService _modelService; public ModelServiceTests() { _loggerMock = TestDataBuilder.Mocks.CreateLoggerMock(); 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 var act = async () => await _modelService.InitializeAsync(); // Assert await act.Should() .NotThrowAsync("InitializeAsync should complete without throwing exceptions"); // Verify that logging was called (at least once for model information) _loggerMock.Verify( x => x.Log( LogLevel.Information, It.IsAny(), It.Is((v, t) => v.ToString()!.Contains("model")), It.IsAny(), It.IsAny>() ), Times.AtLeastOnce, "Should log model information" ); } }