import XCTest @testable import ClipBored final class DiagnosticsServiceTests: XCTestCase { func testCountersCanBeIncrementedAndReset() { let diagnostics = DiagnosticsService.shared diagnostics.reset() diagnostics.incrementMonitorTick() diagnostics.incrementPasteboardChange() diagnostics.incrementExtractionAttempt() diagnostics.incrementDatabaseMutation() diagnostics.incrementCachePurge() // The snapshot read synchronizes with the serial diagnostics queue. let snapshot = diagnostics.currentSnapshot() XCTAssertEqual(snapshot.monitorTicks, 1) XCTAssertEqual(snapshot.pasteboardChanges, 1) XCTAssertEqual(snapshot.extractionAttempts, 1) XCTAssertEqual(snapshot.databaseMutations, 1) XCTAssertEqual(snapshot.cachePurges, 1) diagnostics.reset() XCTAssertEqual(diagnostics.currentSnapshot(), .init(monitorTicks: 0, pasteboardChanges: 0, extractionAttempts: 0, databaseMutations: 0, cachePurges: 0)) } }