Test frameworks consolidated (#12672)

This commit is contained in:
Davide Giacometti
2021-08-16 15:25:06 +02:00
committed by GitHub
parent c3a51f9227
commit e96c0da265
53 changed files with 1018 additions and 924 deletions

View File

@@ -7,13 +7,13 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using NUnit.Framework;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wox.Infrastructure;
using Wox.Plugin;
namespace Wox.Test
{
[TestFixture]
[TestClass]
public class FuzzyMatcherTest
{
private const string Chrome = "Chrome";
@@ -49,7 +49,7 @@ namespace Wox.Test
return listToReturn;
}
[Test]
[TestMethod]
public void MatchTest()
{
var sources = new List<string>
@@ -80,22 +80,24 @@ namespace Wox.Test
Assert.IsTrue(results[2].Title == "file open in browser-test");
}
[TestCase("Chrome")]
[DataTestMethod]
[DataRow("Chrome")]
public void WhenGivenNotAllCharactersFoundInSearchStringThenShouldReturnZeroScore(string searchString)
{
var compareString = "Can have rum only in my glass";
var matcher = new StringMatcher();
var scoreResult = matcher.FuzzyMatch(searchString, compareString).RawScore;
Assert.True(scoreResult == 0);
Assert.IsTrue(scoreResult == 0);
}
[TestCase("chr")]
[TestCase("chrom")]
[TestCase("chrome")]
[TestCase("cand")]
[TestCase("cpywa")]
[TestCase("ccs")]
[DataTestMethod]
[DataRow("chr")]
[DataRow("chrom")]
[DataRow("chrome")]
[DataRow("cand")]
[DataRow("cpywa")]
[DataRow("ccs")]
public void WhenGivenStringsAndAppliedPrecisionFilteringThenShouldReturnGreaterThanPrecisionScoreResults(string searchTerm)
{
var results = new List<Result>();
@@ -129,7 +131,8 @@ namespace Wox.Test
}
}
[TestCase("vim", "Vim", "ignoreDescription", "ignore.exe", "Vim Diff", "ignoreDescription", "ignore.exe")]
[DataTestMethod]
[DataRow("vim", "Vim", "ignoreDescription", "ignore.exe", "Vim Diff", "ignoreDescription", "ignore.exe")]
public void WhenMultipleResultsExactMatchingResultShouldHaveGreatestScore(string queryString, string firstName, string firstDescription, string firstExecutableName, string secondName, string secondDescription, string secondExecutableName)
{
// Act
@@ -149,16 +152,17 @@ namespace Wox.Test
Assert.IsTrue(firstScore > secondScore);
}
[TestCase("goo", "Google Chrome", StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("chr", "Google Chrome", StringMatcher.SearchPrecisionScore.Low, true)]
[TestCase("chr", "Chrome", StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("chr", "Help cure hope raise on mind entity Chrome", StringMatcher.SearchPrecisionScore.Regular, false)]
[TestCase("chr", "Help cure hope raise on mind entity Chrome", StringMatcher.SearchPrecisionScore.Low, true)]
[TestCase("chr", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Regular, false)]
[TestCase("chr", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.None, true)]
[TestCase("ccs", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Low, true)]
[TestCase("cand", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("cand", "Help cure hope raise on mind entity Chrome", StringMatcher.SearchPrecisionScore.Regular, false)]
[DataTestMethod]
[DataRow("goo", "Google Chrome", StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("chr", "Google Chrome", StringMatcher.SearchPrecisionScore.Low, true)]
[DataRow("chr", "Chrome", StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("chr", "Help cure hope raise on mind entity Chrome", StringMatcher.SearchPrecisionScore.Regular, false)]
[DataRow("chr", "Help cure hope raise on mind entity Chrome", StringMatcher.SearchPrecisionScore.Low, true)]
[DataRow("chr", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Regular, false)]
[DataRow("chr", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.None, true)]
[DataRow("ccs", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Low, true)]
[DataRow("cand", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("cand", "Help cure hope raise on mind entity Chrome", StringMatcher.SearchPrecisionScore.Regular, false)]
public void WhenGivenDesiredPrecisionThenShouldReturnAllResultsGreaterOrEqual(
string queryString,
string compareString,
@@ -185,23 +189,24 @@ namespace Wox.Test
$"{$"Query:{queryString}{Environment.NewLine} "}{$"Compare:{compareString}{Environment.NewLine}"}{$"Raw Score: {matchResult.RawScore}{Environment.NewLine}"}{$"Precision Score: {(int)expectedPrecisionScore}"}");
}
[TestCase("exce", "OverLeaf-Latex: An online LaTeX editor", StringMatcher.SearchPrecisionScore.Regular, false)]
[TestCase("term", "Windows Terminal (Preview)", StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("sql s managa", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, false)]
[TestCase("sql' s manag", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, false)]
[TestCase("sql s manag", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("sql manag", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("sql", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("sql serv", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("sql serv man", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("sql studio", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("mic", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("chr", "Shutdown", StringMatcher.SearchPrecisionScore.Regular, false)]
[TestCase("mssms", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, false)]
[TestCase("chr", "Change settings for text-to-speech and for speech recognition (if installed).", StringMatcher.SearchPrecisionScore.Regular, false)]
[TestCase("ch r", "Change settings for text-to-speech and for speech recognition (if installed).", StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("a test", "This is a test", StringMatcher.SearchPrecisionScore.Regular, true)]
[TestCase("test", "This is a test", StringMatcher.SearchPrecisionScore.Regular, true)]
[DataTestMethod]
[DataRow("exce", "OverLeaf-Latex: An online LaTeX editor", StringMatcher.SearchPrecisionScore.Regular, false)]
[DataRow("term", "Windows Terminal (Preview)", StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("sql s managa", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, false)]
[DataRow("sql' s manag", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, false)]
[DataRow("sql s manag", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("sql manag", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("sql", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("sql serv", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("sql serv man", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("sql studio", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("mic", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("chr", "Shutdown", StringMatcher.SearchPrecisionScore.Regular, false)]
[DataRow("mssms", MicrosoftSqlServerManagementStudio, StringMatcher.SearchPrecisionScore.Regular, false)]
[DataRow("chr", "Change settings for text-to-speech and for speech recognition (if installed).", StringMatcher.SearchPrecisionScore.Regular, false)]
[DataRow("ch r", "Change settings for text-to-speech and for speech recognition (if installed).", StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("a test", "This is a test", StringMatcher.SearchPrecisionScore.Regular, true)]
[DataRow("test", "This is a test", StringMatcher.SearchPrecisionScore.Regular, true)]
public void WhenGivenQueryShouldReturnResultsContainingAllQuerySubstrings(
string queryString,
string compareString,
@@ -228,8 +233,9 @@ namespace Wox.Test
$"{$"Query:{queryString}{Environment.NewLine} "}{$"Compare:{compareString}{Environment.NewLine}"}{$"Raw Score: {matchResult.RawScore}{Environment.NewLine}"}{$"Precision Score: {(int)expectedPrecisionScore}"}");
}
[TestCase("Windows Terminal", "Windows_Terminal", "term")]
[TestCase("Windows Terminal", "WindowsTerminal", "term")]
[DataTestMethod]
[DataRow("Windows Terminal", "Windows_Terminal", "term")]
[DataRow("Windows Terminal", "WindowsTerminal", "term")]
public void FuzzyMatchingScoreShouldBeHigherWhenPreceedingCharacterIsSpace(string firstCompareStr, string secondCompareStr, string query)
{
// Arrange

View File

@@ -2,16 +2,16 @@
// 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;
using PowerLauncher.ViewModel;
namespace Wox.Test
{
[TestFixture]
internal class MainViewModelTest
[TestClass]
public class MainViewModelTest
{
[Test]
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenInputIsNull()
[TestMethod]
public void MainViewModelGetAutoCompleteTextReturnsEmptyStringWhenInputIsNull()
{
// Arrange
int index = 0;
@@ -25,8 +25,8 @@ namespace Wox.Test
Assert.AreEqual(string.Empty, autoCompleteText);
}
[Test]
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenInputIsEmpty()
[TestMethod]
public void MainViewModelGetAutoCompleteTextReturnsEmptyStringWhenInputIsEmpty()
{
// Arrange
int index = 0;
@@ -40,8 +40,8 @@ namespace Wox.Test
Assert.AreEqual(string.Empty, autoCompleteText);
}
[Test]
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenQueryIsNull()
[TestMethod]
public void MainViewModelGetAutoCompleteTextReturnsEmptyStringWhenQueryIsNull()
{
// Arrange
int index = 0;
@@ -55,8 +55,8 @@ namespace Wox.Test
Assert.AreEqual(string.Empty, autoCompleteText);
}
[Test]
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenQueryIsEmpty()
[TestMethod]
public void MainViewModelGetAutoCompleteTextReturnsEmptyStringWhenQueryIsEmpty()
{
// Arrange
int index = 0;
@@ -70,8 +70,8 @@ namespace Wox.Test
Assert.AreEqual(string.Empty, autoCompleteText);
}
[Test]
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenIndexIsNonZero()
[TestMethod]
public void MainViewModelGetAutoCompleteTextReturnsEmptyStringWhenIndexIsNonZero()
{
// Arrange
int index = 2;
@@ -85,8 +85,8 @@ namespace Wox.Test
Assert.AreEqual(string.Empty, autoCompleteText);
}
[Test]
public void MainViewModel_GetAutoCompleteTextReturnsMatchingString_WhenIndexIsZeroAndMatch()
[TestMethod]
public void MainViewModelGetAutoCompleteTextReturnsMatchingStringWhenIndexIsZeroAndMatch()
{
// Arrange
int index = 0;
@@ -101,8 +101,8 @@ namespace Wox.Test
Assert.AreEqual(expectedAutoCompleteText, autoCompleteText);
}
[Test]
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenIndexIsZeroAndNoMatch()
[TestMethod]
public void MainViewModelGetAutoCompleteTextReturnsEmptyStringWhenIndexIsZeroAndNoMatch()
{
// Arrange
int index = 0;
@@ -117,8 +117,8 @@ namespace Wox.Test
Assert.AreEqual(expectedAutoCompleteText, autoCompleteText);
}
[Test]
public void MainViewModel_GetSearchTextReturnsEmptyString_WhenInputIsNull()
[TestMethod]
public void MainViewModelGetSearchTextReturnsEmptyStringWhenInputIsNull()
{
// Arrange
int index = 0;
@@ -132,8 +132,8 @@ namespace Wox.Test
Assert.AreEqual(string.Empty, autoCompleteText);
}
[Test]
public void MainViewModel_GetSearchTextReturnsEmptyString_WhenInputIsEmpty()
[TestMethod]
public void MainViewModelGetSearchTextReturnsEmptyStringWhenInputIsEmpty()
{
// Arrange
int index = 0;
@@ -147,8 +147,8 @@ namespace Wox.Test
Assert.AreEqual(string.Empty, autoCompleteText);
}
[Test]
public void MainViewModel_GetSearchTextReturnsInputString_WhenQueryIsNull()
[TestMethod]
public void MainViewModelGetSearchTextReturnsInputStringWhenQueryIsNull()
{
// Arrange
int index = 0;
@@ -162,8 +162,8 @@ namespace Wox.Test
Assert.AreEqual(input, autoCompleteText);
}
[Test]
public void MainViewModel_GetSearchTextReturnsInputString_WhenQueryIsEmpty()
[TestMethod]
public void MainViewModelGetSearchTextReturnsInputStringWhenQueryIsEmpty()
{
// Arrange
int index = 0;
@@ -177,8 +177,8 @@ namespace Wox.Test
Assert.AreEqual(input, autoCompleteText);
}
[Test]
public void MainViewModel_GetSearchTextReturnsMatchingStringWithCase_WhenIndexIsZeroAndMatch()
[TestMethod]
public void MainViewModelGetSearchTextReturnsMatchingStringWithCaseWhenIndexIsZeroAndMatch()
{
// Arrange
int index = 0;
@@ -193,8 +193,8 @@ namespace Wox.Test
Assert.AreEqual(expectedAutoCompleteText, autoCompleteText);
}
[Test]
public void MainViewModel_GetSearchTextReturnsInput_WhenIndexIsZeroAndNoMatch()
[TestMethod]
public void MainViewModelGetSearchTextReturnsInputWhenIndexIsZeroAndNoMatch()
{
// Arrange
int index = 0;
@@ -208,8 +208,8 @@ namespace Wox.Test
Assert.AreEqual(input, autoCompleteText);
}
[Test]
public void ShouldAutoCompleteTextBeEmpty_ShouldReturnFalse_WhenAutoCompleteTextIsEmpty()
[TestMethod]
public void ShouldAutoCompleteTextBeEmptyShouldReturnFalseWhenAutoCompleteTextIsEmpty()
{
// Arrange
string queryText = "Te";
@@ -222,8 +222,8 @@ namespace Wox.Test
Assert.AreEqual(false, result);
}
[Test]
public void ShouldAutoCompleteTextBeEmpty_ShouldReturnTrue_WhenQueryTextMatchAutoCompleteText()
[TestMethod]
public void ShouldAutoCompleteTextBeEmptyShouldReturnTrueWhenQueryTextMatchAutoCompleteText()
{
// Arrange
string queryText = "Te";
@@ -236,8 +236,8 @@ namespace Wox.Test
Assert.AreEqual(false, result);
}
[Test]
public void ShouldAutoCompleteTextBeEmpty_ShouldReturnTrue_WhenQueryTextIsEmpty()
[TestMethod]
public void ShouldAutoCompleteTextBeEmptyShouldReturnTrueWhenQueryTextIsEmpty()
{
// Arrange
string queryText = string.Empty;
@@ -250,8 +250,8 @@ namespace Wox.Test
Assert.AreEqual(true, result);
}
[Test]
public void ShouldAutoCompleteTextBeEmpty_ShouldReturnTrue_WhenQueryTextDoesNotMatchAutoCompleteText()
[TestMethod]
public void ShouldAutoCompleteTextBeEmptyShouldReturnTrueWhenQueryTextDoesNotMatchAutoCompleteText()
{
// Arrange
string queryText = "TE";

View File

@@ -3,25 +3,26 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using NUnit.Framework;
using PowerLauncher.Plugin;
using Wox.Plugin;
namespace Wox.Test
{
[TestFixture]
[TestClass]
public class PluginManagerTest
{
[TestCase(">", "dummyQueryText", "dummyTitle", "> dummyQueryText")]
[TestCase(">", null, "dummyTitle", "> dummyTitle")]
[TestCase(">", "", "dummyTitle", "> dummyTitle")]
[TestCase("", "dummyQueryText", "dummyTitle", "dummyQueryText")]
[TestCase("", null, "dummyTitle", "dummyTitle")]
[TestCase("", "", "dummyTitle", "dummyTitle")]
[TestCase(null, "dummyQueryText", "dummyTitle", "dummyQueryText")]
[TestCase(null, null, "dummyTitle", "dummyTitle")]
[TestCase(null, "", "dummyTitle", "dummyTitle")]
[DataTestMethod]
[DataRow(">", "dummyQueryText", "dummyTitle", "> dummyQueryText")]
[DataRow(">", null, "dummyTitle", "> dummyTitle")]
[DataRow(">", "", "dummyTitle", "> dummyTitle")]
[DataRow("", "dummyQueryText", "dummyTitle", "dummyQueryText")]
[DataRow("", null, "dummyTitle", "dummyTitle")]
[DataRow("", "", "dummyTitle", "dummyTitle")]
[DataRow(null, "dummyQueryText", "dummyTitle", "dummyQueryText")]
[DataRow(null, null, "dummyTitle", "dummyTitle")]
[DataRow(null, "", "dummyTitle", "dummyTitle")]
public void QueryForPluginSetsActionKeywordWhenQueryTextDisplayIsEmpty(string actionKeyword, string queryTextDisplay, string title, string expectedResult)
{
// Arrange

View File

@@ -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>();

View File

@@ -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));

View File

@@ -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();

View File

@@ -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));
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -5,13 +5,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Collections.Generic;
using NUnit.Framework;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PowerLauncher.Plugin;
using Wox.Plugin;
namespace Wox.Test
{
[TestClass]
public class QueryBuilderTest
{
private static bool AreEqual(Query firstQuery, Query secondQuery)
@@ -22,7 +22,7 @@ namespace Wox.Test
&& firstQuery.RawQuery.Equals(secondQuery.RawQuery, StringComparison.Ordinal);
}
[Test]
[TestMethod]
public void QueryBuilderShouldRemoveExtraSpacesForNonGlobalPlugin()
{
// Arrange
@@ -41,7 +41,7 @@ namespace Wox.Test
Assert.AreEqual("> file.txt file2 file3", searchQuery);
}
[Test]
[TestMethod]
public void QueryBuilderShouldRemoveExtraSpacesForGlobalPlugin()
{
// Arrange
@@ -59,7 +59,7 @@ namespace Wox.Test
Assert.AreEqual("file.txt file2 file3", searchQuery);
}
[Test]
[TestMethod]
public void QueryBuildShouldGenerateSameSearchQueryWithOrWithoutSpaceAfterActionKeyword()
{
// Arrange
@@ -85,7 +85,7 @@ namespace Wox.Test
Assert.IsTrue(firstQuery.ActionKeyword.Equals(secondQuery.ActionKeyword, StringComparison.Ordinal));
}
[Test]
[TestMethod]
public void QueryBuildShouldGenerateCorrectQueryForPluginsWhoseActionKeywordsHaveSamePrefix()
{
// Arrange
@@ -109,7 +109,7 @@ namespace Wox.Test
Assert.IsTrue(AreEqual(secondQuery, new Query(searchQuery, secondPlugin.Metadata.ActionKeyword)));
}
[Test]
[TestMethod]
public void QueryBuilderShouldSetTermsCorrectlyWhenCalled()
{
// Arrange
@@ -134,7 +134,7 @@ namespace Wox.Test
Assert.IsTrue(secondQuery.Terms[0].Equals("efgh", StringComparison.Ordinal) && secondQuery.Terms.Count == 1);
}
[Test]
[TestMethod]
public void QueryBuilderShouldReturnAllPluginsWithTheActionWord()
{
// Arrange

View File

@@ -3,17 +3,17 @@
// See the LICENSE file in the project root for more information.
using System.Windows.Input;
using NUnit.Framework;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PowerLauncher.ViewModel;
using Wox.Plugin;
namespace Wox.Test
{
[TestFixture]
internal class ResultsViewModelTest
[TestClass]
public class ResultsViewModelTest
{
[Test]
public void ContextMenuSelectedIndex_ShouldEqualNoSelectionIndex_WhenInitialized()
[TestMethod]
public void ContextMenuSelectedIndexShouldEqualNoSelectionIndexWhenInitialized()
{
// Arrange
ResultsViewModel rvm = new ResultsViewModel();
@@ -26,8 +26,8 @@ namespace Wox.Test
Assert.AreEqual(ResultViewModel.NoSelectionIndex, selectedItem.ContextMenuSelectedIndex);
}
[Test]
public void SelectNextContextMenuItem_IncrementsContextMenuSelectedIndex_WhenCalled()
[TestMethod]
public void SelectNextContextMenuItemIncrementsContextMenuSelectedIndexWhenCalled()
{
// Arrange
ResultsViewModel rvm = new ResultsViewModel();
@@ -43,8 +43,8 @@ namespace Wox.Test
Assert.AreEqual(0, selectedItem.ContextMenuSelectedIndex);
}
[Test]
public void SelectNextContextMenuItem_DoesnNotIncrementContextMenuSelectedIndex_WhenCalledOnLastItem()
[TestMethod]
public void SelectNextContextMenuItemDoesnNotIncrementContextMenuSelectedIndexWhenCalledOnLastItem()
{
// Arrange
ResultsViewModel rvm = new ResultsViewModel();
@@ -60,8 +60,8 @@ namespace Wox.Test
Assert.AreEqual(0, selectedItem.ContextMenuSelectedIndex);
}
[Test]
public void SelectPreviousContextMenuItem_DecrementsContextMenuSelectedIndex_WhenCalled()
[TestMethod]
public void SelectPreviousContextMenuItemDecrementsContextMenuSelectedIndexWhenCalled()
{
// Arrange
ResultsViewModel rvm = new ResultsViewModel();
@@ -82,8 +82,8 @@ namespace Wox.Test
Assert.AreEqual(1, selectedItem.ContextMenuSelectedIndex);
}
[Test]
public void SelectPreviousContextMenuItem_ResetsContextMenuSelectedIndex_WhenCalledOnFirstItem()
[TestMethod]
public void SelectPreviousContextMenuItemResetsContextMenuSelectedIndexWhenCalledOnFirstItem()
{
// Arrange
ResultsViewModel rvm = new ResultsViewModel();
@@ -100,8 +100,8 @@ namespace Wox.Test
Assert.AreEqual(ResultViewModel.NoSelectionIndex, selectedItem.ContextMenuSelectedIndex);
}
[Test]
public void IsContextMenuItemSelected_ReturnsTrue_WhenContextMenuItemIsSelected()
[TestMethod]
public void IsContextMenuItemSelectedReturnsTrueWhenContextMenuItemIsSelected()
{
// Arrange
ResultsViewModel rvm = new ResultsViewModel();
@@ -118,8 +118,8 @@ namespace Wox.Test
Assert.IsTrue(isContextMenuItemSelected);
}
[Test]
public void IsContextMenuItemSelected_ReturnsFalse_WhenContextMenuItemIsNotSelected()
[TestMethod]
public void IsContextMenuItemSelectedReturnsFalseWhenContextMenuItemIsNotSelected()
{
// Arrange
ResultsViewModel rvm = new ResultsViewModel();

View File

@@ -61,12 +61,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="nunit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.5" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">

View File

@@ -4,13 +4,13 @@
using System.Runtime.CompilerServices;
using System.Windows.Input;
using NUnit.Framework;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PowerLauncher.ViewModel;
using Wox.Plugin;
namespace Wox.Test
{
[TestFixture]
[TestClass]
public class WoxTest
{
// A Dummy class to test that OnPropertyChanged() is called while we set the variable
@@ -44,7 +44,7 @@ namespace Wox.Test
}
}
[Test]
[TestMethod]
public void AnyVariableMustCallOnPropertyChangedWhenSet()
{
// Arrange