mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
Test frameworks consolidated (#12672)
This commit is contained in:
committed by
GitHub
parent
c3a51f9227
commit
e96c0da265
@@ -4,16 +4,17 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Plugin.Folder;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Test.Plugins
|
||||
{
|
||||
internal class FolderPluginTest
|
||||
[TestClass]
|
||||
public class FolderPluginTest
|
||||
{
|
||||
[Test]
|
||||
public void ContextMenuLoader_ReturnContextMenuForFolderWithOpenInConsole_WhenLoadContextMenusIsCalled()
|
||||
[TestMethod]
|
||||
public void ContextMenuLoaderReturnContextMenuForFolderWithOpenInConsoleWhenLoadContextMenusIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
var mock = new Mock<IPublicAPI>();
|
||||
@@ -31,8 +32,8 @@ namespace Wox.Test.Plugins
|
||||
Assert.AreEqual(Microsoft.Plugin.Folder.Properties.Resources.Microsoft_plugin_folder_open_in_console, contextMenuResults[1].Title);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ContextMenuLoader_ReturnContextMenuForFileWithOpenInConsole_WhenLoadContextMenusIsCalled()
|
||||
[TestMethod]
|
||||
public void ContextMenuLoaderReturnContextMenuForFileWithOpenInConsoleWhenLoadContextMenusIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
var mock = new Mock<IPublicAPI>();
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using NUnit.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Wox.Test.Plugins
|
||||
{
|
||||
[TestFixture]
|
||||
[TestClass]
|
||||
public class PluginInitTest
|
||||
{
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void PublicAPIIsNullTest()
|
||||
{
|
||||
// Assert.Throws(typeof(WoxFatalException), () => PluginManager.Initialize(null));
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Windows;
|
||||
using NUnit.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Test.Plugins
|
||||
{
|
||||
[TestFixture]
|
||||
internal class ResultTest
|
||||
[TestClass]
|
||||
public class ResultTest
|
||||
{
|
||||
[Test]
|
||||
public void Result_UpdatesToolTipVisibilityToVisible_WhenToolTipDataIsSet()
|
||||
[TestMethod]
|
||||
public void ResultUpdatesToolTipVisibilityToVisibleWhenToolTipDataIsSet()
|
||||
{
|
||||
// Arrange
|
||||
Result res = new Result();
|
||||
@@ -25,8 +25,8 @@ namespace Wox.Test.Plugins
|
||||
Assert.AreEqual(Visibility.Visible, res.ToolTipVisibility);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Result_UpdatesToolTipVisibilityToCollapsed_WhenToolTipDataIsNotSet()
|
||||
[TestMethod]
|
||||
public void ResultUpdatesToolTipVisibilityToCollapsedWhenToolTipDataIsNotSet()
|
||||
{
|
||||
// Act
|
||||
Result res = new Result();
|
||||
|
||||
@@ -3,23 +3,23 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Test.Plugins
|
||||
{
|
||||
[TestFixture]
|
||||
internal class ToolTipDataTest
|
||||
[TestClass]
|
||||
public class ToolTipDataTest
|
||||
{
|
||||
[Test]
|
||||
public void Constructor_ThrowsNullArgumentException_WhenToolTipTitleIsNull()
|
||||
[TestMethod]
|
||||
public void ConstructorThrowsNullArgumentExceptionWhenToolTipTitleIsNull()
|
||||
{
|
||||
// Arrange
|
||||
string title = null;
|
||||
string text = "text";
|
||||
|
||||
// Assert
|
||||
var ex = Assert.Throws<ArgumentException>(() => new ToolTipData(title, text));
|
||||
var ex = Assert.ThrowsException<ArgumentException>(() => new ToolTipData(title, text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ using Microsoft.Plugin.Indexer;
|
||||
using Microsoft.Plugin.Indexer.DriveDetection;
|
||||
using Microsoft.Plugin.Indexer.SearchHelper;
|
||||
using Microsoft.Search.Interop;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Test.Plugins
|
||||
{
|
||||
[TestFixture]
|
||||
[TestClass]
|
||||
public class WindowsIndexerTest
|
||||
{
|
||||
private static WindowsSearchAPI GetWindowsSearchAPI()
|
||||
@@ -39,7 +39,7 @@ namespace Wox.Test.Plugins
|
||||
return mockSearchManager.Object;
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void InitQueryHelperShouldInitializeWhenFunctionIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
@@ -56,7 +56,7 @@ namespace Wox.Test.Plugins
|
||||
Assert.AreEqual(maxCount, queryHelper.QueryMaxResults);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void ModifyQueryHelperShouldSetQueryHelperWhenPatternIsAsterisk()
|
||||
{
|
||||
// Arrange
|
||||
@@ -75,7 +75,7 @@ namespace Wox.Test.Plugins
|
||||
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("Contains", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void ModifyQueryHelperShouldSetQueryHelperWhenPatternContainsAsterisk()
|
||||
{
|
||||
// Arrange
|
||||
@@ -94,7 +94,7 @@ namespace Wox.Test.Plugins
|
||||
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("Contains", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void ModifyQueryHelperShouldSetQueryHelperWhenPatternContainsPercent()
|
||||
{
|
||||
// Arrange
|
||||
@@ -113,7 +113,7 @@ namespace Wox.Test.Plugins
|
||||
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("Contains", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void ModifyQueryHelperShouldSetQueryHelperWhenPatternContainsUnderScore()
|
||||
{
|
||||
// Arrange
|
||||
@@ -132,7 +132,7 @@ namespace Wox.Test.Plugins
|
||||
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("Contains", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void ModifyQueryHelperShouldSetQueryHelperWhenPatternContainsQuestionMark()
|
||||
{
|
||||
// Arrange
|
||||
@@ -151,7 +151,7 @@ namespace Wox.Test.Plugins
|
||||
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("Contains", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void ModifyQueryHelperShouldSetQueryHelperWhenPatternDoesNotContainSplSymbols()
|
||||
{
|
||||
// Arrange
|
||||
@@ -170,7 +170,7 @@ namespace Wox.Test.Plugins
|
||||
Assert.IsTrue(queryHelper.QueryWhereRestrictions.Contains("Contains", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void WindowsSearchAPIShouldReturnResultsWhenSearchWasExecuted()
|
||||
{
|
||||
// Arrange
|
||||
@@ -191,7 +191,7 @@ namespace Wox.Test.Plugins
|
||||
Assert.IsTrue(windowsSearchAPIResults.Any(x => x.Title == "file2.txt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void WindowsSearchAPIShouldNotReturnResultsWithNullValueWhenDbResultHasANullColumn()
|
||||
{
|
||||
// Arrange
|
||||
@@ -212,7 +212,7 @@ namespace Wox.Test.Plugins
|
||||
Assert.IsTrue(windowsSearchAPIResults.Any(x => x.Title == "file2.txt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void WindowsSearchAPIShouldRequestNormalRequestWhenDisplayHiddenFilesIsTrue()
|
||||
{
|
||||
ISearchQueryHelper queryHelper;
|
||||
@@ -230,7 +230,7 @@ namespace Wox.Test.Plugins
|
||||
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("AND System.FileAttributes <> SOME BITWISE 2", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void WindowsSearchAPIShouldRequestFilteredRequestWhenDisplayHiddenFilesIsFalse()
|
||||
{
|
||||
ISearchQueryHelper queryHelper;
|
||||
@@ -248,7 +248,7 @@ namespace Wox.Test.Plugins
|
||||
Assert.IsTrue(queryHelper.QueryWhereRestrictions.Contains("AND System.FileAttributes <> SOME BITWISE 2", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void WindowsSearchAPIShouldRequestNormalRequestWhenDisplayHiddenFilesIsTrueAfterRuntimeSwap()
|
||||
{
|
||||
ISearchQueryHelper queryHelper;
|
||||
@@ -269,10 +269,11 @@ namespace Wox.Test.Plugins
|
||||
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("AND System.FileAttributes <> SOME BITWISE 2", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[TestCase("item.exe")]
|
||||
[TestCase("item.bat")]
|
||||
[TestCase("item.appref-ms")]
|
||||
[TestCase("item.lnk")]
|
||||
[DataTestMethod]
|
||||
[DataRow("item.exe")]
|
||||
[DataRow("item.bat")]
|
||||
[DataRow("item.appref-ms")]
|
||||
[DataRow("item.lnk")]
|
||||
public void LoadContextMenusMustLoadAllItemsWhenFileIsAnApp(string path)
|
||||
{
|
||||
// Arrange
|
||||
@@ -297,10 +298,11 @@ namespace Wox.Test.Plugins
|
||||
Assert.AreEqual(Microsoft.Plugin.Indexer.Properties.Resources.Microsoft_plugin_indexer_open_in_console, contextMenuItems[3].Title);
|
||||
}
|
||||
|
||||
[TestCase("item.pdf")]
|
||||
[TestCase("item.xls")]
|
||||
[TestCase("item.ppt")]
|
||||
[TestCase("C:/DummyFile.cs")]
|
||||
[DataTestMethod]
|
||||
[DataRow("item.pdf")]
|
||||
[DataRow("item.xls")]
|
||||
[DataRow("item.ppt")]
|
||||
[DataRow("C:/DummyFile.cs")]
|
||||
public void LoadContextMenusMustNotLoadRunAsAdminWhenFileIsAnNotApp(string path)
|
||||
{
|
||||
// Arrange
|
||||
@@ -324,8 +326,9 @@ namespace Wox.Test.Plugins
|
||||
Assert.AreEqual(Microsoft.Plugin.Indexer.Properties.Resources.Microsoft_plugin_indexer_open_in_console, contextMenuItems[2].Title);
|
||||
}
|
||||
|
||||
[TestCase("C:/DummyFolder")]
|
||||
[TestCase("TestFolder")]
|
||||
[DataTestMethod]
|
||||
[DataRow("C:/DummyFolder")]
|
||||
[DataRow("TestFolder")]
|
||||
public void LoadContextMenusMustNotLoadRunAsAdminAndOpenContainingFolderForFolder(string path)
|
||||
{
|
||||
// Arrange
|
||||
@@ -348,12 +351,13 @@ namespace Wox.Test.Plugins
|
||||
Assert.AreEqual(Microsoft.Plugin.Indexer.Properties.Resources.Microsoft_plugin_indexer_open_in_console, contextMenuItems[1].Title);
|
||||
}
|
||||
|
||||
[TestCase(0, 2, false, ExpectedResult = true)]
|
||||
[TestCase(0, 3, true, ExpectedResult = false)]
|
||||
[TestCase(1, 2, false, ExpectedResult = false)]
|
||||
[TestCase(1, 4, true, ExpectedResult = false)]
|
||||
[TestCase(0, 1, false, ExpectedResult = false)]
|
||||
public bool DriveDetectionMustDisplayWarningWhenEnhancedModeIsOffAndWhenWarningIsNotDisabled(int enhancedModeStatus, int driveCount, bool disableWarningCheckBoxStatus)
|
||||
[DataTestMethod]
|
||||
[DataRow(0, 2, false, true)]
|
||||
[DataRow(0, 3, true, false)]
|
||||
[DataRow(1, 2, false, false)]
|
||||
[DataRow(1, 4, true, false)]
|
||||
[DataRow(0, 1, false, false)]
|
||||
public void DriveDetectionMustDisplayWarningWhenEnhancedModeIsOffAndWhenWarningIsNotDisabled(int enhancedModeStatus, int driveCount, bool disableWarningCheckBoxStatus, bool result)
|
||||
{
|
||||
// Arrange
|
||||
var mockRegistry = new Mock<IRegistryWrapper>();
|
||||
@@ -366,7 +370,7 @@ namespace Wox.Test.Plugins
|
||||
driveDetection.IsDriveDetectionWarningCheckBoxSelected = disableWarningCheckBoxStatus;
|
||||
|
||||
// Act & Assert
|
||||
return driveDetection.DisplayWarning();
|
||||
Assert.AreEqual(driveDetection.DisplayWarning(), result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user