Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Threema/DataBackup/Tests/Helper/   (Social Medium ©)  Datei vom 26.9.2026 mit Größe 1 kB image not shown  

Quelle  RecoveryKeyGeneratorMock.swift   Sprache: JAVA

 

import DataBackup
import os

public struct RecoveryKeyGeneratorMock: RecoveryKeyGeneratorProtocol {

    // MARK: - Public types

    public enum Call: Equatable, Sendable {
        case generate
    }

    // MARK: - Private types

    private struct State {
        var calls: [Call] = []
        var mockGenerate: @Sendable () throws -> String = {
            String(repeating: "A1B2C3D4", count: 8)
        }
    }

    // MARK: - Private properties

    private let state = OSAllocatedUnfairLock<State>(initialState: State())

    // MARK: - Lifecycle

    public init() { /* no-op */ }

    // MARK: - Public properties

    public var mockGenerate: @Sendable () throws -> String {
        get { state.withLock { $0.mockGenerate } }
        set { state.withLock { $0.mockGenerate = newValue } }
    }

    public var calls: [Call] {
        state.withLock { $0.calls }
    }

    // MARK: - Public methods

    public func reset() {
        state.withLock { $0.calls.removeAll() }
    }

    public func generate() throws -> String {
        let stub: @Sendable () throws -> String = state.withLock {
            $0.calls.append(.generate)
            return $0.mockGenerate
        }
        return try stub()
    }
}

extension RecoveryKeyGeneratorProtocol where Self == RecoveryKeyGeneratorMock {
    public static var mock: Self {
        RecoveryKeyGeneratorMock()
    }
}

Messung
CHZG
849710093

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-04) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.