mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
try new nunit
This commit is contained in:
parent
a7c22270cb
commit
05a5a50f7a
9 changed files with 119 additions and 116 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,12 +49,9 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Moq" Version="4.18.4" />
|
||||
<PackageReference Include="nunit" Version="3.14.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NUnit" Version="4.1.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -6,6 +6,7 @@ using NUnit.Framework;
|
|||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Plugin;
|
||||
using Flow.Launcher.Plugin.SharedModels;
|
||||
using NUnit.Framework.Legacy;
|
||||
|
||||
namespace Flow.Launcher.Test
|
||||
{
|
||||
|
|
@ -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}");
|
||||
}
|
||||
|
||||
|
|
@ -195,7 +196,7 @@ namespace Flow.Launcher.Test
|
|||
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}" +
|
||||
|
|
@ -246,7 +247,7 @@ namespace Flow.Launcher.Test
|
|||
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}" +
|
||||
|
|
@ -335,8 +336,8 @@ namespace Flow.Launcher.Test
|
|||
var firstScore = new[] {firstNameMatch, firstDescriptionMatch, firstExecutableNameMatch}.Max();
|
||||
var secondScore = new[] {secondNameMatch, secondDescriptionMatch, secondExecutableNameMatch}.Max();
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(firstScore > secondScore,
|
||||
// ClassicAssert
|
||||
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}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using NUnit.Framework;
|
|||
using System;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Infrastructure.Http;
|
||||
using NUnit.Framework.Legacy;
|
||||
|
||||
namespace Flow.Launcher.Test
|
||||
{
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using Flow.Launcher.Core.Plugin;
|
|||
using Flow.Launcher.Plugin;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework.Legacy;
|
||||
|
||||
namespace Flow.Launcher.Test
|
||||
{
|
||||
|
|
@ -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]
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using System.IO;
|
|||
using System.Runtime.Versioning;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework.Legacy;
|
||||
using static Flow.Launcher.Plugin.Explorer.Search.SearchManager;
|
||||
|
||||
namespace Flow.Launcher.Test.Plugins
|
||||
|
|
@ -57,7 +58,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 +75,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 +95,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 +106,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 +129,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var resultString = queryConstructor.FilesAndFolders(userSearchString);
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(expectedString, resultString);
|
||||
ClassicAssert.AreEqual(expectedString, resultString);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -144,7 +145,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
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,7 +163,7 @@ 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}");
|
||||
}
|
||||
|
|
@ -181,7 +182,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}");
|
||||
}
|
||||
|
|
@ -202,7 +203,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}");
|
||||
|
||||
|
|
@ -229,7 +230,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}");
|
||||
}
|
||||
|
|
@ -242,7 +243,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}");
|
||||
}
|
||||
|
|
@ -256,7 +257,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var resultString = QueryConstructor.RecursiveDirectoryConstraint(path);
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(expectedString, resultString);
|
||||
ClassicAssert.AreEqual(expectedString, resultString);
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("windows7.0")]
|
||||
|
|
@ -270,7 +271,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\\")]
|
||||
|
|
@ -301,7 +302,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")]
|
||||
|
|
@ -330,7 +331,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")]
|
||||
|
|
@ -362,7 +363,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")]
|
||||
|
|
@ -394,7 +395,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)]
|
||||
|
|
@ -416,7 +417,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\")]
|
||||
|
|
@ -440,7 +441,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var hash2 = comparator.GetHashCode(result2);
|
||||
|
||||
// When, Then
|
||||
Assert.IsTrue(hash1 == hash2);
|
||||
ClassicAssert.IsTrue(hash1 == hash2);
|
||||
}
|
||||
|
||||
[TestCase(@"%appdata%", true)]
|
||||
|
|
@ -457,7 +458,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
var result = EnvironmentVariables.HasEnvironmentVar(path);
|
||||
|
||||
// Then
|
||||
Assert.AreEqual(result, expectedResult);
|
||||
ClassicAssert.AreEqual(result, expectedResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,62 +29,62 @@ namespace Flow.Launcher.Test.Plugins
|
|||
}
|
||||
|
||||
[TestCase("{\"result\":[],\"DebugMessage\":null}", Description = "Empty Result")]
|
||||
[TestCase("{\"result\":[{\"JsonRPCAction\":null,\"Title\":\"something\",\"SubTitle\":\"\",\"ActionKeywordAssigned\":null,\"IcoPath\":null}],\"DebugMessage\":null}", Description = "One Result with Pascal Case")]
|
||||
[TestCase("{\"result\":[{\"jsonRPCAction\":null,\"title\":\"something\",\"subTitle\":\"\",\"actionKeywordAssigned\":null,\"icoPath\":null}],\"debugMessage\":null}", Description = "One Result with camel Case")]
|
||||
[TestCase("{\"result\":[{\"JsonRPCAction\":null,\"Title\":\"iii\",\"SubTitle\":\"\",\"ActionKeywordAssigned\":null,\"IcoPath\":null},{\"JsonRPCAction\":null,\"Title\":\"iii\",\"SubTitle\":\"\",\"ActionKeywordAssigned\":null,\"IcoPath\":null}],\"DebugMessage\":null}", Description = "Two Result with Pascal Case")]
|
||||
[TestCase("{\"result\":[{\"jsonrpcAction\":null,\"TItLE\":\"iii\",\"Subtitle\":\"\",\"Actionkeywordassigned\":null,\"icoPath\":null},{\"jsonRPCAction\":null,\"tiTle\":\"iii\",\"subTitle\":\"\",\"ActionKeywordAssigned\":null,\"IcoPath\":null}],\"DebugMessage\":null}", Description = "Two Result with Weird Case")]
|
||||
[TestCase(
|
||||
"{\"result\":[{\"JsonRPCAction\":null,\"Title\":\"something\",\"SubTitle\":\"\",\"ActionKeywordAssigned\":null,\"IcoPath\":null}],\"DebugMessage\":null}",
|
||||
Description = "One Result with Pascal Case")]
|
||||
[TestCase(
|
||||
"{\"result\":[{\"jsonRPCAction\":null,\"title\":\"something\",\"subTitle\":\"\",\"actionKeywordAssigned\":null,\"icoPath\":null}],\"debugMessage\":null}",
|
||||
Description = "One Result with camel Case")]
|
||||
[TestCase(
|
||||
"{\"result\":[{\"JsonRPCAction\":null,\"Title\":\"iii\",\"SubTitle\":\"\",\"ActionKeywordAssigned\":null,\"IcoPath\":null},{\"JsonRPCAction\":null,\"Title\":\"iii\",\"SubTitle\":\"\",\"ActionKeywordAssigned\":null,\"IcoPath\":null}],\"DebugMessage\":null}",
|
||||
Description = "Two Result with Pascal Case")]
|
||||
[TestCase(
|
||||
"{\"result\":[{\"jsonrpcAction\":null,\"TItLE\":\"iii\",\"Subtitle\":\"\",\"Actionkeywordassigned\":null,\"icoPath\":null},{\"jsonRPCAction\":null,\"tiTle\":\"iii\",\"subTitle\":\"\",\"ActionKeywordAssigned\":null,\"IcoPath\":null}],\"DebugMessage\":null}",
|
||||
Description = "Two Result with Weird Case")]
|
||||
public async Task GivenVariousJsonText_WhenVariousNamingCase_ThenExpectNotNullResults_Async(string resultText)
|
||||
{
|
||||
var results = await QueryAsync(new Query
|
||||
{
|
||||
Search = resultText
|
||||
}, default);
|
||||
var results = await QueryAsync(new Query { Search = resultText }, default);
|
||||
|
||||
Assert.IsNotNull(results);
|
||||
Assert.That(results, Is.Not.Null);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.AsyncAction);
|
||||
Assert.IsNotNull(result.Title);
|
||||
Assert.That(result, Is.Not.Null);
|
||||
Assert.That(result.AsyncAction, Is.Not.Null);
|
||||
Assert.That(result.Title, Is.Not.Null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static List<JsonRPCQueryResponseModel> ResponseModelsSource = new()
|
||||
{
|
||||
new JsonRPCQueryResponseModel(0, new List<JsonRPCResult>()),
|
||||
new JsonRPCQueryResponseModel(0, new List<JsonRPCResult>
|
||||
{
|
||||
new JsonRPCResult
|
||||
{
|
||||
Title = "Test1", SubTitle = "Test2"
|
||||
}
|
||||
})
|
||||
new JsonRPCQueryResponseModel(0,
|
||||
new List<JsonRPCResult> { new JsonRPCResult { Title = "Test1", SubTitle = "Test2" } })
|
||||
};
|
||||
|
||||
[TestCaseSource(typeof(JsonRPCPluginTest), nameof(ResponseModelsSource))]
|
||||
public async Task GivenModel_WhenSerializeWithDifferentNamingPolicy_ThenExpectSameResult_Async(JsonRPCQueryResponseModel reference)
|
||||
public async Task GivenModel_WhenSerializeWithDifferentNamingPolicy_ThenExpectSameResult_Async(
|
||||
JsonRPCQueryResponseModel reference)
|
||||
{
|
||||
var camelText = JsonSerializer.Serialize(reference, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
|
||||
var camelText = JsonSerializer.Serialize(reference,
|
||||
new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
|
||||
|
||||
var pascalText = JsonSerializer.Serialize(reference);
|
||||
|
||||
var results1 = await QueryAsync(new Query { Search = camelText }, default);
|
||||
var results2 = await QueryAsync(new Query { Search = pascalText }, default);
|
||||
|
||||
Assert.IsNotNull(results1);
|
||||
Assert.IsNotNull(results2);
|
||||
Assert.That(results1, Is.Not.Null);
|
||||
Assert.That(results2, Is.Not.Null);
|
||||
|
||||
foreach (var ((result1, result2), referenceResult) in results1.Zip(results2).Zip(reference.Result))
|
||||
{
|
||||
Assert.AreEqual(result1, result2);
|
||||
Assert.AreEqual(result1, referenceResult);
|
||||
Assert.That(result1, Is.EqualTo(result2));
|
||||
Assert.That(result1, Is.EqualTo(referenceResult));
|
||||
|
||||
Assert.IsNotNull(result1);
|
||||
Assert.IsNotNull(result1.AsyncAction);
|
||||
Assert.That(result1, Is.Not.Null);
|
||||
Assert.That(result1.AsyncAction, Is.Not.Null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,23 +10,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"));
|
||||
Assert.That(plugin.IsURL("http://www.google.com"), Is.True);
|
||||
Assert.That(plugin.IsURL("https://www.google.com"), Is.True);
|
||||
Assert.That(plugin.IsURL("http://google.com"), Is.True);
|
||||
Assert.That(plugin.IsURL("www.google.com"), Is.True);
|
||||
Assert.That(plugin.IsURL("google.com"), Is.True);
|
||||
Assert.That(plugin.IsURL("http://localhost"), Is.True);
|
||||
Assert.That(plugin.IsURL("https://localhost"), Is.True);
|
||||
Assert.That(plugin.IsURL("http://localhost:80"), Is.True);
|
||||
Assert.That(plugin.IsURL("https://localhost:80"), Is.True);
|
||||
Assert.That(plugin.IsURL("http://110.10.10.10"), Is.True);
|
||||
Assert.That(plugin.IsURL("110.10.10.10"), Is.True);
|
||||
Assert.That(plugin.IsURL("ftp://110.10.10.10"), Is.True);
|
||||
|
||||
|
||||
Assert.IsFalse(plugin.IsURL("wwww"));
|
||||
Assert.IsFalse(plugin.IsURL("wwww.c"));
|
||||
Assert.IsFalse(plugin.IsURL("wwww.c"));
|
||||
Assert.That(plugin.IsURL("wwww"), Is.False);
|
||||
Assert.That(plugin.IsURL("wwww.c"), Is.False);
|
||||
Assert.That(plugin.IsURL("wwww.c"), Is.False);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using NUnit.Framework;
|
||||
using Flow.Launcher.Core.Plugin;
|
||||
using Flow.Launcher.Plugin;
|
||||
using NUnit.Framework.Legacy;
|
||||
|
||||
namespace Flow.Launcher.Test
|
||||
{
|
||||
|
|
@ -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