# azamsharp/unittestingworkshop architecture

> Architecture diagram of the GitHub repository azamsharp/unittestingworkshop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azamsharp/unittestingworkshop
- Repository: https://github.com/azamsharp/unittestingworkshop

## Overview

##### Project Type Analysis
This is an educational iOS project demonstrating various testing methodologies through two main applications:
- BudgetApp (focusing on Unit Testing)
- LoanApp (demonstrating Integration Testing, Mocking, and End-to-End Testing)

##### Main Components

A. Testing Layers (Hierarchical Structure)
**┌─────────────────────────┐**
- End-to-End Tests     │
- ┤
- Integration Tests     │
- ┤
- Unit Tests        │
- ┤
- Application Code     │
- ┘

B. Application Architecture (For each app):
**┌─────────────────┐**
- UI Layer    │
- (SwiftUI)     │
- ┤
- Business Logic │
- (Services)   │
- ┤
- Models      │
- ┘

##### Specific Components

For LoanApp:
**┌─────────────────────────────────────────┐**
- UI Components              │
- RegistrationScreen                    │
- CustomerListScreen                    │
- ┤
- Services                   │
- APRService                           │
- CreditScoreService (Real & Mocked)   │
- ┤
- Models                    │
- CreditScoreResponse                  │
- ┘

##### Testing Components
**┌─────────────────────────────────────────┐**
- End-to-End Tests              │
- LoanAppUITests                        │
- ┤
- Integration Tests              │
- CustomerListScreenTests               │
- RegistrationScreenTests               │
- ┤
- Unit Tests                   │
- BudgetAppTests                        │
- MockedCreditScoreService             │
- ┘

##### Important Elements to Highlight
- Mock Service implementations
- Different testing environments (configured through Xcode settings)
- Relationship between real and mocked services
- Test data files (e.g., credit-score-response.json)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Testing Pyramid"
        E2E["End-to-End Tests"]:::e2e
        IT["Integration Tests"]:::integration
        UT["Unit Tests"]:::unit
        AC["Application Code"]:::app
        
        E2E --> IT
        IT --> UT
        UT --> AC
    end

    subgraph "UI Layer"
        RS["Registration Screen"]:::ui
        CLS["Customer List Screen"]:::ui
    end

    subgraph "Business Logic"
        APRS["APR Service"]:::service
        CSS["Credit Score Service"]:::service
        MCSS["Mocked Credit Score Service"]:::mock
    end

    subgraph "Models"
        CSR["Credit Score Response"]:::model
        CE["Credit Score Error"]:::model
    end

    subgraph "Test Components"
        CLST["Customer List Screen Tests"]:::test
        RST["Registration Screen Tests"]:::test
        BAT["Budget App Tests"]:::test
        TD["Test Data JSON"]:::test
        LAUT["Loan App UI Tests"]:::e2e
    end

    %% Relationships
    RS --> APRS
    RS --> CSS
    CLS --> CSS
    CSS --> CSR
    CSS --> CE
    MCSS -.-> CSS
    CLST --> MCSS
    RST --> MCSS
    CLST --> CLS
    RST --> RS
    LAUT --> RS
    LAUT --> CLS
    TD --> MCSS

    %% Click Events
    click RS "https://github.com/azamsharp/UnitTestingWorkshop/blob/main/LoanApp/LoanApp/Screens/RegistrationScreen.swift"
    click CLS "https://github.com/azamsharp/UnitTestingWorkshop/blob/main/LoanApp/LoanApp/Screens/CustomerListScreen.swift"
    click APRS "https://github.com/azamsharp/UnitTestingWorkshop/blob/main/LoanApp/LoanApp/Services/APRService.swift"
    click MCSS "https://github.com/azamsharp/UnitTestingWorkshop/blob/main/LoanApp/LoanAppTests/MockedCreditScoreService.swift"
    click CSR "https://github.com/azamsharp/UnitTestingWorkshop/blob/main/LoanApp/LoanApp/Models/CreditScoreResponse.swift"
    click CLST "https://github.com/azamsharp/UnitTestingWorkshop/blob/main/LoanApp/LoanAppTests/CustomerListScreenTests.swift"
    click RST "https://github.com/azamsharp/UnitTestingWorkshop/blob/main/LoanApp/LoanAppTests/RegistrationScreenTests.swift"
    click LAUT "https://github.com/azamsharp/UnitTestingWorkshop/blob/main/LoanApp/LoanAppUITests/LoanAppUITests.swift"
    click BAT "https://github.com/azamsharp/UnitTestingWorkshop/blob/main/BudgetApp/BudgetAppTests/BudgetAppTests.swift"
    click TD "https://github.com/azamsharp/UnitTestingWorkshop/blob/main/LoanApp/LoanAppTests/credit-score-response.json"
    click CE "https://github.com/azamsharp/UnitTestingWorkshop/blob/main/LoanApp/LoanApp/Custom Errors/CreditScoreError.swift"

    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#2ecc71,stroke:#27ae60,color:white
    classDef model fill:#f1c40f,stroke:#f39c12,color:black
    classDef test fill:#e67e22,stroke:#d35400,color:white
    classDef mock fill:#9b59b6,stroke:#8e44ad,color:white
    classDef e2e fill:#e74c3c,stroke:#c0392b,color:white
    classDef integration fill:#f39c12,stroke:#d35400,color:white
    classDef unit fill:#16a085,stroke:#1abc9c,color:white
    classDef app fill:#34495e,stroke:#2c3e50,color:white
```
