LD-Uninstaller/tests/LDUninstaller.Tests/JunkManagerTests.cs

63 lines
2.2 KiB
C#

using System.Collections.Generic;
using LDUninstaller.Core.Junk;
using LDUninstaller.Core.Models;
using Xunit;
namespace LDUninstaller.Tests
{
public class JunkManagerTests
{
[Theory]
[InlineData("github", "git", false)]
[InlineData("github desktop", "git", false)]
[InlineData("git", "git", true)]
[InlineData("git-scm", "git", true)]
[InlineData("git_tools", "git", true)]
[InlineData("git.exe", "git", true)]
[InlineData("photostudio", "studio", false)]
[InlineData("visual studio code", "studio", true)]
[InlineData("sublime_text", "sublime", true)]
public void IsWordOrExactMatch_BoundaryEnforcement(string target, string token, bool expected)
{
bool actual = JunkManager.IsWordOrExactMatch(target, token);
Assert.Equal(expected, actual);
}
[Fact]
public void GetMatchTokens_StopWords_ExcludesGenericWords()
{
var entry = new ApplicationUninstallerEntry
{
DisplayName = "VLC media player",
Publisher = "VideoLAN"
};
var (cleanName, cleanPub, tokens) = JunkManager.GetMatchTokens(entry);
Assert.Equal("vlc media player", cleanName);
Assert.Equal("videolan", cleanPub);
Assert.Contains("vlc", tokens);
Assert.DoesNotContain("media", tokens);
Assert.DoesNotContain("player", tokens);
}
[Fact]
public void GetMatchTokens_AppWithStopWords_FiltersProperly()
{
var entry = new ApplicationUninstallerEntry
{
DisplayName = "Windows App SDK Desktop Runtime",
Publisher = "Microsoft Corporation"
};
var (_, _, tokens) = JunkManager.GetMatchTokens(entry);
// "app", "sdk", "desktop", "runtime", "windows" are stop-words and should be filtered from lone tokens
Assert.DoesNotContain("app", tokens);
Assert.DoesNotContain("sdk", tokens);
Assert.DoesNotContain("desktop", tokens);
Assert.DoesNotContain("runtime", tokens);
Assert.DoesNotContain("windows", tokens);
}
}
}