Added tests template
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0-windows</TargetFramework>
|
||||
<Platforms>x64;ARM64</Platforms>
|
||||
<PlatformTarget>$(Platform)</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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="NLog" Version="5.0.4" />
|
||||
<PackageReference Include="System.IO.Abstractions" Version="17.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Community.PowerToys.Run.Plugin.YandexGPT\Community.PowerToys.Run.Plugin.YandexGPT.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Platform)' == 'x64'">
|
||||
<Reference Include="..\libs\x64\Wox.Plugin.dll" />
|
||||
<Reference Include="..\libs\x64\PowerToys.Settings.UI.Lib.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Platform)' == 'ARM64'">
|
||||
<Reference Include="..\libs\ARM64\Wox.Plugin.dll" />
|
||||
<Reference Include="..\libs\ARM64\PowerToys.Settings.UI.Lib.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user