2020-11-26 03:35:48 -06:00
|
|
|
// 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;
|
|
|
|
|
|
2021-01-08 16:11:30 +01:00
|
|
|
namespace Microsoft.PowerToys.Run.Plugin.System.UnitTests
|
2020-11-26 03:35:48 -06:00
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|