added unit test
This commit is contained in:
parent
4489683eeb
commit
f78425cffa
30
tests/UnitTest/MainTest.cs
Normal file
30
tests/UnitTest/MainTest.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using BotSharp.Abstraction.Conversations;
|
||||
using BotSharp.Core.Evaluations;
|
||||
using BotSharp.Plugin.ChatHub.Hooks;
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
[TestClass]
|
||||
public class MainTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestConversationHookProvider()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddSingleton<IConversationHook, EvaluationConversationHook>();
|
||||
services.AddSingleton<IConversationHook, WelcomeHook>();
|
||||
services.AddSingleton<IConversationHook, ChatHubConversationHook>();
|
||||
services.AddSingleton<ConversationHookProvider>();
|
||||
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
var conversationHookProvider = serviceProvider.GetService<ConversationHookProvider>();
|
||||
|
||||
Assert.AreEqual(3, conversationHookProvider.Hooks.Count());
|
||||
|
||||
// ChatHubConversationHook has the top priority
|
||||
Assert.IsInstanceOfType<ChatHubConversationHook>(conversationHookProvider.HooksOrderByPriority.FirstOrDefault());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,10 +13,16 @@
|
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Infrastructure\BotSharp.Abstraction\BotSharp.Abstraction.csproj" />
|
||||
<ProjectReference Include="..\..\src\Infrastructure\BotSharp.Core\BotSharp.Core.csproj" />
|
||||
<ProjectReference Include="..\..\src\Plugins\BotSharp.Plugin.ChatHub\BotSharp.Plugin.ChatHub.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
namespace UnitTest
|
||||
{
|
||||
[TestClass]
|
||||
public class UnitTest1
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestMethod1()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue