50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using Explorer.Application;
|
|
using Explorer.Domain;
|
|
|
|
namespace Explorer.Application.Tests;
|
|
|
|
public class FavoriteFoldersTests
|
|
{
|
|
[Fact]
|
|
public void Normalize_dedupes_and_skips_virtual_roots()
|
|
{
|
|
var normalized = FavoriteFolders.Normalize(
|
|
[
|
|
@"D:\Photos\",
|
|
@"d:\photos",
|
|
LocationRoots.ThisPc,
|
|
LocationRoots.Favorites,
|
|
@"C:\Users\Dominique\Documents"
|
|
]);
|
|
Assert.Equal([@"D:\Photos", @"C:\Users\Dominique\Documents"], normalized);
|
|
}
|
|
|
|
[Fact]
|
|
public void Contains_is_case_insensitive()
|
|
{
|
|
var pinned = FavoriteFolders.Normalize([@"D:\Photos"]);
|
|
Assert.True(FavoriteFolders.Contains(pinned, @"d:\photos\"));
|
|
Assert.False(FavoriteFolders.Contains(pinned, @"D:\Other"));
|
|
Assert.False(FavoriteFolders.Contains(pinned, LocationRoots.Home));
|
|
}
|
|
|
|
[Fact]
|
|
public void Add_appends_new_folders_up_to_max()
|
|
{
|
|
var current = Enumerable.Range(0, FavoriteFolders.MaxCount - 1).Select(i => $@"D:\F{i}");
|
|
var next = FavoriteFolders.Add(current, [@"D:\New", @"D:\F0", @"E:\TooMany"]);
|
|
Assert.Equal(FavoriteFolders.MaxCount, next.Count);
|
|
Assert.Equal(@"D:\New", next[^1]);
|
|
Assert.DoesNotContain(@"E:\TooMany", next);
|
|
}
|
|
|
|
[Fact]
|
|
public void Remove_unpins_without_touching_other_entries()
|
|
{
|
|
var next = FavoriteFolders.Remove(
|
|
[@"D:\Photos", @"D:\Music"],
|
|
[@"d:\photos", LocationRoots.ThisPc]);
|
|
Assert.Equal([@"D:\Music"], next);
|
|
}
|
|
}
|