From f78425cffab83f0ccd86a034fbfa740bdf6542b5 Mon Sep 17 00:00:00 2001 From: Kerry Jiang Date: Thu, 12 Dec 2024 20:44:26 -0800 Subject: [PATCH] added unit test --- tests/UnitTest/MainTest.cs | 30 ++++++++++++++++++++++++++++++ tests/UnitTest/UnitTest.csproj | 8 +++++++- tests/UnitTest/UnitTest1.cs | 11 ----------- 3 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 tests/UnitTest/MainTest.cs delete mode 100644 tests/UnitTest/UnitTest1.cs diff --git a/tests/UnitTest/MainTest.cs b/tests/UnitTest/MainTest.cs new file mode 100644 index 00000000..2e4c29bf --- /dev/null +++ b/tests/UnitTest/MainTest.cs @@ -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(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + + var serviceProvider = services.BuildServiceProvider(); + var conversationHookProvider = serviceProvider.GetService(); + + Assert.AreEqual(3, conversationHookProvider.Hooks.Count()); + + // ChatHubConversationHook has the top priority + Assert.IsInstanceOfType(conversationHookProvider.HooksOrderByPriority.FirstOrDefault()); + } + } +} \ No newline at end of file diff --git a/tests/UnitTest/UnitTest.csproj b/tests/UnitTest/UnitTest.csproj index be924573..3e1831ae 100644 --- a/tests/UnitTest/UnitTest.csproj +++ b/tests/UnitTest/UnitTest.csproj @@ -13,10 +13,16 @@ + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + + diff --git a/tests/UnitTest/UnitTest1.cs b/tests/UnitTest/UnitTest1.cs deleted file mode 100644 index ab3cd866..00000000 --- a/tests/UnitTest/UnitTest1.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace UnitTest -{ - [TestClass] - public class UnitTest1 - { - [TestMethod] - public void TestMethod1() - { - } - } -} \ No newline at end of file