Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Flow.Launcher.Test/FilesFoldersTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Flow.Launcher.Plugin.SharedCommands;
using NUnit.Framework;
using NUnit.Framework.Legacy;

namespace Flow.Launcher.Test
{
Expand Down Expand Up @@ -35,7 +36,7 @@ public class FilesFoldersTest
[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
Expand All @@ -47,7 +48,7 @@ public void GivenTwoPaths_WhenCheckPathContains_ThenShouldBeExpectedResult(strin
[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));
}
}
}
2 changes: 1 addition & 1 deletion Flow.Launcher.Test/Flow.Launcher.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

<ItemGroup>
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="nunit" Version="3.14.0" />
<PackageReference Include="nunit" Version="4.3.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
37 changes: 19 additions & 18 deletions Flow.Launcher.Test/FuzzyMatcherTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand All @@ -21,8 +22,8 @@ public class FuzzyMatcherTest
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.",
Expand All @@ -34,7 +35,7 @@ public List<string> GetSearchStrings()
OneOneOneOne
};

public List<int> GetPrecisionScores()
public static List<int> GetPrecisionScores()
{
var listToReturn = new List<int>();

Expand Down Expand Up @@ -71,10 +72,10 @@ public void MatchTest()

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")]
Expand All @@ -84,7 +85,7 @@ public void WhenNotAllCharactersFoundInSearchString_ThenShouldReturnZeroScore(st
var matcher = new StringMatcher();
var scoreResult = matcher.FuzzyMatch(searchString, compareString).RawScore;

Assert.True(scoreResult == 0);
ClassicAssert.True(scoreResult == 0);
}

[TestCase("chr")]
Expand Down Expand Up @@ -125,7 +126,7 @@ public void GivenQueryString_WhenAppliedPrecisionFiltering_ThenShouldReturnGreat
Debug.WriteLine("###############################################");
Debug.WriteLine("");

Assert.IsFalse(filteredResult.Any(x => x.Score < precisionScore));
ClassicAssert.IsFalse(filteredResult.Any(x => x.Score < precisionScore));
}
}

Expand All @@ -151,7 +152,7 @@ public void WhenGivenQueryString_ThenShouldReturn_TheDesiredScoring(
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}");
}

Expand Down Expand Up @@ -190,12 +191,12 @@ public void WhenGivenDesiredPrecision_ThenShouldReturn_AllResultsGreaterOrEqual(
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}" +
Expand Down Expand Up @@ -241,12 +242,12 @@ public void WhenGivenQuery_ShouldReturnResults_ContainingAllQuerySubstrings(
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}" +
Expand Down Expand Up @@ -277,7 +278,7 @@ public void WhenGivenAQuery_Scoring_ShouldGiveMoreWeightToStartOfNewWord(
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}" +
Expand Down Expand Up @@ -310,7 +311,7 @@ public void WhenGivenTwoStrings_Scoring_ShouldGiveMoreWeightToTheStringCloserToI
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}" +
Expand All @@ -336,7 +337,7 @@ public void WhenMultipleResults_ExactMatchingResult_ShouldHaveGreatestScore(
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}" +
Expand All @@ -360,7 +361,7 @@ public void WhenGivenAnAcronymQuery_ShouldReturnAcronymScore(string queryString,
{
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}
Expand Down
15 changes: 8 additions & 7 deletions Flow.Launcher.Test/HttpTest.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,16 +17,16 @@ public void GivenHttpProxy_WhenUpdated_ThenWebProxyShouldAlsoBeUpdatedToTheSame(

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);
}
}
}
31 changes: 16 additions & 15 deletions Flow.Launcher.Test/PluginLoadTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
using NUnit.Framework.Legacy;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Plugin;
using System.Collections.Generic;
Expand All @@ -15,37 +16,37 @@ public void GivenDuplicatePluginMetadatasWhenLoadedThenShouldReturnOnlyUniqueLis
// 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"
Expand All @@ -56,11 +57,11 @@ public void GivenDuplicatePluginMetadatasWhenLoadedThenShouldReturnOnlyUniqueLis
(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]
Expand All @@ -69,12 +70,12 @@ public void GivenDuplicatePluginMetadatasWithNoUniquePluginWhenLoadedThenShouldR
// Given
var duplicateList = new List<PluginMetadata>
{
new PluginMetadata
new()
{
ID = "CEA0TYUC6D3B7855823D60DC76F28855",
Version = "1.0.0"
},
new PluginMetadata
new()
{
ID = "CEA0TYUC6D3B7855823D60DC76F28855",
Version = "1.0.0"
Expand All @@ -85,8 +86,8 @@ public void GivenDuplicatePluginMetadatasWithNoUniquePluginWhenLoadedThenShouldR
(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);
}
}
}
Loading
Loading