mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
[PTRun][TimeZone]Fix empty subtiles and missing results (#18632)
* Fix for #16627, Partial fixers for #16695 and #17349 * remove none related PR changes * more PR related fixes
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<RootNamespace>Microsoft.PowerToys.Run.Plugin.TimeZone.UnitTests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.PowerToys.Run.Plugin.TimeZone\Microsoft.PowerToys.Run.Plugin.TimeZone.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\..\..\codeAnalysis\GlobalSuppressions.cs">
|
||||
<Link>GlobalSuppressions.cs</Link>
|
||||
</Compile>
|
||||
<AdditionalFiles Include="..\..\..\..\codeAnalysis\StyleCop.json">
|
||||
<Link>StyleCop.json</Link>
|
||||
</AdditionalFiles>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,55 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Linq;
|
||||
using Microsoft.PowerToys.Run.Plugin.TimeZone.Classes;
|
||||
using Microsoft.PowerToys.Run.Plugin.TimeZone.Helper;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using NLog;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Microsoft.PowerToys.Run.Plugin.TimeZone.UnitTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ResultHelperTest
|
||||
{
|
||||
private TimeZoneList _timeZoneList;
|
||||
private TimeZoneSettings _timeZoneSettings;
|
||||
private string _actionKeyword;
|
||||
|
||||
[TestInitialize]
|
||||
public void SetUp()
|
||||
{
|
||||
_actionKeyword = "&";
|
||||
_timeZoneList = JsonHelper.ReadAllPossibleTimeZones();
|
||||
_timeZoneSettings = new TimeZoneSettings
|
||||
{
|
||||
ShowTimeNames = true,
|
||||
ShowTimeZoneNames = true,
|
||||
};
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow("&MEZ", 1)]
|
||||
[DataRow("&GMT", 1)]
|
||||
|
||||
[DataRow("&Germany", 1)] // https://github.com/microsoft/PowerToys/issues/17349
|
||||
[DataRow("&AWST", 1)] // https://github.com/microsoft/PowerToys/issues/16695
|
||||
[DataRow("&AEDT", 1)] // https://github.com/microsoft/PowerToys/issues/16695
|
||||
[DataRow("&AEST", 1)] // https://github.com/microsoft/PowerToys/issues/16695
|
||||
public void GetResultsTest(string search, int expectedResultCount)
|
||||
{
|
||||
var query = new Query(search, _actionKeyword);
|
||||
var results = ResultHelper.GetResults(_timeZoneList.TimeZones, _timeZoneSettings, query, string.Empty);
|
||||
|
||||
Assert.AreEqual(results.Count(), expectedResultCount);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
Assert.AreEqual(!result.Title.Contains("UTC"), _timeZoneSettings.ShowTimeZoneNames);
|
||||
Assert.IsFalse(string.IsNullOrWhiteSpace(result.SubTitle));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user