BotSharp/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelPluginTests.cs

44 lines
2.2 KiB
C#
Raw Normal View History

2023-11-13 15:11:49 +00:00
using BotSharp.Abstraction.Conversations;
2023-11-12 14:04:00 +00:00
using BotSharp.Abstraction.MLTasks;
2023-11-20 13:20:10 +00:00
using BotSharp.Abstraction.VectorStorage;
using BotSharp.Plugin.SemanticKernel.UnitTests.Helpers;
2023-11-12 14:04:00 +00:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
2023-11-13 15:11:49 +00:00
using Microsoft.SemanticKernel;
using Moq;
2023-11-12 14:04:00 +00:00
namespace BotSharp.Plugin.SemanticKernel.Tests
{
public class SemanticKernelPluginTests
{
[Fact]
public void TestRegisterDI()
{
var services = new ServiceCollection();
var config = new ConfigurationBuilder().Build();
services.AddSingleton<IConfiguration>(config);
2023-11-12 14:04:00 +00:00
var plugin = new SemanticKernelPlugin();
2024-01-30 11:04:22 +00:00
services.AddScoped(x => Mock.Of<Microsoft.SemanticKernel.TextGeneration.ITextGenerationService>());
services.AddScoped(x => Mock.Of<Microsoft.SemanticKernel.ChatCompletion.IChatCompletionService>());
#pragma warning disable SKEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
2023-11-20 13:20:10 +00:00
services.AddScoped(x => Mock.Of<Microsoft.SemanticKernel.Memory.IMemoryStore>());
2024-01-30 11:04:22 +00:00
#pragma warning restore SKEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
#pragma warning disable SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
services.AddScoped(x => Mock.Of<Microsoft.SemanticKernel.Embeddings.ITextEmbeddingGenerationService>());
#pragma warning restore SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
2023-11-20 13:20:10 +00:00
services.AddScoped(x => Mock.Of<ITokenStatistics>());
2023-11-13 15:11:49 +00:00
2023-11-12 14:04:00 +00:00
plugin.RegisterDI(services, config);
2023-11-20 13:20:10 +00:00
var provider = services.BuildServiceProvider().CreateScope().ServiceProvider;
2023-11-12 14:04:00 +00:00
Assert.NotNull(provider.GetService<ITextCompletion>());
Assert.NotNull(provider.GetService<IChatCompletion>());
2023-11-20 13:20:10 +00:00
Assert.NotNull(provider.GetService<IVectorDb>());
Assert.NotNull(provider.GetService<ITextEmbedding>());
2023-11-12 14:04:00 +00:00
}
}
}