mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-24 04:12:32 +08:00
Getting remaining Tests on stylecop (#5846)
This commit is contained in:
parent
7bfd0823db
commit
082a78bd92
@ -33,7 +33,7 @@ namespace Wox.Test
|
||||
UninstallOrChangeProgramsOnYourComputer,
|
||||
"Add, change, and manage fonts on your computer",
|
||||
LastIsChrome,
|
||||
OneOneOneOne
|
||||
OneOneOneOne,
|
||||
};
|
||||
|
||||
public List<int> GetPrecisionScores()
|
||||
@ -57,7 +57,7 @@ namespace Wox.Test
|
||||
"Install Package",
|
||||
"add new bsd",
|
||||
"Inste",
|
||||
"aac"
|
||||
"aac",
|
||||
};
|
||||
|
||||
var results = new List<Result>();
|
||||
@ -67,7 +67,7 @@ namespace Wox.Test
|
||||
results.Add(new Result
|
||||
{
|
||||
Title = str,
|
||||
Score = matcher.FuzzyMatch("inst", str).RawScore
|
||||
Score = matcher.FuzzyMatch("inst", str).RawScore,
|
||||
});
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ namespace Wox.Test
|
||||
results.Add(new Result
|
||||
{
|
||||
Title = str,
|
||||
Score = matcher.FuzzyMatch(searchTerm, str).Score
|
||||
Score = matcher.FuzzyMatch(searchTerm, str).Score,
|
||||
});
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ namespace Wox.Test
|
||||
{
|
||||
var filteredResult = results.Where(result => result.Score >= precisionScore).Select(result => result).OrderByDescending(x => x.Score).ToList();
|
||||
|
||||
Debug.WriteLine("");
|
||||
Debug.WriteLine(string.Empty);
|
||||
Debug.WriteLine("###############################################");
|
||||
Debug.WriteLine("SEARCHTERM: " + searchTerm + ", GreaterThanSearchPrecisionScore: " + precisionScore);
|
||||
foreach (var item in filteredResult)
|
||||
@ -121,7 +121,7 @@ namespace Wox.Test
|
||||
}
|
||||
|
||||
Debug.WriteLine("###############################################");
|
||||
Debug.WriteLine("");
|
||||
Debug.WriteLine(string.Empty);
|
||||
|
||||
Assert.IsFalse(filteredResult.Any(x => x.Score < precisionScore));
|
||||
}
|
||||
@ -169,19 +169,18 @@ namespace Wox.Test
|
||||
// Given
|
||||
var matchResult = matcher.FuzzyMatch(queryString, compareString);
|
||||
|
||||
Debug.WriteLine("");
|
||||
Debug.WriteLine(string.Empty);
|
||||
Debug.WriteLine("###############################################");
|
||||
Debug.WriteLine($"QueryString: {queryString} CompareString: {compareString}");
|
||||
Debug.WriteLine($"RAW SCORE: {matchResult.RawScore.ToString()}, PrecisionLevelSetAt: {expectedPrecisionScore} ({(int)expectedPrecisionScore})");
|
||||
Debug.WriteLine($"RAW SCORE: {matchResult.RawScore}, PrecisionLevelSetAt: {expectedPrecisionScore} ({(int)expectedPrecisionScore})");
|
||||
Debug.WriteLine("###############################################");
|
||||
Debug.WriteLine("");
|
||||
Debug.WriteLine(string.Empty);
|
||||
|
||||
// Should
|
||||
Assert.AreEqual(expectedPrecisionResult, matchResult.IsSearchPrecisionScoreMet(),
|
||||
$"Query:{queryString}{Environment.NewLine} " +
|
||||
$"Compare:{compareString}{Environment.NewLine}" +
|
||||
$"Raw Score: {matchResult.RawScore}{Environment.NewLine}" +
|
||||
$"Precision Score: {(int)expectedPrecisionScore}");
|
||||
Assert.AreEqual(
|
||||
expectedPrecisionResult,
|
||||
matchResult.IsSearchPrecisionScoreMet(),
|
||||
$"{$"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)]
|
||||
@ -213,19 +212,18 @@ namespace Wox.Test
|
||||
// Given
|
||||
var matchResult = matcher.FuzzyMatch(queryString, compareString);
|
||||
|
||||
Debug.WriteLine("");
|
||||
Debug.WriteLine(string.Empty);
|
||||
Debug.WriteLine("###############################################");
|
||||
Debug.WriteLine($"QueryString: {queryString} CompareString: {compareString}");
|
||||
Debug.WriteLine($"RAW SCORE: {matchResult.RawScore.ToString()}, PrecisionLevelSetAt: {expectedPrecisionScore} ({(int)expectedPrecisionScore})");
|
||||
Debug.WriteLine($"RAW SCORE: {matchResult.RawScore}, PrecisionLevelSetAt: {expectedPrecisionScore} ({(int)expectedPrecisionScore})");
|
||||
Debug.WriteLine("###############################################");
|
||||
Debug.WriteLine("");
|
||||
Debug.WriteLine(string.Empty);
|
||||
|
||||
// Should
|
||||
Assert.AreEqual(expectedPrecisionResult, matchResult.IsSearchPrecisionScoreMet(),
|
||||
$"Query:{queryString}{Environment.NewLine} " +
|
||||
$"Compare:{compareString}{Environment.NewLine}" +
|
||||
$"Raw Score: {matchResult.RawScore}{Environment.NewLine}" +
|
||||
$"Precision Score: {(int)expectedPrecisionScore}");
|
||||
Assert.AreEqual(
|
||||
expectedPrecisionResult,
|
||||
matchResult.IsSearchPrecisionScoreMet(),
|
||||
$"{$"Query:{queryString}{Environment.NewLine} "}{$"Compare:{compareString}{Environment.NewLine}"}{$"Raw Score: {matchResult.RawScore}{Environment.NewLine}"}{$"Precision Score: {(int)expectedPrecisionScore}"}");
|
||||
}
|
||||
|
||||
[TestCase("Windows Terminal", "Windows_Terminal", "term")]
|
||||
|
@ -3,16 +3,12 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Wox.Plugin;
|
||||
using PowerLauncher.ViewModel;
|
||||
|
||||
namespace Wox.Test
|
||||
{
|
||||
[TestFixture]
|
||||
class MainViewModelTest
|
||||
internal class MainViewModelTest
|
||||
{
|
||||
[Test]
|
||||
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenInputIsNull()
|
||||
@ -20,7 +16,7 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 0;
|
||||
string input = null;
|
||||
String query = "M";
|
||||
string query = "M";
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query);
|
||||
@ -35,7 +31,7 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 0;
|
||||
string input = string.Empty;
|
||||
String query = "M";
|
||||
string query = "M";
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query);
|
||||
@ -50,7 +46,7 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 0;
|
||||
string input = "M";
|
||||
String query = null;
|
||||
string query = null;
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query);
|
||||
@ -65,7 +61,7 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 0;
|
||||
string input = "M";
|
||||
String query = string.Empty;
|
||||
string query = string.Empty;
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query);
|
||||
@ -80,7 +76,7 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 2;
|
||||
string input = "Visual";
|
||||
String query = "Vis";
|
||||
string query = "Vis";
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query);
|
||||
@ -95,14 +91,14 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 0;
|
||||
string input = "VISUAL";
|
||||
String query = "VIs";
|
||||
string ExpectedAutoCompleteText = "VIsUAL";
|
||||
string query = "VIs";
|
||||
string expectedAutoCompleteText = "VIsUAL";
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(autoCompleteText, ExpectedAutoCompleteText);
|
||||
Assert.AreEqual(autoCompleteText, expectedAutoCompleteText);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -111,14 +107,14 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 0;
|
||||
string input = "VISUAL";
|
||||
String query = "Vim";
|
||||
string ExpectedAutoCompleteText = string.Empty;
|
||||
string query = "Vim";
|
||||
string expectedAutoCompleteText = string.Empty;
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(autoCompleteText, ExpectedAutoCompleteText);
|
||||
Assert.AreEqual(autoCompleteText, expectedAutoCompleteText);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -127,7 +123,7 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 0;
|
||||
string input = null;
|
||||
String query = "M";
|
||||
string query = "M";
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetSearchText(index, input, query);
|
||||
@ -142,7 +138,7 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 0;
|
||||
string input = string.Empty;
|
||||
String query = "M";
|
||||
string query = "M";
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetSearchText(index, input, query);
|
||||
@ -157,7 +153,7 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 0;
|
||||
string input = "Visual";
|
||||
String query = null;
|
||||
string query = null;
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetSearchText(index, input, query);
|
||||
@ -172,7 +168,7 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 0;
|
||||
string input = "Visual";
|
||||
String query = string.Empty;
|
||||
string query = string.Empty;
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetSearchText(index, input, query);
|
||||
@ -187,14 +183,14 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 0;
|
||||
string input = "VISUAL";
|
||||
String query = "VIs";
|
||||
string ExpectedAutoCompleteText = "VIsUAL";
|
||||
string query = "VIs";
|
||||
string expectedAutoCompleteText = "VIsUAL";
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetSearchText(index, input, query);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(autoCompleteText, ExpectedAutoCompleteText);
|
||||
Assert.AreEqual(autoCompleteText, expectedAutoCompleteText);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -203,7 +199,7 @@ namespace Wox.Test
|
||||
// Arrange
|
||||
int index = 0;
|
||||
string input = "VISUAL";
|
||||
String query = "Vim";
|
||||
string query = "Vim";
|
||||
|
||||
// Act
|
||||
string autoCompleteText = MainViewModel.GetSearchText(index, input, query);
|
||||
|
@ -2,17 +2,15 @@
|
||||
// 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.Collections.Generic;
|
||||
using Microsoft.Plugin.Folder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Wox.Plugin;
|
||||
using Microsoft.Plugin.Folder;
|
||||
|
||||
namespace Wox.Test.Plugins
|
||||
{
|
||||
class FolderPluginTest
|
||||
internal class FolderPluginTest
|
||||
{
|
||||
[Test]
|
||||
public void ContextMenuLoader_ReturnContextMenuForFolderWithOpenInConsole_WhenLoadContextMenusIsCalled()
|
||||
|
@ -3,8 +3,6 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using NUnit.Framework;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Infrastructure.Exception;
|
||||
|
||||
namespace Wox.Test.Plugins
|
||||
{
|
||||
|
@ -2,17 +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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using NUnit.Framework;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Test.Plugins
|
||||
{
|
||||
[TestFixture]
|
||||
class ResultTest
|
||||
internal class ResultTest
|
||||
{
|
||||
[Test]
|
||||
public void Result_UpdatesToolTipVisibilityToVisible_WhenToolTipDataIsSet()
|
||||
|
@ -2,16 +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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Test.Plugins
|
||||
{
|
||||
[TestFixture]
|
||||
class ToolTipDataTest
|
||||
internal class ToolTipDataTest
|
||||
{
|
||||
[Test]
|
||||
public void Constructor_ThrowsNullArgumentException_WhenToolTipTitleIsNull()
|
||||
|
@ -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 System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Search.Interop;
|
||||
using Microsoft.Plugin.Indexer.SearchHelper;
|
||||
using Microsoft.Plugin.Indexer;
|
||||
using Moq;
|
||||
using Wox.Plugin;
|
||||
using System.Linq;
|
||||
using Microsoft.Plugin.Indexer;
|
||||
using Microsoft.Plugin.Indexer.DriveDetection;
|
||||
using Microsoft.Plugin.Indexer.SearchHelper;
|
||||
using Microsoft.Search.Interop;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Test.Plugins
|
||||
{
|
||||
@ -30,7 +30,7 @@ namespace Wox.Test.Plugins
|
||||
{
|
||||
// Arrange
|
||||
int maxCount = 10;
|
||||
WindowsSearchAPI _api = GetWindowsSearchAPI();
|
||||
WindowsSearchAPI api = GetWindowsSearchAPI();
|
||||
ISearchQueryHelper queryHelper = null;
|
||||
|
||||
// Act
|
||||
@ -46,8 +46,8 @@ namespace Wox.Test.Plugins
|
||||
{
|
||||
// Arrange
|
||||
ISearchQueryHelper queryHelper;
|
||||
String pattern = "*";
|
||||
WindowsSearchAPI _api = GetWindowsSearchAPI();
|
||||
string pattern = "*";
|
||||
WindowsSearchAPI api = GetWindowsSearchAPI();
|
||||
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10);
|
||||
|
||||
// Act
|
||||
@ -63,8 +63,8 @@ namespace Wox.Test.Plugins
|
||||
{
|
||||
// Arrange
|
||||
ISearchQueryHelper queryHelper;
|
||||
String pattern = "tt*^&)";
|
||||
WindowsSearchAPI _api = GetWindowsSearchAPI();
|
||||
string pattern = "tt*^&)";
|
||||
WindowsSearchAPI api = GetWindowsSearchAPI();
|
||||
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10);
|
||||
|
||||
// Act
|
||||
@ -80,8 +80,8 @@ namespace Wox.Test.Plugins
|
||||
{
|
||||
// Arrange
|
||||
ISearchQueryHelper queryHelper;
|
||||
String pattern = "tt%^&)";
|
||||
WindowsSearchAPI _api = GetWindowsSearchAPI();
|
||||
string pattern = "tt%^&)";
|
||||
WindowsSearchAPI api = GetWindowsSearchAPI();
|
||||
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10);
|
||||
|
||||
// Act
|
||||
@ -97,8 +97,8 @@ namespace Wox.Test.Plugins
|
||||
{
|
||||
// Arrange
|
||||
ISearchQueryHelper queryHelper;
|
||||
String pattern = "tt_^&)";
|
||||
WindowsSearchAPI _api = GetWindowsSearchAPI();
|
||||
string pattern = "tt_^&)";
|
||||
WindowsSearchAPI api = GetWindowsSearchAPI();
|
||||
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10);
|
||||
|
||||
// Act
|
||||
@ -114,8 +114,8 @@ namespace Wox.Test.Plugins
|
||||
{
|
||||
// Arrange
|
||||
ISearchQueryHelper queryHelper;
|
||||
String pattern = "tt?^&)";
|
||||
WindowsSearchAPI _api = GetWindowsSearchAPI();
|
||||
string pattern = "tt?^&)";
|
||||
WindowsSearchAPI api = GetWindowsSearchAPI();
|
||||
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10);
|
||||
|
||||
// Act
|
||||
@ -131,8 +131,8 @@ namespace Wox.Test.Plugins
|
||||
{
|
||||
// Arrange
|
||||
ISearchQueryHelper queryHelper;
|
||||
String pattern = "tt^&)bc";
|
||||
WindowsSearchAPI _api = GetWindowsSearchAPI();
|
||||
string pattern = "tt^&)bc";
|
||||
WindowsSearchAPI api = GetWindowsSearchAPI();
|
||||
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10);
|
||||
|
||||
// Act
|
||||
@ -148,10 +148,10 @@ namespace Wox.Test.Plugins
|
||||
{
|
||||
// Arrange
|
||||
OleDBSearch oleDbSearch = new OleDBSearch();
|
||||
WindowsSearchAPI _api = new WindowsSearchAPI(oleDbSearch);
|
||||
WindowsSearchAPI api = new WindowsSearchAPI(oleDbSearch);
|
||||
|
||||
// Act
|
||||
_api.Search("FilePath");
|
||||
api.Search("FilePath");
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(oleDbSearch.HaveAllDisposableItemsBeenDisposed());
|
||||
@ -161,15 +161,15 @@ namespace Wox.Test.Plugins
|
||||
public void WindowsSearchAPI_ShouldShowHiddenFiles_WhenDisplayHiddenFilesIsTrue()
|
||||
{
|
||||
// Arrange
|
||||
OleDBResult unHiddenFile = new OleDBResult(new List<object>() { "C:/test/path/file1.txt", "file1.txt", (Int64)0x0 });
|
||||
OleDBResult hiddenFile = new OleDBResult(new List<object>() { "C:/test/path/file2.txt", "file2.txt", (Int64)0x2 });
|
||||
OleDBResult unHiddenFile = new OleDBResult(new List<object>() { "C:/test/path/file1.txt", "file1.txt", 0x0L });
|
||||
OleDBResult hiddenFile = new OleDBResult(new List<object>() { "C:/test/path/file2.txt", "file2.txt", 0x2L });
|
||||
List<OleDBResult> results = new List<OleDBResult>() { hiddenFile, unHiddenFile };
|
||||
var mock = new Mock<ISearch>();
|
||||
mock.Setup(x => x.Query(It.IsAny<string>(), It.IsAny<string>())).Returns(results);
|
||||
WindowsSearchAPI _api = new WindowsSearchAPI(mock.Object, true);
|
||||
WindowsSearchAPI api = new WindowsSearchAPI(mock.Object, true);
|
||||
|
||||
// Act
|
||||
var windowsSearchAPIResults = _api.Search("FilePath");
|
||||
var windowsSearchAPIResults = api.Search("FilePath");
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(windowsSearchAPIResults.Count() == 2);
|
||||
@ -181,15 +181,15 @@ namespace Wox.Test.Plugins
|
||||
public void WindowsSearchAPI_ShouldNotShowHiddenFiles_WhenDisplayHiddenFilesIsFalse()
|
||||
{
|
||||
// Arrange
|
||||
OleDBResult unHiddenFile = new OleDBResult(new List<object>() { "C:/test/path/file1.txt", "file1.txt", (Int64)0x0 });
|
||||
OleDBResult hiddenFile = new OleDBResult(new List<object>() { "C:/test/path/file2.txt", "file2.txt", (Int64)0x2 });
|
||||
OleDBResult unHiddenFile = new OleDBResult(new List<object>() { "C:/test/path/file1.txt", "file1.txt", 0x0L });
|
||||
OleDBResult hiddenFile = new OleDBResult(new List<object>() { "C:/test/path/file2.txt", "file2.txt", 0x2L });
|
||||
List<OleDBResult> results = new List<OleDBResult>() { hiddenFile, unHiddenFile };
|
||||
var mock = new Mock<ISearch>();
|
||||
mock.Setup(x => x.Query(It.IsAny<string>(), It.IsAny<string>())).Returns(results);
|
||||
WindowsSearchAPI _api = new WindowsSearchAPI(mock.Object, false);
|
||||
WindowsSearchAPI api = new WindowsSearchAPI(mock.Object, false);
|
||||
|
||||
// Act
|
||||
var windowsSearchAPIResults = _api.Search("FilePath");
|
||||
var windowsSearchAPIResults = api.Search("FilePath");
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(windowsSearchAPIResults.Count() == 1);
|
||||
@ -201,16 +201,16 @@ namespace Wox.Test.Plugins
|
||||
public void WindowsSearchAPI_ShouldNotReturnResultsWithNullValue_WhenDbResultHasANullColumn()
|
||||
{
|
||||
// Arrange
|
||||
OleDBResult file1 = new OleDBResult(new List<object>() { "C:/test/path/file1.txt", DBNull.Value, (Int64)0x0 });
|
||||
OleDBResult file2 = new OleDBResult(new List<object>() { "C:/test/path/file2.txt", "file2.txt", (Int64)0x0 });
|
||||
OleDBResult file1 = new OleDBResult(new List<object>() { "C:/test/path/file1.txt", DBNull.Value, 0x0L });
|
||||
OleDBResult file2 = new OleDBResult(new List<object>() { "C:/test/path/file2.txt", "file2.txt", 0x0L });
|
||||
|
||||
List<OleDBResult> results = new List<OleDBResult>() { file1, file2 };
|
||||
var mock = new Mock<ISearch>();
|
||||
mock.Setup(x => x.Query(It.IsAny<string>(), It.IsAny<string>())).Returns(results);
|
||||
WindowsSearchAPI _api = new WindowsSearchAPI(mock.Object, false);
|
||||
WindowsSearchAPI api = new WindowsSearchAPI(mock.Object, false);
|
||||
|
||||
// Act
|
||||
var windowsSearchAPIResults = _api.Search("FilePath");
|
||||
var windowsSearchAPIResults = api.Search("FilePath");
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(windowsSearchAPIResults.Count() == 1);
|
||||
@ -228,15 +228,15 @@ namespace Wox.Test.Plugins
|
||||
var mockapi = new Mock<IPublicAPI>();
|
||||
var pluginInitContext = new PluginInitContext() { API = mockapi.Object };
|
||||
|
||||
ContextMenuLoader _contextMenuLoader = new ContextMenuLoader(pluginInitContext);
|
||||
ContextMenuLoader contextMenuLoader = new ContextMenuLoader(pluginInitContext);
|
||||
|
||||
// Act
|
||||
Result result = new Result
|
||||
{
|
||||
ContextData = new SearchResult { Path = path }
|
||||
ContextData = new SearchResult { Path = path },
|
||||
};
|
||||
|
||||
List<ContextMenuResult> contextMenuItems = _contextMenuLoader.LoadContextMenus(result);
|
||||
List<ContextMenuResult> contextMenuItems = contextMenuLoader.LoadContextMenus(result);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(contextMenuItems.Count, 4);
|
||||
@ -256,15 +256,15 @@ namespace Wox.Test.Plugins
|
||||
var mockapi = new Mock<IPublicAPI>();
|
||||
var pluginInitContext = new PluginInitContext() { API = mockapi.Object };
|
||||
|
||||
ContextMenuLoader _contextMenuLoader = new ContextMenuLoader(pluginInitContext);
|
||||
ContextMenuLoader contextMenuLoader = new ContextMenuLoader(pluginInitContext);
|
||||
|
||||
// Act
|
||||
Result result = new Result
|
||||
{
|
||||
ContextData = new SearchResult { Path = path }
|
||||
ContextData = new SearchResult { Path = path },
|
||||
};
|
||||
|
||||
List<ContextMenuResult> contextMenuItems = _contextMenuLoader.LoadContextMenus(result);
|
||||
List<ContextMenuResult> contextMenuItems = contextMenuLoader.LoadContextMenus(result);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(contextMenuItems.Count, 3);
|
||||
@ -282,15 +282,15 @@ namespace Wox.Test.Plugins
|
||||
var mockapi = new Mock<IPublicAPI>();
|
||||
var pluginInitContext = new PluginInitContext() { API = mockapi.Object };
|
||||
|
||||
ContextMenuLoader _contextMenuLoader = new ContextMenuLoader(pluginInitContext);
|
||||
ContextMenuLoader contextMenuLoader = new ContextMenuLoader(pluginInitContext);
|
||||
|
||||
// Act
|
||||
Result result = new Result
|
||||
{
|
||||
ContextData = new SearchResult { Path = path }
|
||||
ContextData = new SearchResult { Path = path },
|
||||
};
|
||||
|
||||
List<ContextMenuResult> contextMenuItems = _contextMenuLoader.LoadContextMenus(result);
|
||||
List<ContextMenuResult> contextMenuItems = contextMenuLoader.LoadContextMenus(result);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(contextMenuItems.Count, 2);
|
||||
@ -310,11 +310,11 @@ namespace Wox.Test.Plugins
|
||||
var mockRegistry = new Mock<IRegistryWrapper>();
|
||||
mockRegistry.Setup(r => r.GetHKLMRegistryValue(It.IsAny<string>(), It.IsAny<string>())).Returns(enhancedModeStatus); // Enhanced mode is disabled
|
||||
|
||||
IndexerDriveDetection _driveDetection = new IndexerDriveDetection(mockRegistry.Object);
|
||||
_driveDetection.IsDriveDetectionWarningCheckBoxSelected = disableWarningCheckBoxStatus;
|
||||
IndexerDriveDetection driveDetection = new IndexerDriveDetection(mockRegistry.Object);
|
||||
driveDetection.IsDriveDetectionWarningCheckBoxSelected = disableWarningCheckBoxStatus;
|
||||
|
||||
// Act & Assert
|
||||
return _driveDetection.DisplayWarning();
|
||||
return driveDetection.DisplayWarning();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace Wox.Test
|
||||
{
|
||||
var nonGlobalPlugins = new Dictionary<string, PluginPair>
|
||||
{
|
||||
{ ">", new PluginPair { Metadata = new PluginMetadata { ActionKeywords = new List<string> { ">" } } } }
|
||||
{ ">", new PluginPair { Metadata = new PluginMetadata { ActionKeywords = new List<string> { ">" } } } },
|
||||
};
|
||||
|
||||
Query q = QueryBuilder.Build("> file.txt file2 file3", nonGlobalPlugins);
|
||||
@ -30,7 +30,7 @@ namespace Wox.Test
|
||||
{
|
||||
var nonGlobalPlugins = new Dictionary<string, PluginPair>
|
||||
{
|
||||
{ ">", new PluginPair { Metadata = new PluginMetadata { ActionKeywords = new List<string> { ">" }, Disabled = true } } }
|
||||
{ ">", new PluginPair { Metadata = new PluginMetadata { ActionKeywords = new List<string> { ">" }, Disabled = true } } },
|
||||
};
|
||||
|
||||
Query q = QueryBuilder.Build("> file.txt file2 file3", nonGlobalPlugins);
|
||||
@ -44,7 +44,7 @@ namespace Wox.Test
|
||||
Query q = QueryBuilder.Build("file.txt file2 file3", new Dictionary<string, PluginPair>());
|
||||
|
||||
Assert.AreEqual("file.txt file2 file3", q.Search);
|
||||
Assert.AreEqual("", q.ActionKeyword);
|
||||
Assert.AreEqual(string.Empty, q.ActionKeyword);
|
||||
|
||||
Assert.AreEqual("file.txt", q.FirstSearch);
|
||||
Assert.AreEqual("file2", q.SecondSearch);
|
||||
|
@ -4,16 +4,12 @@
|
||||
|
||||
using NUnit.Framework;
|
||||
using PowerLauncher.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Test
|
||||
{
|
||||
[TestFixture]
|
||||
class ResultsViewModelTest
|
||||
internal class ResultsViewModelTest
|
||||
{
|
||||
[Test]
|
||||
public void ContextMenuSelectedIndex_ShouldEqualNoSelectionIndex_WhenInitialized()
|
||||
@ -24,7 +20,7 @@ namespace Wox.Test
|
||||
ResultViewModel selectedItem = new ResultViewModel(result);
|
||||
selectedItem.ContextMenuItems.Add(new ContextMenuItemViewModel()
|
||||
{
|
||||
Title = "Dummy Context Menu"
|
||||
Title = "Dummy Context Menu",
|
||||
});
|
||||
rvm.SelectedItem = selectedItem;
|
||||
|
||||
@ -41,7 +37,7 @@ namespace Wox.Test
|
||||
ResultViewModel selectedItem = new ResultViewModel(result);
|
||||
selectedItem.ContextMenuItems.Add(new ContextMenuItemViewModel()
|
||||
{
|
||||
Title = "Dummy Context Menu"
|
||||
Title = "Dummy Context Menu",
|
||||
});
|
||||
rvm.SelectedItem = selectedItem;
|
||||
|
||||
@ -61,7 +57,7 @@ namespace Wox.Test
|
||||
ResultViewModel selectedItem = new ResultViewModel(result);
|
||||
selectedItem.ContextMenuItems.Add(new ContextMenuItemViewModel()
|
||||
{
|
||||
Title = "Dummy Context Menu"
|
||||
Title = "Dummy Context Menu",
|
||||
});
|
||||
rvm.SelectedItem = selectedItem;
|
||||
|
||||
@ -81,15 +77,15 @@ namespace Wox.Test
|
||||
ResultViewModel selectedItem = new ResultViewModel(result);
|
||||
selectedItem.ContextMenuItems.Add(new ContextMenuItemViewModel()
|
||||
{
|
||||
Title = "Dummy Context Menu 1"
|
||||
Title = "Dummy Context Menu 1",
|
||||
});
|
||||
selectedItem.ContextMenuItems.Add(new ContextMenuItemViewModel()
|
||||
{
|
||||
Title = "Dummy Context Menu 2"
|
||||
Title = "Dummy Context Menu 2",
|
||||
});
|
||||
selectedItem.ContextMenuItems.Add(new ContextMenuItemViewModel()
|
||||
{
|
||||
Title = "Dummy Context Menu 3"
|
||||
Title = "Dummy Context Menu 3",
|
||||
});
|
||||
rvm.SelectedItem = selectedItem;
|
||||
|
||||
@ -112,7 +108,7 @@ namespace Wox.Test
|
||||
ResultViewModel selectedItem = new ResultViewModel(result);
|
||||
selectedItem.ContextMenuItems.Add(new ContextMenuItemViewModel()
|
||||
{
|
||||
Title = "Dummy Context Menu"
|
||||
Title = "Dummy Context Menu",
|
||||
});
|
||||
rvm.SelectedItem = selectedItem;
|
||||
|
||||
@ -133,7 +129,7 @@ namespace Wox.Test
|
||||
ResultViewModel selectedItem = new ResultViewModel(result);
|
||||
selectedItem.ContextMenuItems.Add(new ContextMenuItemViewModel()
|
||||
{
|
||||
Title = "Dummy Context Menu"
|
||||
Title = "Dummy Context Menu",
|
||||
});
|
||||
rvm.SelectedItem = selectedItem;
|
||||
|
||||
@ -154,7 +150,7 @@ namespace Wox.Test
|
||||
ResultViewModel selectedItem = new ResultViewModel(result);
|
||||
selectedItem.ContextMenuItems.Add(new ContextMenuItemViewModel()
|
||||
{
|
||||
Title = "Dummy Context Menu"
|
||||
Title = "Dummy Context Menu",
|
||||
});
|
||||
rvm.SelectedItem = selectedItem;
|
||||
|
||||
|
@ -1,35 +0,0 @@
|
||||
// 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 NUnit.Framework;
|
||||
// using Wox.Plugin.Url;
|
||||
|
||||
namespace Wox.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class UrlPluginTest
|
||||
{
|
||||
[Test]
|
||||
public void URLMatchTest()
|
||||
{
|
||||
// var plugin = new Main();
|
||||
// Assert.IsTrue(plugin.IsURL("http://www.google.com"));
|
||||
// Assert.IsTrue(plugin.IsURL("https://www.google.com"));
|
||||
// Assert.IsTrue(plugin.IsURL("http://google.com"));
|
||||
// Assert.IsTrue(plugin.IsURL("www.google.com"));
|
||||
// Assert.IsTrue(plugin.IsURL("google.com"));
|
||||
// Assert.IsTrue(plugin.IsURL("http://localhost"));
|
||||
// Assert.IsTrue(plugin.IsURL("https://localhost"));
|
||||
// Assert.IsTrue(plugin.IsURL("http://localhost:80"));
|
||||
// Assert.IsTrue(plugin.IsURL("https://localhost:80"));
|
||||
// Assert.IsTrue(plugin.IsURL("http://110.10.10.10"));
|
||||
// Assert.IsTrue(plugin.IsURL("110.10.10.10"));
|
||||
// Assert.IsTrue(plugin.IsURL("ftp://110.10.10.10"));
|
||||
|
||||
// Assert.IsFalse(plugin.IsURL("wwww"));
|
||||
// Assert.IsFalse(plugin.IsURL("wwww.c"));
|
||||
// Assert.IsFalse(plugin.IsURL("wwww.c"));
|
||||
}
|
||||
}
|
||||
}
|
@ -57,7 +57,7 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
|
||||
</ItemGroup>
|
||||
<!--<ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">
|
||||
<Link>GlobalSuppressions.cs</Link>
|
||||
</Compile>
|
||||
@ -71,5 +71,5 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>-->
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -2,35 +2,36 @@
|
||||
// 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.Runtime.CompilerServices;
|
||||
using System.Windows.Input;
|
||||
using NUnit.Framework;
|
||||
using Wox.Plugin;
|
||||
using PowerLauncher.ViewModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class Wox
|
||||
public class WoxTest
|
||||
{
|
||||
// A Dummy class to test that OnPropertyChanged() is called while we set the variable
|
||||
public class DummyTestClass : BaseModel
|
||||
{
|
||||
public bool isFunctionCalled = false;
|
||||
public bool IsFunctionCalled { get; set; } = false;
|
||||
|
||||
private ICommand _item;
|
||||
|
||||
public ICommand Item
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._item;
|
||||
return _item;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this._item)
|
||||
if (value != _item)
|
||||
{
|
||||
this._item = value;
|
||||
_item = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
@ -39,7 +40,7 @@ namespace Wox.Test
|
||||
// Overriding the OnPropertyChanged() function to test if it is being called
|
||||
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
isFunctionCalled = true;
|
||||
IsFunctionCalled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +54,7 @@ namespace Wox.Test
|
||||
testClass.Item = new RelayCommand(null);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(testClass.isFunctionCalled);
|
||||
Assert.IsTrue(testClass.IsFunctionCalled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user