From be19c0ad8d8bee790a9b636bb429df6653bfabab Mon Sep 17 00:00:00 2001 From: gamer147 Date: Fri, 29 May 2026 13:29:19 -0400 Subject: [PATCH] feat(repo): cosmetic catalog id enumerations on ICollectionRepository --- .../Collectibles/CollectionRepository.cs | 12 ++++++++ .../Collectibles/ICollectionRepository.cs | 4 +++ .../Repositories/CollectionRepositoryTests.cs | 28 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 SVSim.UnitTests/Repositories/CollectionRepositoryTests.cs diff --git a/SVSim.Database/Repositories/Collectibles/CollectionRepository.cs b/SVSim.Database/Repositories/Collectibles/CollectionRepository.cs index c398aac..859d705 100644 --- a/SVSim.Database/Repositories/Collectibles/CollectionRepository.cs +++ b/SVSim.Database/Repositories/Collectibles/CollectionRepository.cs @@ -16,4 +16,16 @@ public class CollectionRepository : ICollectionRepository { return await _dbContext.Set().AsNoTracking().Include(skin => skin.Class).ToListAsync(); } + + public Task> GetAllSleeveIds() => + _dbContext.Set().AsNoTracking().Select(s => s.Id).ToListAsync(); + + public Task> GetAllEmblemIds() => + _dbContext.Set().AsNoTracking().Select(e => e.Id).ToListAsync(); + + public Task> GetAllDegreeIds() => + _dbContext.Set().AsNoTracking().Select(d => d.Id).ToListAsync(); + + public Task> GetAllMyPageBackgroundIds() => + _dbContext.Set().AsNoTracking().Select(m => m.Id).ToListAsync(); } \ No newline at end of file diff --git a/SVSim.Database/Repositories/Collectibles/ICollectionRepository.cs b/SVSim.Database/Repositories/Collectibles/ICollectionRepository.cs index 17e7dab..870102e 100644 --- a/SVSim.Database/Repositories/Collectibles/ICollectionRepository.cs +++ b/SVSim.Database/Repositories/Collectibles/ICollectionRepository.cs @@ -5,4 +5,8 @@ namespace SVSim.Database.Repositories.Collectibles; public interface ICollectionRepository { Task> GetLeaderSkins(); + Task> GetAllSleeveIds(); + Task> GetAllEmblemIds(); + Task> GetAllDegreeIds(); + Task> GetAllMyPageBackgroundIds(); } \ No newline at end of file diff --git a/SVSim.UnitTests/Repositories/CollectionRepositoryTests.cs b/SVSim.UnitTests/Repositories/CollectionRepositoryTests.cs new file mode 100644 index 0000000..2f853ca --- /dev/null +++ b/SVSim.UnitTests/Repositories/CollectionRepositoryTests.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using SVSim.Database; +using SVSim.Database.Models; +using SVSim.Database.Repositories.Collectibles; +using SVSim.UnitTests.Infrastructure; + +namespace SVSim.UnitTests.Repositories; + +public class CollectionRepositoryTests +{ + [Test] + public async Task GetAllSleeveIds_returns_every_master_sleeve() + { + using var factory = new SVSimTestFactory(); + await factory.SeedGlobalsAsync(); + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + db.Sleeves.Add(new SleeveEntry { Id = 123456 }); + await db.SaveChangesAsync(); + + var repo = new CollectionRepository(db); + var ids = await repo.GetAllSleeveIds(); + + Assert.That(ids, Does.Contain(123456)); + Assert.That(ids.Count, Is.EqualTo(await db.Sleeves.CountAsync())); + } +}