mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
committed by
GitHub
parent
17b40aa10a
commit
abf9287a99
@@ -0,0 +1,67 @@
|
||||
// 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 System.Text;
|
||||
using Mono.Collections.Generic;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Microsoft.PowerToys.Run.Plugin.System.UnitTests
|
||||
{
|
||||
public class ImageTests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
StringMatcher.Instance = new StringMatcher();
|
||||
}
|
||||
|
||||
[TestCase("shutdown", "Images\\shutdown.dark.png")]
|
||||
[TestCase("restart", "Images\\restart.dark.png")]
|
||||
[TestCase("sign out", "Images\\logoff.dark.png")]
|
||||
[TestCase("lock", "Images\\lock.dark.png")]
|
||||
[TestCase("sleep", "Images\\sleep.dark.png")]
|
||||
[TestCase("hibernate", "Images\\sleep.dark.png")]
|
||||
[TestCase("empty recycle", "Images\\recyclebin.dark.png")]
|
||||
public void IconThemeDarkTest(string typedString, string expectedResult)
|
||||
{
|
||||
// Setup
|
||||
Mock<Main> main = new Mock<Main>();
|
||||
main.Object.IconTheme = "dark";
|
||||
string[] terms = { typedString };
|
||||
Query expectedQuery = new Query(typedString, typedString, new ReadOnlyCollection<string>(terms), string.Empty);
|
||||
|
||||
// Act
|
||||
var result = main.Object.Query(expectedQuery).FirstOrDefault().IcoPath;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
|
||||
[TestCase("shutdown", "Images\\shutdown.light.png")]
|
||||
[TestCase("restart", "Images\\restart.light.png")]
|
||||
[TestCase("sign out", "Images\\logoff.light.png")]
|
||||
[TestCase("lock", "Images\\lock.light.png")]
|
||||
[TestCase("sleep", "Images\\sleep.light.png")]
|
||||
[TestCase("hibernate", "Images\\sleep.light.png")]
|
||||
[TestCase("empty recycle", "Images\\recyclebin.light.png")]
|
||||
public void IconThemeLightTest(string typedString, string expectedResult)
|
||||
{
|
||||
// Setup
|
||||
Mock<Main> main = new Mock<Main>();
|
||||
main.Object.IconTheme = "light";
|
||||
string[] terms = { typedString };
|
||||
Query expectedQuery = new Query(typedString, typedString, new ReadOnlyCollection<string>(terms), string.Empty);
|
||||
|
||||
// Act
|
||||
var result = main.Object.Query(expectedQuery).FirstOrDefault().IcoPath;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<Platforms>x64</Platforms>
|
||||
<RootNamespace>Microsoft.PowerToys.Run.Plugin.System.UnitTests</RootNamespace>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Moq" Version="4.14.7" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<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.System\Microsoft.PowerToys.Run.Plugin.System.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="StyleCop.Analyzers">
|
||||
<Version>1.1.118</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
|
||||
<Version>3.3.0</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,43 @@
|
||||
// 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 Mono.Collections.Generic;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Microsoft.PowerToys.Run.Plugin.System.UnitTests
|
||||
{
|
||||
public class QueryTests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
StringMatcher.Instance = new StringMatcher();
|
||||
}
|
||||
|
||||
[TestCase("shutdown", "Shutdown computer")]
|
||||
[TestCase("restart", "Restart computer")]
|
||||
[TestCase("sign out", "Sign out of computer")]
|
||||
[TestCase("lock", "Lock computer")]
|
||||
[TestCase("sleep", "Put computer to sleep")]
|
||||
[TestCase("hibernate", "Hibernate computer")]
|
||||
[TestCase("empty recycle", "Empty Recycle Bin")]
|
||||
public void QueryResults(string typedString, string expectedResult)
|
||||
{
|
||||
// Setup
|
||||
Mock<Main> main = new Mock<Main>();
|
||||
string[] terms = { typedString };
|
||||
Query expectedQuery = new Query(typedString, typedString, new ReadOnlyCollection<string>(terms), string.Empty);
|
||||
|
||||
// Act
|
||||
var result = main.Object.Query(expectedQuery).FirstOrDefault().SubTitle;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user