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 { if (this.shouldFail) throw new Error('Event publisher failed'); this.dashboardAccessedEvents.push(event); } async publishDashboardError(event: DashboardErrorEvent): Promise { 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; } }