ImageTests.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using System.Linq;
 6  
 7  using Microsoft.VisualStudio.TestTools.UnitTesting;
 8  using Moq;
 9  using Wox.Infrastructure;
10  using Wox.Plugin;
11  
12  namespace Microsoft.PowerToys.Run.Plugin.System.UnitTests
13  {
14      [TestClass]
15      public class ImageTests
16      {
17          [TestInitialize]
18          public void Setup()
19          {
20              StringMatcher.Instance = new StringMatcher();
21          }
22  
23          [DataTestMethod]
24          [DataRow("shutdown", "Images\\shutdown.dark.png")]
25          [DataRow("restart", "Images\\restart.dark.png")]
26          [DataRow("sign out", "Images\\logoff.dark.png")]
27          [DataRow("lock", "Images\\lock.dark.png")]
28          [DataRow("sleep", "Images\\sleep.dark.png")]
29          [DataRow("hibernate", "Images\\sleep.dark.png")]
30          [DataRow("recycle bin", "Images\\recyclebin.dark.png")]
31          [DataRow("uefi firmware settings", "Images\\firmwareSettings.dark.png")]
32          [DataRow("ip v4 addr", "Images\\networkAdapter.dark.png", true)]
33          [DataRow("ip v6 addr", "Images\\networkAdapter.dark.png", true)]
34          [DataRow("mac addr", "Images\\networkAdapter.dark.png", true)]
35          public void IconThemeDarkTest(string typedString, string expectedResult, bool isDelayed = default)
36          {
37              // Setup
38              Mock<Main> main = new Mock<Main>();
39              main.Object.IconTheme = "dark";
40              main.Object.IsBootedInUefiMode = true; // Set to true that we can test, regardless of the environment we run on.
41              Query expectedQuery = new Query(typedString);
42  
43              // Act
44              var result = !isDelayed ? main.Object.Query(expectedQuery).FirstOrDefault().IcoPath : main.Object.Query(expectedQuery, true).FirstOrDefault().IcoPath;
45  
46              // Assert
47              Assert.AreEqual(expectedResult, result);
48          }
49  
50          [DataTestMethod]
51          [DataRow("shutdown", "Images\\shutdown.light.png")]
52          [DataRow("restart", "Images\\restart.light.png")]
53          [DataRow("sign out", "Images\\logoff.light.png")]
54          [DataRow("lock", "Images\\lock.light.png")]
55          [DataRow("sleep", "Images\\sleep.light.png")]
56          [DataRow("hibernate", "Images\\sleep.light.png")]
57          [DataRow("recycle bin", "Images\\recyclebin.light.png")]
58          [DataRow("uefi firmware settings", "Images\\firmwareSettings.light.png")]
59          [DataRow("ipv4 addr", "Images\\networkAdapter.light.png", true)]
60          [DataRow("ipv6 addr", "Images\\networkAdapter.light.png", true)]
61          [DataRow("mac addr", "Images\\networkAdapter.light.png", true)]
62          public void IconThemeLightTest(string typedString, string expectedResult, bool isDelayed = default)
63          {
64              // Setup
65              Mock<Main> main = new Mock<Main>();
66              main.Object.IconTheme = "light";
67              main.Object.IsBootedInUefiMode = true; // Set to true that we can test, regardless of the environment we run on.
68              Query expectedQuery = new Query(typedString);
69  
70              // Act
71              var result = !isDelayed ? main.Object.Query(expectedQuery).FirstOrDefault().IcoPath : main.Object.Query(expectedQuery, true).FirstOrDefault().IcoPath;
72  
73              // Assert
74              Assert.AreEqual(expectedResult, result);
75          }
76      }
77  }