mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix build issue for nunit 4.3.2 & Improve code quality
This commit is contained in:
parent
2d90481968
commit
81d479c3a3
8 changed files with 113 additions and 133 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Legacy;
|
||||
|
||||
namespace Flow.Launcher.Test
|
||||
{
|
||||
|
|
@ -35,7 +36,7 @@ namespace Flow.Launcher.Test
|
|||
[TestCase(@"c:\barr", @"c:\foo\..\bar\baz", false)]
|
||||
public void GivenTwoPaths_WhenCheckPathContains_ThenShouldBeExpectedResult(string parentPath, string path, bool expectedResult)
|
||||
{
|
||||
Assert.AreEqual(expectedResult, FilesFolders.PathContains(parentPath, path));
|
||||
ClassicAssert.AreEqual(expectedResult, FilesFolders.PathContains(parentPath, path));
|
||||
}
|
||||
|
||||
// Equality
|
||||
|
|
@ -47,7 +48,7 @@ namespace Flow.Launcher.Test
|
|||
[TestCase(@"c:\foo", @"c:\foo\", true)]
|
||||
public void GivenTwoPathsAreTheSame_WhenCheckPathContains_ThenShouldBeExpectedResult(string parentPath, string path, bool expectedResult)
|
||||
{
|
||||
Assert.AreEqual(expectedResult, FilesFolders.PathContains(parentPath, path, allowEqual: expectedResult));
|
||||
ClassicAssert.AreEqual(expectedResult, FilesFolders.PathContains(parentPath, path, allowEqual: expectedResult));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Legacy;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Plugin;
|
||||
using Flow.Launcher.Plugin.SharedModels;
|
||||
|
|
@ -21,8 +22,8 @@ namespace Flow.Launcher.Test
|
|||
private const string MicrosoftSqlServerManagementStudio = "Microsoft SQL Server Management Studio";
|
||||
private const string VisualStudioCode = "Visual Studio Code";
|
||||
|
||||
public List<string> GetSearchStrings()
|
||||
=> new List<string>
|
||||
public static List<string> GetSearchStrings()
|
||||
=> new()
|
||||
{
|
||||
Chrome,
|
||||
"Choose which programs you want Windows to use for activities like web browsing, editing photos, sending e-mail, and playing music.",
|
||||
|
|
@ -34,7 +35,7 @@ namespace Flow.Launcher.Test
|
|||
OneOneOneOne
|
||||
};
|
||||
|
||||
public List<int> GetPrecisionScores()
|
||||
public static List<int> GetPrecisionScores()
|
||||
{
|
||||
var listToReturn = new List<int>();
|
||||
|
||||
|
|
@ -71,10 +72,10 @@ namespace Flow.Launcher.Test
|
|||
|
||||
results = results.Where(x => x.Score > 0).OrderByDescending(x => x.Score).ToList();
|
||||
|
||||
Assert.IsTrue(results.Count == 3);
|
||||
Assert.IsTrue(results[0].Title == "Inste");
|
||||
Assert.IsTrue(results[1].Title == "Install Package");
|
||||
Assert.IsTrue(results[2].Title == "file open in browser-test");
|
||||
ClassicAssert.IsTrue(results.Count == 3);
|
||||
ClassicAssert.IsTrue(results[0].Title == "Inste");
|
||||
ClassicAssert.IsTrue(results[1].Title == "Install Package");
|
||||
ClassicAssert.IsTrue(results[2].Title == "file open in browser-test");
|
||||
}
|
||||
|
||||
[TestCase("Chrome")]
|
||||
|
|
@ -84,7 +85,7 @@ namespace Flow.Launcher.Test
|
|||
var matcher = new StringMatcher();
|
||||
var scoreResult = matcher.FuzzyMatch(searchString, compareString).RawScore;
|
||||
|
||||
Assert.True(scoreResult == 0);
|
||||
ClassicAssert.True(scoreResult == 0);
|
||||
}
|
||||
|
||||
[TestCase("chr")]
|
||||
|
|
@ -125,7 +126,7 @@ namespace Flow.Launcher.Test
|
|||
Debug.WriteLine("###############################################");
|
||||
Debug.WriteLine("");
|
||||
|
||||
Assert.IsFalse(filteredResult.Any(x => x.Score < precisionScore));
|
||||
ClassicAssert.IsFalse(filteredResult.Any(x => x.Score < precisionScore));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +152,7 @@ namespace Flow.Launcher.Test
|
|||
var rawScore = matcher.FuzzyMatch(queryString, compareString).RawScore;
|
||||
|
||||
// Should
|
||||
Assert.AreEqual(expectedScore, rawScore,
|
||||
ClassicAssert.AreEqual(expectedScore, rawScore,
|
||||
$"Expected score for compare string '{compareString}': {expectedScore}, Actual: {rawScore}");
|
||||
}
|
||||
|
||||
|
|
@ -190,12 +191,12 @@ namespace Flow.Launcher.Test
|
|||
Debug.WriteLine("###############################################");
|
||||
Debug.WriteLine($"QueryString: {queryString} CompareString: {compareString}");
|
||||
Debug.WriteLine(
|
||||
$"RAW SCORE: {matchResult.RawScore.ToString()}, PrecisionLevelSetAt: {expectedPrecisionScore} ({(int) expectedPrecisionScore})");
|
||||
$"RAW SCORE: {matchResult.RawScore}, PrecisionLevelSetAt: {expectedPrecisionScore} ({(int) expectedPrecisionScore})");
|
||||
Debug.WriteLine("###############################################");
|
||||
Debug.WriteLine("");
|
||||
|
||||
// Should
|
||||
Assert.AreEqual(expectedPrecisionResult, matchResult.IsSearchPrecisionScoreMet(),
|
||||
ClassicAssert.AreEqual(expectedPrecisionResult, matchResult.IsSearchPrecisionScoreMet(),
|
||||
$"Query: {queryString}{Environment.NewLine} " +
|
||||
$"Compare: {compareString}{Environment.NewLine}" +
|
||||
$"Raw Score: {matchResult.RawScore}{Environment.NewLine}" +
|
||||
|
|
@ -241,12 +242,12 @@ namespace Flow.Launcher.Test
|
|||
Debug.WriteLine("###############################################");
|
||||
Debug.WriteLine($"QueryString: {queryString} CompareString: {compareString}");
|
||||
Debug.WriteLine(
|
||||
$"RAW SCORE: {matchResult.RawScore.ToString()}, PrecisionLevelSetAt: {expectedPrecisionScore} ({(int) expectedPrecisionScore})");
|
||||
$"RAW SCORE: {matchResult.RawScore}, PrecisionLevelSetAt: {expectedPrecisionScore} ({(int) expectedPrecisionScore})");
|
||||
Debug.WriteLine("###############################################");
|
||||
Debug.WriteLine("");
|
||||
|
||||
// Should
|
||||
Assert.AreEqual(expectedPrecisionResult, matchResult.IsSearchPrecisionScoreMet(),
|
||||
ClassicAssert.AreEqual(expectedPrecisionResult, matchResult.IsSearchPrecisionScoreMet(),
|
||||
$"Query:{queryString}{Environment.NewLine} " +
|
||||
$"Compare:{compareString}{Environment.NewLine}" +
|
||||
$"Raw Score: {matchResult.RawScore}{Environment.NewLine}" +
|
||||
|
|
@ -277,7 +278,7 @@ namespace Flow.Launcher.Test
|
|||
Debug.WriteLine("");
|
||||
|
||||
// Should
|
||||
Assert.True(compareString1Result.Score > compareString2Result.Score,
|
||||
ClassicAssert.True(compareString1Result.Score > compareString2Result.Score,
|
||||
$"Query: \"{queryString}\"{Environment.NewLine} " +
|
||||
$"CompareString1: \"{compareString1}\", Score: {compareString1Result.Score}{Environment.NewLine}" +
|
||||
$"Should be greater than{Environment.NewLine}" +
|
||||
|
|
@ -310,7 +311,7 @@ namespace Flow.Launcher.Test
|
|||
Debug.WriteLine("");
|
||||
|
||||
// Should
|
||||
Assert.True(compareString1Result.Score > compareString2Result.Score,
|
||||
ClassicAssert.True(compareString1Result.Score > compareString2Result.Score,
|
||||
$"Query: \"{queryString}\"{Environment.NewLine} " +
|
||||
$"CompareString1: \"{compareString1}\", Score: {compareString1Result.Score}{Environment.NewLine}" +
|
||||
$"Should be greater than{Environment.NewLine}" +
|
||||
|
|
@ -336,7 +337,7 @@ namespace Flow.Launcher.Test
|
|||
var secondScore = new[] {secondNameMatch, secondDescriptionMatch, secondExecutableNameMatch}.Max();
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(firstScore > secondScore,
|
||||
ClassicAssert.IsTrue(firstScore > secondScore,
|
||||
$"Query: \"{queryString}\"{Environment.NewLine} " +
|
||||
$"Name of first: \"{firstName}\", Final Score: {firstScore}{Environment.NewLine}" +
|
||||
$"Should be greater than{Environment.NewLine}" +
|
||||
|
|
@ -360,7 +361,7 @@ namespace Flow.Launcher.Test
|
|||
{
|
||||
var matcher = new StringMatcher();
|
||||
var score = matcher.FuzzyMatch(queryString, compareString).Score;
|
||||
Assert.IsTrue(score == desiredScore,
|
||||
ClassicAssert.IsTrue(score == desiredScore,
|
||||
$@"Query: ""{queryString}""
|
||||
CompareString: ""{compareString}""
|
||||
Score: {score}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using NUnit.Framework;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Legacy;
|
||||
using System;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Infrastructure.Http;
|
||||
|
|
@ -16,16 +17,16 @@ namespace Flow.Launcher.Test
|
|||
|
||||
proxy.Enabled = true;
|
||||
proxy.Server = "127.0.0.1";
|
||||
Assert.AreEqual(Http.WebProxy.Address, new Uri($"http://{proxy.Server}:{proxy.Port}"));
|
||||
Assert.IsNull(Http.WebProxy.Credentials);
|
||||
ClassicAssert.AreEqual(Http.WebProxy.Address, new Uri($"http://{proxy.Server}:{proxy.Port}"));
|
||||
ClassicAssert.IsNull(Http.WebProxy.Credentials);
|
||||
|
||||
proxy.UserName = "test";
|
||||
Assert.NotNull(Http.WebProxy.Credentials);
|
||||
Assert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").UserName, proxy.UserName);
|
||||
Assert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").Password, "");
|
||||
ClassicAssert.NotNull(Http.WebProxy.Credentials);
|
||||
ClassicAssert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").UserName, proxy.UserName);
|
||||
ClassicAssert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").Password, "");
|
||||
|
||||
proxy.Password = "test password";
|
||||
Assert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").Password, proxy.Password);
|
||||
ClassicAssert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").Password, proxy.Password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using NUnit.Framework;
|
||||
using NUnit.Framework.Legacy;
|
||||
using Flow.Launcher.Core.Plugin;
|
||||
using Flow.Launcher.Plugin;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -15,37 +16,37 @@ namespace Flow.Launcher.Test
|
|||
// Given
|
||||
var duplicateList = new List<PluginMetadata>
|
||||
{
|
||||
new PluginMetadata
|
||||
new()
|
||||
{
|
||||
ID = "CEA0TYUC6D3B4085823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
},
|
||||
new PluginMetadata
|
||||
new()
|
||||
{
|
||||
ID = "CEA0TYUC6D3B4085823D60DC76F28855",
|
||||
Version = "1.0.1"
|
||||
},
|
||||
new PluginMetadata
|
||||
new()
|
||||
{
|
||||
ID = "CEA0TYUC6D3B4085823D60DC76F28855",
|
||||
Version = "1.0.2"
|
||||
},
|
||||
new PluginMetadata
|
||||
new()
|
||||
{
|
||||
ID = "CEA0TYUC6D3B4085823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
},
|
||||
new PluginMetadata
|
||||
new()
|
||||
{
|
||||
ID = "CEA0TYUC6D3B4085823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
},
|
||||
new PluginMetadata
|
||||
new()
|
||||
{
|
||||
ID = "ABC0TYUC6D3B7855823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
},
|
||||
new PluginMetadata
|
||||
new()
|
||||
{
|
||||
ID = "ABC0TYUC6D3B7855823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
|
|
@ -56,11 +57,11 @@ namespace Flow.Launcher.Test
|
|||
(var unique, var duplicates) = PluginConfig.GetUniqueLatestPluginMetadata(duplicateList);
|
||||
|
||||
// Then
|
||||
Assert.True(unique.FirstOrDefault().ID == "CEA0TYUC6D3B4085823D60DC76F28855" && unique.FirstOrDefault().Version == "1.0.2");
|
||||
Assert.True(unique.Count() == 1);
|
||||
ClassicAssert.True(unique.FirstOrDefault().ID == "CEA0TYUC6D3B4085823D60DC76F28855" && unique.FirstOrDefault().Version == "1.0.2");
|
||||
ClassicAssert.True(unique.Count == 1);
|
||||
|
||||
Assert.False(duplicates.Any(x => x.Version == "1.0.2" && x.ID == "CEA0TYUC6D3B4085823D60DC76F28855"));
|
||||
Assert.True(duplicates.Count() == 6);
|
||||
ClassicAssert.False(duplicates.Any(x => x.Version == "1.0.2" && x.ID == "CEA0TYUC6D3B4085823D60DC76F28855"));
|
||||
ClassicAssert.True(duplicates.Count == 6);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -69,12 +70,12 @@ namespace Flow.Launcher.Test
|
|||
// Given
|
||||
var duplicateList = new List<PluginMetadata>
|
||||
{
|
||||
new PluginMetadata
|
||||
new()
|
||||
{
|
||||
ID = "CEA0TYUC6D3B7855823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
},
|
||||
new PluginMetadata
|
||||
new()
|
||||
{
|
||||
ID = "CEA0TYUC6D3B7855823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
|
|
@ -85,8 +86,8 @@ namespace Flow.Launcher.Test
|
|||
(var unique, var duplicates) = PluginConfig.GetUniqueLatestPluginMetadata(duplicateList);
|
||||
|
||||
// Then
|
||||
Assert.True(unique.Count() == 0);
|
||||
Assert.True(duplicates.Count() == 2);
|
||||
ClassicAssert.True(unique.Count == 0);
|
||||
ClassicAssert.True(duplicates.Count == 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
|
|||
using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Legacy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static Flow.Launcher.Plugin.Explorer.Search.SearchManager;
|
||||
|
||||
namespace Flow.Launcher.Test.Plugins
|
||||
|
|
@ -22,28 +20,6 @@ namespace Flow.Launcher.Test.Plugins
|
|||
[TestFixture]
|
||||
public class ExplorerTest
|
||||
{
|
||||
#pragma warning disable CS1998 // async method with no await (more readable to leave it async to match the tested signature)
|
||||
private async Task<List<Result>> MethodWindowsIndexSearchReturnsZeroResultsAsync(Query dummyQuery, string dummyString, CancellationToken dummyToken)
|
||||
{
|
||||
return new List<Result>();
|
||||
}
|
||||
#pragma warning restore CS1998
|
||||
|
||||
private List<Result> MethodDirectoryInfoClassSearchReturnsTwoResults(Query dummyQuery, string dummyString, CancellationToken token)
|
||||
{
|
||||
return new List<Result>
|
||||
{
|
||||
new Result
|
||||
{
|
||||
Title = "Result 1"
|
||||
},
|
||||
new Result
|
||||
{
|
||||
Title = "Result 2"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private bool PreviousLocationExistsReturnsTrue(string dummyString) => true;
|
||||
|
||||
private bool PreviousLocationNotExistReturnsFalse(string dummyString) => false;
|
||||
|
|
@ -57,7 +33,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var result = QueryConstructor.TopLevelDirectoryConstraint(folderPath);
|
||||
|
||||
// Then
|
||||
Assert.IsTrue(result == expectedString,
|
||||
ClassicAssert.IsTrue(result == expectedString,
|
||||
$"Expected QueryWhereRestrictions string: {expectedString}{Environment.NewLine} " +
|
||||
$"Actual: {result}{Environment.NewLine}");
|
||||
}
|
||||
|
|
@ -74,7 +50,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var queryString = queryConstructor.Directory(folderPath);
|
||||
|
||||
// Then
|
||||
Assert.IsTrue(queryString.Replace(" ", " ") == expectedString.Replace(" ", " "),
|
||||
ClassicAssert.IsTrue(queryString.Replace(" ", " ") == expectedString.Replace(" ", " "),
|
||||
$"Expected string: {expectedString}{Environment.NewLine} " +
|
||||
$"Actual string was: {queryString}{Environment.NewLine}");
|
||||
}
|
||||
|
|
@ -94,7 +70,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var queryString = queryConstructor.Directory(folderPath, userSearchString);
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(expectedString, queryString);
|
||||
ClassicAssert.AreEqual(expectedString, queryString);
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("windows7.0")]
|
||||
|
|
@ -105,7 +81,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
const string resultString = QueryConstructor.RestrictionsForAllFilesAndFoldersSearch;
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(expectedString, resultString);
|
||||
ClassicAssert.AreEqual(expectedString, resultString);
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("windows7.0")]
|
||||
|
|
@ -128,7 +104,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var resultString = queryConstructor.FilesAndFolders(userSearchString);
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(expectedString, resultString);
|
||||
ClassicAssert.AreEqual(expectedString, resultString);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -138,13 +114,13 @@ namespace Flow.Launcher.Test.Plugins
|
|||
string querySearchString, string expectedString)
|
||||
{
|
||||
// Given
|
||||
var queryConstructor = new QueryConstructor(new Settings());
|
||||
_ = new QueryConstructor(new Settings());
|
||||
|
||||
//When
|
||||
var resultString = QueryConstructor.RestrictionsForFileContentSearch(querySearchString);
|
||||
|
||||
// Then
|
||||
Assert.IsTrue(resultString == expectedString,
|
||||
ClassicAssert.IsTrue(resultString == expectedString,
|
||||
$"Expected QueryWhereRestrictions string: {expectedString}{Environment.NewLine} " +
|
||||
$"Actual string was: {resultString}{Environment.NewLine}");
|
||||
}
|
||||
|
|
@ -162,12 +138,12 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var resultString = queryConstructor.FileContent(userSearchString);
|
||||
|
||||
// Then
|
||||
Assert.IsTrue(resultString == expectedString,
|
||||
ClassicAssert.IsTrue(resultString == expectedString,
|
||||
$"Expected query string: {expectedString}{Environment.NewLine} " +
|
||||
$"Actual string was: {resultString}{Environment.NewLine}");
|
||||
}
|
||||
|
||||
public void GivenQuery_WhenActionKeywordForFileContentSearchExists_ThenFileContentSearchRequiredShouldReturnTrue()
|
||||
public static void GivenQuery_WhenActionKeywordForFileContentSearchExists_ThenFileContentSearchRequiredShouldReturnTrue()
|
||||
{
|
||||
// Given
|
||||
var query = new Query
|
||||
|
|
@ -181,7 +157,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var result = searchManager.IsFileContentSearch(query.ActionKeyword);
|
||||
|
||||
// Then
|
||||
Assert.IsTrue(result,
|
||||
ClassicAssert.IsTrue(result,
|
||||
$"Expected True for file content search. {Environment.NewLine} " +
|
||||
$"Actual result was: {result}{Environment.NewLine}");
|
||||
}
|
||||
|
|
@ -206,7 +182,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var result = FilesFolders.IsLocationPathString(querySearchString);
|
||||
|
||||
//Then
|
||||
Assert.IsTrue(result == expectedResult,
|
||||
ClassicAssert.IsTrue(result == expectedResult,
|
||||
$"Expected query search string check result is: {expectedResult} {Environment.NewLine} " +
|
||||
$"Actual check result is {result} {Environment.NewLine}");
|
||||
|
||||
|
|
@ -233,7 +209,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var previousDirectoryPath = FilesFolders.GetPreviousExistingDirectory(previousLocationExists, path);
|
||||
|
||||
//Then
|
||||
Assert.IsTrue(previousDirectoryPath == expectedString,
|
||||
ClassicAssert.IsTrue(previousDirectoryPath == expectedString,
|
||||
$"Expected path string: {expectedString} {Environment.NewLine} " +
|
||||
$"Actual path string is {previousDirectoryPath} {Environment.NewLine}");
|
||||
}
|
||||
|
|
@ -246,7 +222,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var returnedPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path);
|
||||
|
||||
//Then
|
||||
Assert.IsTrue(returnedPath == expectedString,
|
||||
ClassicAssert.IsTrue(returnedPath == expectedString,
|
||||
$"Expected path string: {expectedString} {Environment.NewLine} " +
|
||||
$"Actual path string is {returnedPath} {Environment.NewLine}");
|
||||
}
|
||||
|
|
@ -260,7 +236,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var resultString = QueryConstructor.RecursiveDirectoryConstraint(path);
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(expectedString, resultString);
|
||||
ClassicAssert.AreEqual(expectedString, resultString);
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("windows7.0")]
|
||||
|
|
@ -274,7 +250,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var resultString = DirectoryInfoSearch.ConstructSearchCriteria(path);
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(expectedString, resultString);
|
||||
ClassicAssert.AreEqual(expectedString, resultString);
|
||||
}
|
||||
|
||||
[TestCase("c:\\somefolder\\someotherfolder", ResultType.Folder, "irrelevant", false, true, "c:\\somefolder\\someotherfolder\\")]
|
||||
|
|
@ -305,7 +281,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var result = ResultManager.GetPathWithActionKeyword(path, type, actionKeyword);
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(result, expectedResult);
|
||||
ClassicAssert.AreEqual(result, expectedResult);
|
||||
}
|
||||
|
||||
[TestCase("c:\\somefolder\\somefile", ResultType.File, "irrelevant", false, true, "e c:\\somefolder\\somefile")]
|
||||
|
|
@ -334,7 +310,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var result = ResultManager.GetPathWithActionKeyword(path, type, actionKeyword);
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(result, expectedResult);
|
||||
ClassicAssert.AreEqual(result, expectedResult);
|
||||
}
|
||||
|
||||
[TestCase("somefolder", "c:\\somefolder\\", ResultType.Folder, "q", false, false, "q somefolder")]
|
||||
|
|
@ -366,7 +342,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var result = ResultManager.GetAutoCompleteText(title, query, path, resultType);
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(result, expectedResult);
|
||||
ClassicAssert.AreEqual(result, expectedResult);
|
||||
}
|
||||
|
||||
[TestCase("somefile", "c:\\somefolder\\somefile", ResultType.File, "q", false, false, "q somefile")]
|
||||
|
|
@ -398,7 +374,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var result = ResultManager.GetAutoCompleteText(title, query, path, resultType);
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(result, expectedResult);
|
||||
ClassicAssert.AreEqual(result, expectedResult);
|
||||
}
|
||||
|
||||
[TestCase(@"c:\foo", @"c:\foo", true)]
|
||||
|
|
@ -420,7 +396,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
};
|
||||
|
||||
// When, Then
|
||||
Assert.AreEqual(expectedResult, comparator.Equals(result1, result2));
|
||||
ClassicAssert.AreEqual(expectedResult, comparator.Equals(result1, result2));
|
||||
}
|
||||
|
||||
[TestCase(@"c:\foo\", @"c:\foo\")]
|
||||
|
|
@ -444,7 +420,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var hash2 = comparator.GetHashCode(result2);
|
||||
|
||||
// When, Then
|
||||
Assert.IsTrue(hash1 == hash2);
|
||||
ClassicAssert.IsTrue(hash1 == hash2);
|
||||
}
|
||||
|
||||
[TestCase(@"%appdata%", true)]
|
||||
|
|
@ -461,7 +437,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var result = EnvironmentVariables.HasEnvironmentVar(path);
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(result, expectedResult);
|
||||
ClassicAssert.AreEqual(result, expectedResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
using NUnit.Framework;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Legacy;
|
||||
using Flow.Launcher.Core.Plugin;
|
||||
using Flow.Launcher.Plugin;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Flow.Launcher.Test.Plugins
|
||||
|
|
@ -40,13 +39,13 @@ namespace Flow.Launcher.Test.Plugins
|
|||
Search = resultText
|
||||
}, default);
|
||||
|
||||
Assert.IsNotNull(results);
|
||||
ClassicAssert.IsNotNull(results);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.AsyncAction);
|
||||
Assert.IsNotNull(result.Title);
|
||||
ClassicAssert.IsNotNull(result);
|
||||
ClassicAssert.IsNotNull(result.AsyncAction);
|
||||
ClassicAssert.IsNotNull(result.Title);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -56,12 +55,11 @@ namespace Flow.Launcher.Test.Plugins
|
|||
new JsonRPCQueryResponseModel(0, new List<JsonRPCResult>()),
|
||||
new JsonRPCQueryResponseModel(0, new List<JsonRPCResult>
|
||||
{
|
||||
new JsonRPCResult
|
||||
new()
|
||||
{
|
||||
Title = "Test1", SubTitle = "Test2"
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
using NUnit.Framework;
|
||||
using NUnit.Framework.Legacy;
|
||||
using Flow.Launcher.Plugin.Url;
|
||||
|
||||
namespace Flow.Launcher.Test
|
||||
namespace Flow.Launcher.Test.Plugins
|
||||
{
|
||||
[TestFixture]
|
||||
public class UrlPluginTest
|
||||
|
|
@ -10,23 +11,23 @@ namespace Flow.Launcher.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"));
|
||||
ClassicAssert.IsTrue(plugin.IsURL("http://www.google.com"));
|
||||
ClassicAssert.IsTrue(plugin.IsURL("https://www.google.com"));
|
||||
ClassicAssert.IsTrue(plugin.IsURL("http://google.com"));
|
||||
ClassicAssert.IsTrue(plugin.IsURL("www.google.com"));
|
||||
ClassicAssert.IsTrue(plugin.IsURL("google.com"));
|
||||
ClassicAssert.IsTrue(plugin.IsURL("http://localhost"));
|
||||
ClassicAssert.IsTrue(plugin.IsURL("https://localhost"));
|
||||
ClassicAssert.IsTrue(plugin.IsURL("http://localhost:80"));
|
||||
ClassicAssert.IsTrue(plugin.IsURL("https://localhost:80"));
|
||||
ClassicAssert.IsTrue(plugin.IsURL("http://110.10.10.10"));
|
||||
ClassicAssert.IsTrue(plugin.IsURL("110.10.10.10"));
|
||||
ClassicAssert.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"));
|
||||
ClassicAssert.IsFalse(plugin.IsURL("wwww"));
|
||||
ClassicAssert.IsFalse(plugin.IsURL("wwww.c"));
|
||||
ClassicAssert.IsFalse(plugin.IsURL("wwww.c"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Legacy;
|
||||
using Flow.Launcher.Core.Plugin;
|
||||
using Flow.Launcher.Plugin;
|
||||
|
||||
|
|
@ -17,17 +18,17 @@ namespace Flow.Launcher.Test
|
|||
|
||||
Query q = QueryBuilder.Build("> ping google.com -n 20 -6", nonGlobalPlugins);
|
||||
|
||||
Assert.AreEqual("> ping google.com -n 20 -6", q.RawQuery);
|
||||
Assert.AreEqual("ping google.com -n 20 -6", q.Search, "Search should not start with the ActionKeyword.");
|
||||
Assert.AreEqual(">", q.ActionKeyword);
|
||||
ClassicAssert.AreEqual("> ping google.com -n 20 -6", q.RawQuery);
|
||||
ClassicAssert.AreEqual("ping google.com -n 20 -6", q.Search, "Search should not start with the ActionKeyword.");
|
||||
ClassicAssert.AreEqual(">", q.ActionKeyword);
|
||||
|
||||
Assert.AreEqual(5, q.SearchTerms.Length, "The length of SearchTerms should match.");
|
||||
ClassicAssert.AreEqual(5, q.SearchTerms.Length, "The length of SearchTerms should match.");
|
||||
|
||||
Assert.AreEqual("ping", q.FirstSearch);
|
||||
Assert.AreEqual("google.com", q.SecondSearch);
|
||||
Assert.AreEqual("-n", q.ThirdSearch);
|
||||
ClassicAssert.AreEqual("ping", q.FirstSearch);
|
||||
ClassicAssert.AreEqual("google.com", q.SecondSearch);
|
||||
ClassicAssert.AreEqual("-n", q.ThirdSearch);
|
||||
|
||||
Assert.AreEqual("google.com -n 20 -6", q.SecondToEndSearch, "SecondToEndSearch should be trimmed of multiple whitespace characters");
|
||||
ClassicAssert.AreEqual("google.com -n 20 -6", q.SecondToEndSearch, "SecondToEndSearch should be trimmed of multiple whitespace characters");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -40,11 +41,11 @@ namespace Flow.Launcher.Test
|
|||
|
||||
Query q = QueryBuilder.Build("> ping google.com -n 20 -6", nonGlobalPlugins);
|
||||
|
||||
Assert.AreEqual("> ping google.com -n 20 -6", q.Search);
|
||||
Assert.AreEqual(q.Search, q.RawQuery, "RawQuery should be equal to Search.");
|
||||
Assert.AreEqual(6, q.SearchTerms.Length, "The length of SearchTerms should match.");
|
||||
Assert.AreNotEqual(">", q.ActionKeyword, "ActionKeyword should not match that of a disabled plugin.");
|
||||
Assert.AreEqual("ping google.com -n 20 -6", q.SecondToEndSearch, "SecondToEndSearch should be trimmed of multiple whitespace characters");
|
||||
ClassicAssert.AreEqual("> ping google.com -n 20 -6", q.Search);
|
||||
ClassicAssert.AreEqual(q.Search, q.RawQuery, "RawQuery should be equal to Search.");
|
||||
ClassicAssert.AreEqual(6, q.SearchTerms.Length, "The length of SearchTerms should match.");
|
||||
ClassicAssert.AreNotEqual(">", q.ActionKeyword, "ActionKeyword should not match that of a disabled plugin.");
|
||||
ClassicAssert.AreEqual("ping google.com -n 20 -6", q.SecondToEndSearch, "SecondToEndSearch should be trimmed of multiple whitespace characters");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -52,13 +53,13 @@ namespace Flow.Launcher.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);
|
||||
ClassicAssert.AreEqual("file.txt file2 file3", q.Search);
|
||||
ClassicAssert.AreEqual("", q.ActionKeyword);
|
||||
|
||||
Assert.AreEqual("file.txt", q.FirstSearch);
|
||||
Assert.AreEqual("file2", q.SecondSearch);
|
||||
Assert.AreEqual("file3", q.ThirdSearch);
|
||||
Assert.AreEqual("file2 file3", q.SecondToEndSearch);
|
||||
ClassicAssert.AreEqual("file.txt", q.FirstSearch);
|
||||
ClassicAssert.AreEqual("file2", q.SecondSearch);
|
||||
ClassicAssert.AreEqual("file3", q.ThirdSearch);
|
||||
ClassicAssert.AreEqual("file2 file3", q.SecondToEndSearch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue