fix issues

This commit is contained in:
Leonid Pershin
2025-10-17 06:15:46 +03:00
parent c5d91a1ad8
commit a96d4d8067
3 changed files with 21 additions and 9 deletions

View File

@@ -173,9 +173,7 @@ public class HistoryCompressionServiceTests : UnitTestBase
);
}
private static IAsyncEnumerable<OllamaSharp.Models.Chat.ChatResponseStream> ThrowAsyncEnumerable(
Exception exception
)
private static ThrowingAsyncEnumerable ThrowAsyncEnumerable(Exception exception)
{
return new ThrowingAsyncEnumerable(exception);
}

View File

@@ -37,10 +37,24 @@ public class ModelServiceTests : UnitTestBase
public async Task InitializeAsync_ShouldLogModelInformation()
{
// Act
await _modelService.InitializeAsync();
var act = async () => await _modelService.InitializeAsync();
// Assert
// The method should complete without throwing exceptions
// In a real test, we might verify logging calls
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<EventId>(),
It.Is<It.IsAnyType>((v, t) => v.ToString()!.Contains("model")),
It.IsAny<Exception>(),
It.IsAny<Func<It.IsAnyType, Exception?, string>>()
),
Times.AtLeastOnce,
"Should log model information"
);
}
}

View File

@@ -156,16 +156,16 @@ public static class TestDataBuilder
.Returns<long, string, string>(
(chatId, chatType, chatTitle) =>
{
if (!sessions.ContainsKey(chatId))
if (!sessions.TryGetValue(chatId, out var session))
{
var session = TestDataBuilder.ChatSessions.CreateBasicSession(
session = TestDataBuilder.ChatSessions.CreateBasicSession(
chatId,
chatType
);
session.ChatTitle = chatTitle;
sessions[chatId] = session;
}
return sessions[chatId];
return session;
}
);