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

40 lines
1.6 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();
2023-11-20 13:20:10 +00:00
services.AddScoped(x => Mock.Of<Microsoft.SemanticKernel.AI.TextCompletion.ITextCompletion>());
services.AddScoped(x => Mock.Of<Microsoft.SemanticKernel.AI.ChatCompletion.IChatCompletion>());
services.AddScoped(x => Mock.Of<Microsoft.SemanticKernel.Memory.IMemoryStore>());
services.AddScoped(x => Mock.Of<Microsoft.SemanticKernel.AI.Embeddings.ITextEmbeddingGeneration>());
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
}
}
}