fix tests
Some checks failed
SonarQube / Build and analyze (push) Failing after 1m44s
Unit Tests / Run Tests (push) Failing after 1m7s

This commit is contained in:
Leonid Pershin
2025-10-20 10:39:58 +03:00
parent f4892efbb5
commit 1d0ebfeeb7
10 changed files with 73 additions and 74 deletions

View File

@@ -22,31 +22,31 @@ public class IAIServiceTests : UnitTestBase
m.Name == "GenerateChatCompletionAsync"
);
generateChatCompletionMethod.Should().NotBeNull();
generateChatCompletionMethod!.ReturnType.Should().Be(typeof(Task<string>));
generateChatCompletionMethod!.ReturnType.Should().Be<Task<string>>();
generateChatCompletionMethod.GetParameters().Should().HaveCount(2);
generateChatCompletionMethod
.GetParameters()[0]
.ParameterType.Should()
.Be(typeof(List<ChatMessage>));
.Be<List<ChatMessage>>();
generateChatCompletionMethod
.GetParameters()[1]
.ParameterType.Should()
.Be(typeof(CancellationToken));
.Be<CancellationToken>();
var generateChatCompletionWithCompressionMethod = methods.FirstOrDefault(m =>
m.Name == "GenerateChatCompletionWithCompressionAsync"
);
generateChatCompletionWithCompressionMethod.Should().NotBeNull();
generateChatCompletionWithCompressionMethod!.ReturnType.Should().Be(typeof(Task<string>));
generateChatCompletionWithCompressionMethod!.ReturnType.Should().Be<Task<string>>();
generateChatCompletionWithCompressionMethod.GetParameters().Should().HaveCount(2);
generateChatCompletionWithCompressionMethod
.GetParameters()[0]
.ParameterType.Should()
.Be(typeof(List<ChatMessage>));
.Be<List<ChatMessage>>();
generateChatCompletionWithCompressionMethod
.GetParameters()[1]
.ParameterType.Should()
.Be(typeof(CancellationToken));
.Be<CancellationToken>();
}
[Fact]

View File

@@ -24,25 +24,25 @@ public class IHistoryCompressionServiceTests : UnitTestBase
m.Name == "CompressHistoryAsync"
);
compressHistoryAsyncMethod.Should().NotBeNull();
compressHistoryAsyncMethod!.ReturnType.Should().Be(typeof(Task<List<ChatMessage>>));
compressHistoryAsyncMethod!.ReturnType.Should().Be<Task<List<ChatMessage>>>();
compressHistoryAsyncMethod.GetParameters().Should().HaveCount(3);
compressHistoryAsyncMethod
.GetParameters()[0]
.ParameterType.Should()
.Be(typeof(List<ChatMessage>));
compressHistoryAsyncMethod.GetParameters()[1].ParameterType.Should().Be(typeof(int));
.Be<List<ChatMessage>>();
compressHistoryAsyncMethod.GetParameters()[1].ParameterType.Should().Be<int>();
compressHistoryAsyncMethod
.GetParameters()[2]
.ParameterType.Should()
.Be(typeof(CancellationToken));
.Be<CancellationToken>();
// ShouldCompress method
var shouldCompressMethod = methods.FirstOrDefault(m => m.Name == "ShouldCompress");
shouldCompressMethod.Should().NotBeNull();
shouldCompressMethod!.ReturnType.Should().Be(typeof(bool));
shouldCompressMethod!.ReturnType.Should().Be<bool>();
shouldCompressMethod.GetParameters().Should().HaveCount(2);
shouldCompressMethod.GetParameters()[0].ParameterType.Should().Be(typeof(int));
shouldCompressMethod.GetParameters()[1].ParameterType.Should().Be(typeof(int));
shouldCompressMethod.GetParameters()[0].ParameterType.Should().Be<int>();
shouldCompressMethod.GetParameters()[1].ParameterType.Should().Be<int>();
}
[Fact]

View File

@@ -25,23 +25,23 @@ public class IOllamaClientTests : UnitTestBase
// SelectedModel property
var selectedModelProperty = properties.FirstOrDefault(p => p.Name == "SelectedModel");
selectedModelProperty.Should().NotBeNull();
selectedModelProperty!.PropertyType.Should().Be(typeof(string));
selectedModelProperty!.PropertyType.Should().Be<string>();
selectedModelProperty.CanRead.Should().BeTrue();
selectedModelProperty.CanWrite.Should().BeTrue();
// ChatAsync method
var chatAsyncMethod = methods.FirstOrDefault(m => m.Name == "ChatAsync");
chatAsyncMethod.Should().NotBeNull();
chatAsyncMethod!.ReturnType.Should().Be(typeof(IAsyncEnumerable<ChatResponseStream?>));
chatAsyncMethod!.ReturnType.Should().Be<IAsyncEnumerable<ChatResponseStream?>>();
chatAsyncMethod.GetParameters().Should().HaveCount(1);
chatAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(ChatRequest));
chatAsyncMethod.GetParameters()[0].ParameterType.Should().Be<ChatRequest>();
// ListLocalModelsAsync method
var listLocalModelsAsyncMethod = methods.FirstOrDefault(m =>
m.Name == "ListLocalModelsAsync"
);
listLocalModelsAsyncMethod.Should().NotBeNull();
listLocalModelsAsyncMethod!.ReturnType.Should().Be(typeof(Task<IEnumerable<Model>>));
listLocalModelsAsyncMethod!.ReturnType.Should().Be<Task<IEnumerable<Model>>>();
listLocalModelsAsyncMethod.GetParameters().Should().BeEmpty();
}

View File

@@ -22,47 +22,47 @@ public class ISessionStorageTests : UnitTestBase
// GetOrCreate method
var getOrCreateMethod = methods.FirstOrDefault(m => m.Name == "GetOrCreate");
getOrCreateMethod.Should().NotBeNull();
getOrCreateMethod!.ReturnType.Should().Be(typeof(ChatSession));
getOrCreateMethod!.ReturnType.Should().Be<ChatSession>();
getOrCreateMethod.GetParameters().Should().HaveCount(3);
getOrCreateMethod.GetParameters()[0].ParameterType.Should().Be(typeof(long));
getOrCreateMethod.GetParameters()[1].ParameterType.Should().Be(typeof(string));
getOrCreateMethod.GetParameters()[2].ParameterType.Should().Be(typeof(string));
getOrCreateMethod.GetParameters()[0].ParameterType.Should().Be<long>();
getOrCreateMethod.GetParameters()[1].ParameterType.Should().Be<string>();
getOrCreateMethod.GetParameters()[2].ParameterType.Should().Be<string>();
// Get method
var getMethod = methods.FirstOrDefault(m => m.Name == "Get");
getMethod.Should().NotBeNull();
getMethod!.ReturnType.Should().Be(typeof(ChatSession));
getMethod!.ReturnType.Should().Be<ChatSession>();
getMethod.GetParameters().Should().HaveCount(1);
getMethod.GetParameters()[0].ParameterType.Should().Be(typeof(long));
getMethod.GetParameters()[0].ParameterType.Should().Be<long>();
// Remove method
var removeMethod = methods.FirstOrDefault(m => m.Name == "Remove");
removeMethod.Should().NotBeNull();
removeMethod!.ReturnType.Should().Be(typeof(bool));
removeMethod!.ReturnType.Should().Be<bool>();
removeMethod.GetParameters().Should().HaveCount(1);
removeMethod.GetParameters()[0].ParameterType.Should().Be(typeof(long));
removeMethod.GetParameters()[0].ParameterType.Should().Be<long>();
// GetActiveSessionsCount method
var getActiveSessionsCountMethod = methods.FirstOrDefault(m =>
m.Name == "GetActiveSessionsCount"
);
getActiveSessionsCountMethod.Should().NotBeNull();
getActiveSessionsCountMethod!.ReturnType.Should().Be(typeof(int));
getActiveSessionsCountMethod!.ReturnType.Should().Be<int>();
getActiveSessionsCountMethod.GetParameters().Should().BeEmpty();
// CleanupOldSessions method
var cleanupOldSessionsMethod = methods.FirstOrDefault(m => m.Name == "CleanupOldSessions");
cleanupOldSessionsMethod.Should().NotBeNull();
cleanupOldSessionsMethod!.ReturnType.Should().Be(typeof(int));
cleanupOldSessionsMethod!.ReturnType.Should().Be<int>();
cleanupOldSessionsMethod.GetParameters().Should().HaveCount(1);
cleanupOldSessionsMethod.GetParameters()[0].ParameterType.Should().Be(typeof(int));
cleanupOldSessionsMethod.GetParameters()[0].ParameterType.Should().Be<int>();
// SaveSessionAsync method
var saveSessionAsyncMethod = methods.FirstOrDefault(m => m.Name == "SaveSessionAsync");
saveSessionAsyncMethod.Should().NotBeNull();
saveSessionAsyncMethod!.ReturnType.Should().Be(typeof(Task));
saveSessionAsyncMethod!.ReturnType.Should().Be<Task>();
saveSessionAsyncMethod.GetParameters().Should().HaveCount(1);
saveSessionAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(ChatSession));
saveSessionAsyncMethod.GetParameters()[0].ParameterType.Should().Be<ChatSession>();
}
[Fact]

View File

@@ -22,9 +22,9 @@ public class ITelegramBotClientWrapperTests : UnitTestBase
// GetMeAsync method
var getMeAsyncMethod = methods.FirstOrDefault(m => m.Name == "GetMeAsync");
getMeAsyncMethod.Should().NotBeNull();
getMeAsyncMethod!.ReturnType.Should().Be(typeof(Task<User>));
getMeAsyncMethod!.ReturnType.Should().Be<Task<User>>();
getMeAsyncMethod.GetParameters().Should().HaveCount(1);
getMeAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(CancellationToken));
getMeAsyncMethod.GetParameters()[0].ParameterType.Should().Be<CancellationToken>();
}
[Fact]

View File

@@ -61,11 +61,11 @@ public class TelegramBotClientWrapperTests : UnitTestBase
// Act & Assert
var method = typeof(TelegramBotClientWrapper).GetMethod("GetMeAsync");
method.Should().NotBeNull();
method!.ReturnType.Should().Be(typeof(Task<User>));
method!.ReturnType.Should().Be<Task<User>>();
var parameters = method.GetParameters();
parameters.Should().HaveCount(1);
parameters[0].ParameterType.Should().Be(typeof(CancellationToken));
parameters[0].ParameterType.Should().Be<CancellationToken>();
parameters[0].HasDefaultValue.Should().BeTrue();
}
@@ -142,7 +142,7 @@ public class TelegramBotClientWrapperTests : UnitTestBase
var constructor = constructors[0];
var parameters = constructor.GetParameters();
parameters.Should().HaveCount(1);
parameters[0].ParameterType.Should().Be(typeof(ITelegramBotClient));
parameters[0].ParameterType.Should().Be<ITelegramBotClient>();
parameters[0].Name.Should().Be("botClient");
}
@@ -153,7 +153,7 @@ public class TelegramBotClientWrapperTests : UnitTestBase
var wrapper = new TelegramBotClientWrapper(_botClientMock.Object);
// Act & Assert
wrapper.GetType().BaseType.Should().Be(typeof(object));
wrapper.GetType().BaseType.Should().Be<object>();
}
[Fact]
@@ -179,11 +179,11 @@ public class TelegramBotClientWrapperTests : UnitTestBase
// Assert
interfaceMethods.Should().HaveCount(1);
interfaceMethods[0].Name.Should().Be("GetMeAsync");
interfaceMethods[0].ReturnType.Should().Be(typeof(Task<User>));
interfaceMethods[0].ReturnType.Should().Be<Task<User>>();
var parameters = interfaceMethods[0].GetParameters();
parameters.Should().HaveCount(1);
parameters[0].ParameterType.Should().Be(typeof(CancellationToken));
parameters[0].ParameterType.Should().Be<CancellationToken>();
parameters[0].HasDefaultValue.Should().BeTrue();
}
@@ -324,7 +324,7 @@ public class TelegramBotClientWrapperTests : UnitTestBase
// Act & Assert
getMeMethod.Should().NotBeNull();
var returnType = getMeMethod!.ReturnType;
returnType.Should().Be(typeof(Task<User>));
returnType.Should().Be<Task<User>>();
var attributes = returnType.GetCustomAttributes(false);
attributes.Should().NotBeNull();