add tests
Some checks failed
Contract Testing / contract-tests (push) Failing after 6m7s
Contract Testing / contract-snapshot (push) Failing after 4m46s

This commit is contained in:
2026-01-22 11:52:42 +01:00
parent 40bc15ff61
commit fb1221701d
112 changed files with 30625 additions and 1059 deletions

View File

@@ -0,0 +1,39 @@
import {
DashboardEventPublisher,
DashboardAccessedEvent,
DashboardErrorEvent,
} from '../../core/dashboard/application/ports/DashboardEventPublisher';
export class InMemoryEventPublisher implements DashboardEventPublisher {
private dashboardAccessedEvents: DashboardAccessedEvent[] = [];
private dashboardErrorEvents: DashboardErrorEvent[] = [];
private shouldFail: boolean = false;
async publishDashboardAccessed(event: DashboardAccessedEvent): Promise<void> {
if (this.shouldFail) throw new Error('Event publisher failed');
this.dashboardAccessedEvents.push(event);
}
async publishDashboardError(event: DashboardErrorEvent): Promise<void> {
if (this.shouldFail) throw new Error('Event publisher failed');
this.dashboardErrorEvents.push(event);
}
getDashboardAccessedEventCount(): number {
return this.dashboardAccessedEvents.length;
}
getDashboardErrorEventCount(): number {
return this.dashboardErrorEvents.length;
}
clear(): void {
this.dashboardAccessedEvents = [];
this.dashboardErrorEvents = [];
this.shouldFail = false;
}
setShouldFail(shouldFail: boolean): void {
this.shouldFail = shouldFail;
}
}