mirror of
https://github.com/tgeorgiadis/quiver-launcher.git
synced 2026-12-06 11:47:59 -05:00
- Introduce Android app - Migrate project files to .NET 10, updating dependencies and workflows. - Migrate project to Avalonia 12 - Refactor App.axaml to include a ResourceDictionary for theme management. - Introduce new styles for gamepad navigation and focus rings. - Implement hosted main view management for better application lifecycle handling. - Remove deprecated MainWindow.Mods.cs file and related code. - Update README to reflect changes in project structure and requirements. Co-authored-by: Cursor <cursoragent@cursor.com>
107 lines
3.6 KiB
C#
107 lines
3.6 KiB
C#
using FluentAssertions;
|
|
using QuiverLauncher.Models;
|
|
using QuiverLauncher.ViewModels;
|
|
|
|
namespace QuiverLauncher.Tests;
|
|
|
|
public class GameGridViewModelTests
|
|
{
|
|
[Fact]
|
|
public void SortGames_orders_by_name_by_default()
|
|
{
|
|
var games = new[]
|
|
{
|
|
new GameInfo { Name = "Zelda" },
|
|
new GameInfo { Name = "Banjo" },
|
|
};
|
|
|
|
var sorted = new GameGridViewModel().SortGames(games, "Name", "/apps", ignoreArticlesWhenSorting: false);
|
|
sorted.Select(g => g.Name).Should().Equal("Banjo", "Zelda");
|
|
}
|
|
|
|
[Fact]
|
|
public void SortGames_name_mode_keeps_leading_articles_when_disabled()
|
|
{
|
|
var games = new[]
|
|
{
|
|
new GameInfo { Name = "Zelda" },
|
|
new GameInfo { Name = "The Legend of Zelda" },
|
|
new GameInfo { Name = "Banjo" },
|
|
};
|
|
|
|
var sorted = new GameGridViewModel().SortGames(games, "Name", "/apps", ignoreArticlesWhenSorting: false);
|
|
sorted.Select(g => g.Name).Should().Equal("Banjo", "The Legend of Zelda", "Zelda");
|
|
}
|
|
|
|
[Fact]
|
|
public void SortGames_name_mode_strips_leading_articles_when_enabled()
|
|
{
|
|
var games = new[]
|
|
{
|
|
new GameInfo { Name = "Zelda" },
|
|
new GameInfo { Name = "The Legend of Zelda" },
|
|
new GameInfo { Name = "A Short Hike" },
|
|
new GameInfo { Name = "Banjo" },
|
|
};
|
|
|
|
var sorted = new GameGridViewModel().SortGames(games, "Name", "/apps", ignoreArticlesWhenSorting: true);
|
|
sorted.Select(g => g.Name).Should().Equal("Banjo", "The Legend of Zelda", "A Short Hike", "Zelda");
|
|
}
|
|
|
|
[Fact]
|
|
public void SortGames_name_mode_uses_custom_display_name()
|
|
{
|
|
var games = new[]
|
|
{
|
|
new GameInfo { Name = "Zelda", CustomDisplayName = "Alpha" },
|
|
new GameInfo { Name = "Banjo" },
|
|
new GameInfo { Name = "Mario", CustomDisplayName = "The Custom Mario" },
|
|
};
|
|
|
|
var sorted = new GameGridViewModel().SortGames(games, "Name", "/apps", ignoreArticlesWhenSorting: true);
|
|
sorted.Select(g => g.DisplayName).Should().Equal("Alpha", "Banjo", "The Custom Mario");
|
|
}
|
|
|
|
[Fact]
|
|
public void ApplySort_does_not_reset_collection_when_already_sorted()
|
|
{
|
|
var banjo = new GameInfo { Name = "Banjo" };
|
|
var zelda = new GameInfo { Name = "Zelda" };
|
|
var games = new System.Collections.ObjectModel.ObservableCollection<GameInfo> { banjo, zelda };
|
|
var resets = 0;
|
|
games.CollectionChanged += (_, e) =>
|
|
{
|
|
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
|
|
resets++;
|
|
};
|
|
|
|
new GameGridViewModel().ApplySort(games, "Name", "/apps", ignoreArticlesWhenSorting: false);
|
|
|
|
resets.Should().Be(0);
|
|
games.Should().Equal(banjo, zelda);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetLastPlayedTime_reads_timestamp_file()
|
|
{
|
|
var tempRoot = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
|
var gameFolder = Path.Combine(tempRoot, "TestGame");
|
|
Directory.CreateDirectory(gameFolder);
|
|
|
|
try
|
|
{
|
|
var timestamp = "2024-06-01 12:00:00";
|
|
File.WriteAllText(Path.Combine(gameFolder, "LastPlayed.txt"), timestamp);
|
|
|
|
var game = new GameInfo { FolderName = "TestGame" };
|
|
var parsed = GameGridViewModel.GetLastPlayedTime(game, tempRoot);
|
|
|
|
parsed.Should().Be(DateTime.ParseExact(timestamp, "yyyy-MM-dd HH:mm:ss", null));
|
|
}
|
|
finally
|
|
{
|
|
Directory.Delete(tempRoot, true);
|
|
}
|
|
}
|
|
}
|