forked from microsoft/PowerToys
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryTests.cs
More file actions
95 lines (80 loc) · 3.21 KB
/
QueryTests.cs
File metadata and controls
95 lines (80 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// 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;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Wox.Infrastructure;
using Wox.Plugin;
namespace Microsoft.PowerToys.Run.Plugin.System.UnitTests
{
[TestClass]
public class QueryTests
{
[TestInitialize]
public void Setup()
{
StringMatcher.Instance = new StringMatcher();
}
[DataTestMethod]
[DataRow("shutdown", "Shutdown computer")]
[DataRow("restart", "Restart computer")]
[DataRow("sign out", "Sign out of computer")]
[DataRow("lock", "Lock computer")]
[DataRow("sleep", "Put computer to sleep")]
[DataRow("hibernate", "Hibernate computer")]
[DataRow("recycle b", "Open the Recycle Bin")]
[DataRow("empty recycle", "Open the Recycle Bin")]
public void EnvironmentIndependentQueryResults(string typedString, string expectedResult)
{
// Setup
Mock<Main> main = new Mock<Main>();
Query expectedQuery = new Query(typedString);
// Act
var result = main.Object.Query(expectedQuery).FirstOrDefault().SubTitle;
// Assert
Assert.IsTrue(result.StartsWith(expectedResult, StringComparison.OrdinalIgnoreCase));
}
[DataTestMethod]
[DataRow("ip", "IPv4 address of")]
[DataRow("address", "IPv4 address of")] // searching for address should show ipv4 first
[DataRow("ip v4", "IPv4 address of")]
[DataRow("ip v6", "IPv6 address of")]
[DataRow("mac addr", "MAC address of")]
public void DelayedQueryResults(string typedString, string expectedResult)
{
// Setup
Mock<Main> main = new Mock<Main>();
Query expectedQuery = new Query(typedString);
// Act
var result = main.Object.Query(expectedQuery, true).FirstOrDefault().SubTitle;
// Assert
Assert.IsTrue(result.StartsWith(expectedResult, StringComparison.OrdinalIgnoreCase));
}
[TestMethod]
public void UefiCommandIsAvailableOnUefiSystems()
{
// Setup
Mock<Main> main = new Mock<Main>();
main.Object.IsBootedInUefiMode = true; // Simulate system with UEFI.
Query expectedQuery = new Query("uefi firm");
// Act
var result = main.Object.Query(expectedQuery).FirstOrDefault().SubTitle;
// Assert
Assert.AreEqual("Reboot computer into UEFI firmware settings (Requires administrative permissions.)", result);
}
[TestMethod]
public void UefiCommandIsNotAvailableOnSystemsWithoutUefi()
{
// Setup
Mock<Main> main = new Mock<Main>();
main.Object.IsBootedInUefiMode = false; // Simulate system without UEFI.
Query expectedQuery = new Query("uefi firm");
// Act
var result = main.Object.Query(expectedQuery).FirstOrDefault();
// Assert
Assert.IsNull(result);
}
}
}