mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-30 14:39:42 +08:00
77f22973cb
* [GUI] Add horizontal game tiles * [GUI] Update launching elements layout * [GUI] Change cards format to squares
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
// Copyright (C) 2026 SharpEmu Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
using SharpEmu.GUI;
|
|
using System.Collections;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.Specialized;
|
|
using Xunit;
|
|
|
|
namespace SharpEmu.Libs.Tests.GUI;
|
|
|
|
public sealed class LibraryTileCollectionTests
|
|
{
|
|
[Fact]
|
|
public void KeepsAddFolderTileAfterVisibleGames()
|
|
{
|
|
var games = new ObservableCollection<GameEntry>();
|
|
var tiles = new LibraryTileCollection(games);
|
|
var first = CreateGame("First");
|
|
var second = CreateGame("Second");
|
|
|
|
games.Add(first);
|
|
games.Add(second);
|
|
|
|
Assert.Equal(3, tiles.Count);
|
|
Assert.True(tiles is IList { IsReadOnly: true });
|
|
Assert.Same(first, tiles[0]);
|
|
Assert.Same(second, tiles[1]);
|
|
Assert.Same(AddFolderTile.Instance, tiles[2]);
|
|
}
|
|
|
|
[Fact]
|
|
public void ForwardsGameChangesAtTheirOriginalIndices()
|
|
{
|
|
var games = new ObservableCollection<GameEntry>();
|
|
var tiles = new LibraryTileCollection(games);
|
|
NotifyCollectionChangedEventArgs? change = null;
|
|
tiles.CollectionChanged += (_, args) => change = args;
|
|
|
|
var game = CreateGame("Game");
|
|
games.Add(game);
|
|
|
|
Assert.NotNull(change);
|
|
Assert.Equal(NotifyCollectionChangedAction.Add, change.Action);
|
|
Assert.Equal(0, change.NewStartingIndex);
|
|
Assert.Same(game, Assert.Single(change.NewItems!.Cast<GameEntry>()));
|
|
Assert.Same(AddFolderTile.Instance, tiles[1]);
|
|
}
|
|
|
|
private static GameEntry CreateGame(string name) =>
|
|
new(name, null, null, $"/games/{name}/eboot.bin", 0, null, null);
|
|
}
|