wip
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* In-Memory Implementation: ILeagueWalletRepository
|
||||
*
|
||||
* Mock repository for testing and development
|
||||
*/
|
||||
|
||||
import type { LeagueWallet } from '../../domain/entities/LeagueWallet';
|
||||
import type { ILeagueWalletRepository } from '../../domain/repositories/ILeagueWalletRepository';
|
||||
|
||||
export class InMemoryLeagueWalletRepository implements ILeagueWalletRepository {
|
||||
private wallets: Map<string, LeagueWallet> = new Map();
|
||||
|
||||
async findById(id: string): Promise<LeagueWallet | null> {
|
||||
return this.wallets.get(id) ?? null;
|
||||
}
|
||||
|
||||
async findByLeagueId(leagueId: string): Promise<LeagueWallet | null> {
|
||||
for (const wallet of this.wallets.values()) {
|
||||
if (wallet.leagueId === leagueId) {
|
||||
return wallet;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async create(wallet: LeagueWallet): Promise<LeagueWallet> {
|
||||
if (this.wallets.has(wallet.id)) {
|
||||
throw new Error('LeagueWallet with this ID already exists');
|
||||
}
|
||||
this.wallets.set(wallet.id, wallet);
|
||||
return wallet;
|
||||
}
|
||||
|
||||
async update(wallet: LeagueWallet): Promise<LeagueWallet> {
|
||||
if (!this.wallets.has(wallet.id)) {
|
||||
throw new Error('LeagueWallet not found');
|
||||
}
|
||||
this.wallets.set(wallet.id, wallet);
|
||||
return wallet;
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<void> {
|
||||
this.wallets.delete(id);
|
||||
}
|
||||
|
||||
async exists(id: string): Promise<boolean> {
|
||||
return this.wallets.has(id);
|
||||
}
|
||||
|
||||
// Test helper
|
||||
clear(): void {
|
||||
this.wallets.clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user