PowerToys/Wox.Test/FuzzyMatcherTest.cs
2016-01-06 21:34:42 +00:00

44 lines
1.1 KiB
C#

using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Wox.Infrastructure;
using Wox.Plugin;
namespace Wox.Test
{
[TestFixture]
public class FuzzyMatcherTest
{
[Test]
public void MatchTest()
{
var sources = new List<string>
{
"file open in browser-test",
"Install Package",
"add new bsd",
"Inste",
"aac"
};
var results = new List<Result>();
foreach (var str in sources)
{
results.Add(new Result
{
Title = str,
Score = FuzzyMatcher.Create("inst").Evaluate(str).Score
});
}
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");
}
}
}