Skip to content

Add mock classes for UARTInterface, SPIInterface, I2CInterface, ADCInterface, OneWireInterface, PWMOutput #80

@haikieu

Description

@haikieu

Board Type

Any

Operating System

Any

Swift Version

Any

Description

Currently, the SwiftGPIO interfaces are tight up to concrete classes which heavily depend on Raspberry Pi's environment, OS and libraries. The downside is the code which has integrated SwiftyGPIO gets crash when run on MAC.

In order to take advanges of XCode, and enable debugging capable on MAC/XCode, I'd like to add mocks feature into SwiftyGPIO.

The overall feature will conduct these things:

  1. Implement mock classes of UARTInterface, SPIInterface, I2CInterface, ADCInterface, OneWireInterface, PWMOutput.
  2. Mock classes provide extra closures, so that developers can provide any simulation logic into any certain function of mock object.
  3. The concrete object shouldn't be created directly, but by help of InstanceCreator
  4. InstanceCreate is able to instantiate the actual objects or alternative mock objects depending on 2 things, enableMock flag and the current OS. if enableMock is true and the OS is MAC then return the mock object, otherwise return the actual object

Check out this branch for more detail: https://github.com/haikieu/SwiftyGPIO/tree/Add-Mocks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions