Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  ServerAPIRequestMock.swift   Sprache: JAVA

 

import Foundation
@testable import ThreemaFramework

/// A mock implementation of `ServerAPIRequestProtocol` for testing purposes.
///
/// This mock allows tests to control the behavior of server API requests by
/// configuring responses and errors. It also captures request information
/// for verification in tests.
final class ServerAPIRequestMock: ServerAPIRequestProtocol {
    
    // MARK: - Configuration
    
    /// The JSON response to return from `postJSONToWorkAPI`.
    /// Set this to configure a successful response.
    var mockResponse: Any?
    
    /// The error to throw from `postJSONToWorkAPI`.
    /// If set, this takes precedence over `mockResponse`.
    var mockError: Error?
    
    // MARK: - Captured Values
    
    /// The path passed to the last `postJSONToWorkAPI` call.
    private(set) var capturedPath: String?
    
    /// The data passed to the last `postJSONToWorkAPI` call.
    private(set) var capturedData: [String: Any]?
    
    /// The number of times `postJSONToWorkAPI` was called.
    private(set) var postJSONCallCount = 0
    
    // MARK: - ServerAPIRequestProtocol
    
    func postJSONToWorkAPI(path: String, data: [String: Any]) async throws -> Any? {
        postJSONCallCount += 1
        capturedPath = path
        capturedData = data
        
        if let error = mockError {
            throw error
        }
        
        return mockResponse
    }
}

Messung
CHZG
839610093

¤ Dauer der Verarbeitung: 0.0 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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1104848
#Domains=416967