diff --git a/Community.PowerToys.Run.Plugin.YandexGPT.UnitTests/Community.PowerToys.Run.Plugin.YandexGPT.UnitTests.csproj b/Community.PowerToys.Run.Plugin.YandexGPT.UnitTests/Community.PowerToys.Run.Plugin.YandexGPT.UnitTests.csproj
new file mode 100644
index 0000000..bd7f15a
--- /dev/null
+++ b/Community.PowerToys.Run.Plugin.YandexGPT.UnitTests/Community.PowerToys.Run.Plugin.YandexGPT.UnitTests.csproj
@@ -0,0 +1,32 @@
+
+
+
+
+ net9.0-windows
+ x64;ARM64
+ $(Platform)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Community.PowerToys.Run.Plugin.YandexGPT.UnitTests/MainTests.cs b/Community.PowerToys.Run.Plugin.YandexGPT.UnitTests/MainTests.cs
new file mode 100644
index 0000000..6dfef73
--- /dev/null
+++ b/Community.PowerToys.Run.Plugin.YandexGPT.UnitTests/MainTests.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Community.PowerToys.Run.Plugin.YandexGPT.UnitTests;
+
+[TestClass]
+public class MainTests
+{
+ private Main _subject = null!;
+
+ [TestInitialize]
+ public void TestInitialize()
+ {
+ _subject = new Main();
+ }
+
+ [TestMethod]
+ public void Query_should_calculate_the_number_of_words()
+ {
+ var results = _subject.Query(new(""),true);
+ Assert.AreEqual("Words: 0", results[0].Title);
+
+ results = _subject.Query(new("Hello World"), true);
+ Assert.AreEqual("Words: 2", results[0].Title);
+ }
+
+ [TestMethod]
+ public void Query_should_calculate_the_number_of_characters()
+ {
+ var results = _subject.Query(new(""),true);
+ Assert.AreEqual("Characters: 0", results[1].Title);
+
+ results = _subject.Query(new("Hello World"), true);
+ Assert.AreEqual("Characters: 10", results[1].Title);
+ }
+
+ [TestMethod]
+ public void LoadContextMenus_should_return_buttons_for_words_result()
+ {
+ var results = _subject.LoadContextMenus(new() { ContextData = (2, TimeSpan.FromSeconds(3)) });
+ Assert.AreEqual(2, results.Count);
+ Assert.AreEqual("Copy (Enter)", results[0].Title);
+ Assert.AreEqual("Copy time (Ctrl+Enter)", results[1].Title);
+ }
+
+ [TestMethod]
+ public void LoadContextMenus_should_return_button_for_characters_result()
+ {
+ var results = _subject.LoadContextMenus(new() { ContextData = 10 });
+ Assert.AreEqual(1, results.Count);
+ Assert.AreEqual("Copy (Enter)", results[0].Title);
+ }
+
+ [TestMethod]
+ public void AdditionalOptions_should_return_option_for_CountSpaces()
+ {
+ var options = _subject.AdditionalOptions;
+ Assert.AreEqual(1, options.Count());
+ Assert.AreEqual("CountSpaces", options.ElementAt(0).Key);
+ Assert.AreEqual(false, options.ElementAt(0).Value);
+ }
+
+ [TestMethod]
+ public void UpdateSettings_should_set_CountSpaces()
+ {
+ _subject.UpdateSettings(new() { AdditionalOptions = [new() { Key = "Token", Value = true }] });
+
+ var results = _subject.Query(new("Hello World"), true);
+ Assert.AreEqual("Characters: 11", results[1].Title);
+ }
+}
\ No newline at end of file
diff --git a/Community.PowerToys.Run.Plugin.YandexGPT/Community.PowerToys.Run.Plugin.YandexGPT.csproj b/Community.PowerToys.Run.Plugin.YandexGPT/Community.PowerToys.Run.Plugin.YandexGPT.csproj
index 9b05b5d..08e6c66 100644
--- a/Community.PowerToys.Run.Plugin.YandexGPT/Community.PowerToys.Run.Plugin.YandexGPT.csproj
+++ b/Community.PowerToys.Run.Plugin.YandexGPT/Community.PowerToys.Run.Plugin.YandexGPT.csproj
@@ -1,7 +1,7 @@
- net8.0-windows
+ net9.0-windows
x64;ARM64
$(Platform)
true
diff --git a/Community.PowerToys.Run.Plugin.YandexGPT/Main.cs b/Community.PowerToys.Run.Plugin.YandexGPT/Main.cs
index 8f22f94..c393d71 100644
--- a/Community.PowerToys.Run.Plugin.YandexGPT/Main.cs
+++ b/Community.PowerToys.Run.Plugin.YandexGPT/Main.cs
@@ -7,7 +7,7 @@ using Wox.Plugin.Logger;
namespace Community.PowerToys.Run.Plugin.YandexGPT;
-public class Main : IPlugin, IContextMenu, ISettingProvider, IDisposable
+public class Main : IDelayedExecutionPlugin, IContextMenu, ISettingProvider, IDisposable
{
#region Plugin Info
public static string PluginId => "C2218AB0D86F4345B55C60F9418A811C";
@@ -40,16 +40,21 @@ public class Main : IPlugin, IContextMenu, ISettingProvider, IDisposable
//UpdateIconPath(Context.API.GetCurrentTheme());
}
- public List Query(Query query)
+ public List Query(Query query, bool delayedExecution)
{
Log.Info("Query: " + query.Search, GetType());
+
+ if (query.ActionKeyword != Token)
+ return [];
+
+ var search = query.Search;
return [
new()
{
QueryTextDisplay = query.Search,
IcoPath = IconPath,
- Title = $"YandexGPT: Чет такое",
+ Title = $"YandexGPT: Чет такое {search}",
SubTitle = $"Ответ: иди туда!",
ToolTipData = new ToolTipData("Ответы", $"Тут ответ\nИ тут ответ"),
ContextData = Token,
diff --git a/Community.PowerToys.Run.Plugin.YandexGPT/plugin.json b/Community.PowerToys.Run.Plugin.YandexGPT/plugin.json
index 2ed6e54..a4df6f3 100644
--- a/Community.PowerToys.Run.Plugin.YandexGPT/plugin.json
+++ b/Community.PowerToys.Run.Plugin.YandexGPT/plugin.json
@@ -2,7 +2,7 @@
"ID": "C2218AB0D86F4345B55C60F9418A811C",
"ActionKeyword": "YandexGPT",
"IsGlobal": false,
- "Name": "YandexGPT",
+ "Name": "Yandex GPT",
"Author": "MikhailRaw",
"Version": "1.0.0",
"Language": "csharp",
diff --git a/PowerToys.Run.YandexGPT.sln b/PowerToys.Run.YandexGPT.sln
index dc800ac..1779cb7 100644
--- a/PowerToys.Run.YandexGPT.sln
+++ b/PowerToys.Run.YandexGPT.sln
@@ -7,6 +7,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Items", "Items", "{4A6F7084
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Community.PowerToys.Run.Plugin.YandexGPT", "Community.PowerToys.Run.Plugin.YandexGPT\Community.PowerToys.Run.Plugin.YandexGPT.csproj", "{B65D8913-4679-46A0-84EA-DF11C641DDF5}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Community.PowerToys.Run.Plugin.YandexGPT.UnitTests", "Community.PowerToys.Run.Plugin.YandexGPT.UnitTests\Community.PowerToys.Run.Plugin.YandexGPT.UnitTests.csproj", "{93DA4312-9C61-4291-8746-C20907616752}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -17,5 +19,9 @@ Global
{B65D8913-4679-46A0-84EA-DF11C641DDF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B65D8913-4679-46A0-84EA-DF11C641DDF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B65D8913-4679-46A0-84EA-DF11C641DDF5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {93DA4312-9C61-4291-8746-C20907616752}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {93DA4312-9C61-4291-8746-C20907616752}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {93DA4312-9C61-4291-8746-C20907616752}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {93DA4312-9C61-4291-8746-C20907616752}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/readme.md b/readme.md
index 4ed8eaf..fad3661 100644
Binary files a/readme.md and b/readme.md differ