diff --git a/ChatBot.Tests/Common/Constants/AIResponseConstantsTests.cs b/ChatBot.Tests/Common/Constants/AIResponseConstantsTests.cs index 53f863a..08c2cf4 100644 --- a/ChatBot.Tests/Common/Constants/AIResponseConstantsTests.cs +++ b/ChatBot.Tests/Common/Constants/AIResponseConstantsTests.cs @@ -392,7 +392,7 @@ public class AIResponseConstantsTests _ => typeof(object), }; - emptyMarkerType.Should().Be(typeof(string)); + emptyMarkerType.Should().Be(); } [Fact] diff --git a/ChatBot.Tests/Common/Constants/ChatTypesTests.cs b/ChatBot.Tests/Common/Constants/ChatTypesTests.cs index ae5525b..4aa2389 100644 --- a/ChatBot.Tests/Common/Constants/ChatTypesTests.cs +++ b/ChatBot.Tests/Common/Constants/ChatTypesTests.cs @@ -345,28 +345,28 @@ public class ChatTypesTests "private" => typeof(string), _ => typeof(object), }; - privateType.Should().Be(typeof(string)); + privateType.Should().Be(); var groupType = ChatTypes.Group switch { "group" => typeof(string), _ => typeof(object), }; - groupType.Should().Be(typeof(string)); + groupType.Should().Be(); var superGroupType = ChatTypes.SuperGroup switch { "supergroup" => typeof(string), _ => typeof(object), }; - superGroupType.Should().Be(typeof(string)); + superGroupType.Should().Be(); var channelType = ChatTypes.Channel switch { "channel" => typeof(string), _ => typeof(object), }; - channelType.Should().Be(typeof(string)); + channelType.Should().Be(); } [Fact] diff --git a/ChatBot.Tests/Data/Interfaces/IChatSessionRepositoryTests.cs b/ChatBot.Tests/Data/Interfaces/IChatSessionRepositoryTests.cs index 9b9328a..c0cefd1 100644 --- a/ChatBot.Tests/Data/Interfaces/IChatSessionRepositoryTests.cs +++ b/ChatBot.Tests/Data/Interfaces/IChatSessionRepositoryTests.cs @@ -22,72 +22,72 @@ public class IChatSessionRepositoryTests : UnitTestBase // GetOrCreateAsync method var getOrCreateAsyncMethod = methods.FirstOrDefault(m => m.Name == "GetOrCreateAsync"); getOrCreateAsyncMethod.Should().NotBeNull(); - getOrCreateAsyncMethod!.ReturnType.Should().Be(typeof(Task)); + getOrCreateAsyncMethod!.ReturnType.Should().Be>(); getOrCreateAsyncMethod.GetParameters().Should().HaveCount(3); - getOrCreateAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(long)); - getOrCreateAsyncMethod.GetParameters()[1].ParameterType.Should().Be(typeof(string)); - getOrCreateAsyncMethod.GetParameters()[2].ParameterType.Should().Be(typeof(string)); + getOrCreateAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); + getOrCreateAsyncMethod.GetParameters()[1].ParameterType.Should().Be(); + getOrCreateAsyncMethod.GetParameters()[2].ParameterType.Should().Be(); // GetByChatIdAsync method var getByChatIdAsyncMethod = methods.FirstOrDefault(m => m.Name == "GetByChatIdAsync"); getByChatIdAsyncMethod.Should().NotBeNull(); - getByChatIdAsyncMethod!.ReturnType.Should().Be(typeof(Task)); + getByChatIdAsyncMethod!.ReturnType.Should().Be>(); getByChatIdAsyncMethod.GetParameters().Should().HaveCount(1); - getByChatIdAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(long)); + getByChatIdAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); // GetBySessionIdAsync method var getBySessionIdAsyncMethod = methods.FirstOrDefault(m => m.Name == "GetBySessionIdAsync" ); getBySessionIdAsyncMethod.Should().NotBeNull(); - getBySessionIdAsyncMethod!.ReturnType.Should().Be(typeof(Task)); + getBySessionIdAsyncMethod!.ReturnType.Should().Be>(); getBySessionIdAsyncMethod.GetParameters().Should().HaveCount(1); - getBySessionIdAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(string)); + getBySessionIdAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); // UpdateAsync method var updateAsyncMethod = methods.FirstOrDefault(m => m.Name == "UpdateAsync"); updateAsyncMethod.Should().NotBeNull(); - updateAsyncMethod!.ReturnType.Should().Be(typeof(Task)); + updateAsyncMethod!.ReturnType.Should().Be>(); updateAsyncMethod.GetParameters().Should().HaveCount(1); - updateAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(ChatSessionEntity)); + updateAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); // DeleteAsync method var deleteAsyncMethod = methods.FirstOrDefault(m => m.Name == "DeleteAsync"); deleteAsyncMethod.Should().NotBeNull(); - deleteAsyncMethod!.ReturnType.Should().Be(typeof(Task)); + deleteAsyncMethod!.ReturnType.Should().Be>(); deleteAsyncMethod.GetParameters().Should().HaveCount(1); - deleteAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(long)); + deleteAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); // GetMessagesAsync method var getMessagesAsyncMethod = methods.FirstOrDefault(m => m.Name == "GetMessagesAsync"); getMessagesAsyncMethod.Should().NotBeNull(); - getMessagesAsyncMethod!.ReturnType.Should().Be(typeof(Task>)); + getMessagesAsyncMethod!.ReturnType.Should().Be>>(); getMessagesAsyncMethod.GetParameters().Should().HaveCount(1); - getMessagesAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(int)); + getMessagesAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); // AddMessageAsync method var addMessageAsyncMethod = methods.FirstOrDefault(m => m.Name == "AddMessageAsync"); addMessageAsyncMethod.Should().NotBeNull(); - addMessageAsyncMethod!.ReturnType.Should().Be(typeof(Task)); + addMessageAsyncMethod!.ReturnType.Should().Be>(); addMessageAsyncMethod.GetParameters().Should().HaveCount(4); - addMessageAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(int)); - addMessageAsyncMethod.GetParameters()[1].ParameterType.Should().Be(typeof(string)); - addMessageAsyncMethod.GetParameters()[2].ParameterType.Should().Be(typeof(string)); - addMessageAsyncMethod.GetParameters()[3].ParameterType.Should().Be(typeof(int)); + addMessageAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); + addMessageAsyncMethod.GetParameters()[1].ParameterType.Should().Be(); + addMessageAsyncMethod.GetParameters()[2].ParameterType.Should().Be(); + addMessageAsyncMethod.GetParameters()[3].ParameterType.Should().Be(); // ClearMessagesAsync method var clearMessagesAsyncMethod = methods.FirstOrDefault(m => m.Name == "ClearMessagesAsync"); clearMessagesAsyncMethod.Should().NotBeNull(); - clearMessagesAsyncMethod!.ReturnType.Should().Be(typeof(Task)); + clearMessagesAsyncMethod!.ReturnType.Should().Be(); clearMessagesAsyncMethod.GetParameters().Should().HaveCount(1); - clearMessagesAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(int)); + clearMessagesAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); // GetActiveSessionsCountAsync method var getActiveSessionsCountAsyncMethod = methods.FirstOrDefault(m => m.Name == "GetActiveSessionsCountAsync" ); getActiveSessionsCountAsyncMethod.Should().NotBeNull(); - getActiveSessionsCountAsyncMethod!.ReturnType.Should().Be(typeof(Task)); + getActiveSessionsCountAsyncMethod!.ReturnType.Should().Be>(); getActiveSessionsCountAsyncMethod.GetParameters().Should().BeEmpty(); // CleanupOldSessionsAsync method @@ -95,20 +95,18 @@ public class IChatSessionRepositoryTests : UnitTestBase m.Name == "CleanupOldSessionsAsync" ); cleanupOldSessionsAsyncMethod.Should().NotBeNull(); - cleanupOldSessionsAsyncMethod!.ReturnType.Should().Be(typeof(Task)); + cleanupOldSessionsAsyncMethod!.ReturnType.Should().Be>(); cleanupOldSessionsAsyncMethod.GetParameters().Should().HaveCount(1); - cleanupOldSessionsAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(int)); + cleanupOldSessionsAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); // GetSessionsForCleanupAsync method var getSessionsForCleanupAsyncMethod = methods.FirstOrDefault(m => m.Name == "GetSessionsForCleanupAsync" ); getSessionsForCleanupAsyncMethod.Should().NotBeNull(); - getSessionsForCleanupAsyncMethod! - .ReturnType.Should() - .Be(typeof(Task>)); + getSessionsForCleanupAsyncMethod!.ReturnType.Should().Be>>(); getSessionsForCleanupAsyncMethod.GetParameters().Should().HaveCount(1); - getSessionsForCleanupAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(int)); + getSessionsForCleanupAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); } [Fact] diff --git a/ChatBot.Tests/Data/MigrationsTests.cs b/ChatBot.Tests/Data/MigrationsTests.cs index 19a8002..a590754 100644 --- a/ChatBot.Tests/Data/MigrationsTests.cs +++ b/ChatBot.Tests/Data/MigrationsTests.cs @@ -160,10 +160,10 @@ public class MigrationsTests : IDisposable var foreignKeys = chatMessageEntity.GetForeignKeys(); foreignKeys.Should().HaveCount(1); - var foreignKey = foreignKeys.First(); + var foreignKey = foreignKeys[0]; foreignKey.PrincipalEntityType.Should().Be(chatSessionEntity); foreignKey.Properties.Should().HaveCount(1); - foreignKey.Properties.First().Name.Should().Be("SessionId"); + foreignKey.Properties[0].Name.Should().Be("SessionId"); foreignKey.DeleteBehavior.Should().Be(DeleteBehavior.Cascade); } @@ -330,5 +330,6 @@ public class MigrationsTests : IDisposable { _dbContext?.Dispose(); _serviceProvider?.Dispose(); + GC.SuppressFinalize(this); } } diff --git a/ChatBot.Tests/Services/Interfaces/IAIServiceTests.cs b/ChatBot.Tests/Services/Interfaces/IAIServiceTests.cs index e0cd10e..105b069 100644 --- a/ChatBot.Tests/Services/Interfaces/IAIServiceTests.cs +++ b/ChatBot.Tests/Services/Interfaces/IAIServiceTests.cs @@ -22,31 +22,31 @@ public class IAIServiceTests : UnitTestBase m.Name == "GenerateChatCompletionAsync" ); generateChatCompletionMethod.Should().NotBeNull(); - generateChatCompletionMethod!.ReturnType.Should().Be(typeof(Task)); + generateChatCompletionMethod!.ReturnType.Should().Be>(); generateChatCompletionMethod.GetParameters().Should().HaveCount(2); generateChatCompletionMethod .GetParameters()[0] .ParameterType.Should() - .Be(typeof(List)); + .Be>(); generateChatCompletionMethod .GetParameters()[1] .ParameterType.Should() - .Be(typeof(CancellationToken)); + .Be(); var generateChatCompletionWithCompressionMethod = methods.FirstOrDefault(m => m.Name == "GenerateChatCompletionWithCompressionAsync" ); generateChatCompletionWithCompressionMethod.Should().NotBeNull(); - generateChatCompletionWithCompressionMethod!.ReturnType.Should().Be(typeof(Task)); + generateChatCompletionWithCompressionMethod!.ReturnType.Should().Be>(); generateChatCompletionWithCompressionMethod.GetParameters().Should().HaveCount(2); generateChatCompletionWithCompressionMethod .GetParameters()[0] .ParameterType.Should() - .Be(typeof(List)); + .Be>(); generateChatCompletionWithCompressionMethod .GetParameters()[1] .ParameterType.Should() - .Be(typeof(CancellationToken)); + .Be(); } [Fact] diff --git a/ChatBot.Tests/Services/Interfaces/IHistoryCompressionServiceTests.cs b/ChatBot.Tests/Services/Interfaces/IHistoryCompressionServiceTests.cs index 85175d0..e21dc56 100644 --- a/ChatBot.Tests/Services/Interfaces/IHistoryCompressionServiceTests.cs +++ b/ChatBot.Tests/Services/Interfaces/IHistoryCompressionServiceTests.cs @@ -24,25 +24,25 @@ public class IHistoryCompressionServiceTests : UnitTestBase m.Name == "CompressHistoryAsync" ); compressHistoryAsyncMethod.Should().NotBeNull(); - compressHistoryAsyncMethod!.ReturnType.Should().Be(typeof(Task>)); + compressHistoryAsyncMethod!.ReturnType.Should().Be>>(); compressHistoryAsyncMethod.GetParameters().Should().HaveCount(3); compressHistoryAsyncMethod .GetParameters()[0] .ParameterType.Should() - .Be(typeof(List)); - compressHistoryAsyncMethod.GetParameters()[1].ParameterType.Should().Be(typeof(int)); + .Be>(); + compressHistoryAsyncMethod.GetParameters()[1].ParameterType.Should().Be(); compressHistoryAsyncMethod .GetParameters()[2] .ParameterType.Should() - .Be(typeof(CancellationToken)); + .Be(); // ShouldCompress method var shouldCompressMethod = methods.FirstOrDefault(m => m.Name == "ShouldCompress"); shouldCompressMethod.Should().NotBeNull(); - shouldCompressMethod!.ReturnType.Should().Be(typeof(bool)); + shouldCompressMethod!.ReturnType.Should().Be(); 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(); + shouldCompressMethod.GetParameters()[1].ParameterType.Should().Be(); } [Fact] diff --git a/ChatBot.Tests/Services/Interfaces/IOllamaClientTests.cs b/ChatBot.Tests/Services/Interfaces/IOllamaClientTests.cs index c96cf8a..5cef3b7 100644 --- a/ChatBot.Tests/Services/Interfaces/IOllamaClientTests.cs +++ b/ChatBot.Tests/Services/Interfaces/IOllamaClientTests.cs @@ -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(); 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)); + chatAsyncMethod!.ReturnType.Should().Be>(); chatAsyncMethod.GetParameters().Should().HaveCount(1); - chatAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(ChatRequest)); + chatAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); // ListLocalModelsAsync method var listLocalModelsAsyncMethod = methods.FirstOrDefault(m => m.Name == "ListLocalModelsAsync" ); listLocalModelsAsyncMethod.Should().NotBeNull(); - listLocalModelsAsyncMethod!.ReturnType.Should().Be(typeof(Task>)); + listLocalModelsAsyncMethod!.ReturnType.Should().Be>>(); listLocalModelsAsyncMethod.GetParameters().Should().BeEmpty(); } diff --git a/ChatBot.Tests/Services/Interfaces/ISessionStorageTests.cs b/ChatBot.Tests/Services/Interfaces/ISessionStorageTests.cs index 6c482e0..e72a414 100644 --- a/ChatBot.Tests/Services/Interfaces/ISessionStorageTests.cs +++ b/ChatBot.Tests/Services/Interfaces/ISessionStorageTests.cs @@ -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(); 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(); + getOrCreateMethod.GetParameters()[1].ParameterType.Should().Be(); + getOrCreateMethod.GetParameters()[2].ParameterType.Should().Be(); // Get method var getMethod = methods.FirstOrDefault(m => m.Name == "Get"); getMethod.Should().NotBeNull(); - getMethod!.ReturnType.Should().Be(typeof(ChatSession)); + getMethod!.ReturnType.Should().Be(); getMethod.GetParameters().Should().HaveCount(1); - getMethod.GetParameters()[0].ParameterType.Should().Be(typeof(long)); + getMethod.GetParameters()[0].ParameterType.Should().Be(); // Remove method var removeMethod = methods.FirstOrDefault(m => m.Name == "Remove"); removeMethod.Should().NotBeNull(); - removeMethod!.ReturnType.Should().Be(typeof(bool)); + removeMethod!.ReturnType.Should().Be(); removeMethod.GetParameters().Should().HaveCount(1); - removeMethod.GetParameters()[0].ParameterType.Should().Be(typeof(long)); + removeMethod.GetParameters()[0].ParameterType.Should().Be(); // GetActiveSessionsCount method var getActiveSessionsCountMethod = methods.FirstOrDefault(m => m.Name == "GetActiveSessionsCount" ); getActiveSessionsCountMethod.Should().NotBeNull(); - getActiveSessionsCountMethod!.ReturnType.Should().Be(typeof(int)); + getActiveSessionsCountMethod!.ReturnType.Should().Be(); 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(); cleanupOldSessionsMethod.GetParameters().Should().HaveCount(1); - cleanupOldSessionsMethod.GetParameters()[0].ParameterType.Should().Be(typeof(int)); + cleanupOldSessionsMethod.GetParameters()[0].ParameterType.Should().Be(); // SaveSessionAsync method var saveSessionAsyncMethod = methods.FirstOrDefault(m => m.Name == "SaveSessionAsync"); saveSessionAsyncMethod.Should().NotBeNull(); - saveSessionAsyncMethod!.ReturnType.Should().Be(typeof(Task)); + saveSessionAsyncMethod!.ReturnType.Should().Be(); saveSessionAsyncMethod.GetParameters().Should().HaveCount(1); - saveSessionAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(ChatSession)); + saveSessionAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); } [Fact] diff --git a/ChatBot.Tests/Services/Interfaces/ITelegramBotClientWrapperTests.cs b/ChatBot.Tests/Services/Interfaces/ITelegramBotClientWrapperTests.cs index d24bf6c..67d81ec 100644 --- a/ChatBot.Tests/Services/Interfaces/ITelegramBotClientWrapperTests.cs +++ b/ChatBot.Tests/Services/Interfaces/ITelegramBotClientWrapperTests.cs @@ -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)); + getMeAsyncMethod!.ReturnType.Should().Be>(); getMeAsyncMethod.GetParameters().Should().HaveCount(1); - getMeAsyncMethod.GetParameters()[0].ParameterType.Should().Be(typeof(CancellationToken)); + getMeAsyncMethod.GetParameters()[0].ParameterType.Should().Be(); } [Fact] diff --git a/ChatBot.Tests/Services/TelegramBotClientWrapperTests.cs b/ChatBot.Tests/Services/TelegramBotClientWrapperTests.cs index f3b9dbe..6f5fa88 100644 --- a/ChatBot.Tests/Services/TelegramBotClientWrapperTests.cs +++ b/ChatBot.Tests/Services/TelegramBotClientWrapperTests.cs @@ -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)); + method!.ReturnType.Should().Be>(); var parameters = method.GetParameters(); parameters.Should().HaveCount(1); - parameters[0].ParameterType.Should().Be(typeof(CancellationToken)); + parameters[0].ParameterType.Should().Be(); 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(); 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(); } [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)); + interfaceMethods[0].ReturnType.Should().Be>(); var parameters = interfaceMethods[0].GetParameters(); parameters.Should().HaveCount(1); - parameters[0].ParameterType.Should().Be(typeof(CancellationToken)); + parameters[0].ParameterType.Should().Be(); 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)); + returnType.Should().Be>(); var attributes = returnType.GetCustomAttributes(false); attributes.Should().NotBeNull();