feat(repo): cosmetic catalog id enumerations on ICollectionRepository
This commit is contained in:
@@ -16,4 +16,16 @@ public class CollectionRepository : ICollectionRepository
|
|||||||
{
|
{
|
||||||
return await _dbContext.Set<LeaderSkinEntry>().AsNoTracking().Include(skin => skin.Class).ToListAsync();
|
return await _dbContext.Set<LeaderSkinEntry>().AsNoTracking().Include(skin => skin.Class).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<List<int>> GetAllSleeveIds() =>
|
||||||
|
_dbContext.Set<SleeveEntry>().AsNoTracking().Select(s => s.Id).ToListAsync();
|
||||||
|
|
||||||
|
public Task<List<int>> GetAllEmblemIds() =>
|
||||||
|
_dbContext.Set<EmblemEntry>().AsNoTracking().Select(e => e.Id).ToListAsync();
|
||||||
|
|
||||||
|
public Task<List<int>> GetAllDegreeIds() =>
|
||||||
|
_dbContext.Set<DegreeEntry>().AsNoTracking().Select(d => d.Id).ToListAsync();
|
||||||
|
|
||||||
|
public Task<List<int>> GetAllMyPageBackgroundIds() =>
|
||||||
|
_dbContext.Set<MyPageBackgroundEntry>().AsNoTracking().Select(m => m.Id).ToListAsync();
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,8 @@ namespace SVSim.Database.Repositories.Collectibles;
|
|||||||
public interface ICollectionRepository
|
public interface ICollectionRepository
|
||||||
{
|
{
|
||||||
Task<List<LeaderSkinEntry>> GetLeaderSkins();
|
Task<List<LeaderSkinEntry>> GetLeaderSkins();
|
||||||
|
Task<List<int>> GetAllSleeveIds();
|
||||||
|
Task<List<int>> GetAllEmblemIds();
|
||||||
|
Task<List<int>> GetAllDegreeIds();
|
||||||
|
Task<List<int>> GetAllMyPageBackgroundIds();
|
||||||
}
|
}
|
||||||
28
SVSim.UnitTests/Repositories/CollectionRepositoryTests.cs
Normal file
28
SVSim.UnitTests/Repositories/CollectionRepositoryTests.cs
Normal file
@@ -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<SVSimDbContext>();
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user