• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

luttje / Key2Joy / 6557152774

18 Oct 2023 06:36AM UTC coverage: 52.519% (+39.8%) from 12.718%
6557152774

push

github

web-flow
Adding more tests, fixing bugs in the process (#48)

* Add config manager tests

* legacy config and mapping profile tests (should fix #42)

* remove comment, problem was caused by transfer across appdomain (or to/fro scripting environment)

* Test core functionality #48 + includes minor refactoring to be able to test + added docs

* Add interop tests + implement and test async test utility (refactors away from singletons)

* fix not all tests running in workflow

* config and interop tests

* Refactor and allow mocking global input hook class

* add capture action test

* Make Execute override optional for script only methods

* add dependency injection + refactor and try test gamepad service

* Refactor config singleton to using dependency injection

* add tests for scripting

* add tests for plugin set + fix plugin showing as loaded even if checksum match failed

* fix tests failing because it relied on config exist (I guess the test order was accidentally correct earlier, this means we should really fix cleanup so we catch this sooner)

* refactor docs code + fix wrong enum summary

* refactor docs builder and start testing it a bit

* fix cmd project structure

* ignore designer files in tests

* cleanup and refactor UI code + show latest version in help

* truncate listview action column

* allow user config to minimize app when pressing X (defaults to shut down app) resolves #45

696 of 1757 branches covered (0.0%)

Branch coverage included in aggregate %.

4597 of 4597 new or added lines in 138 files covered. (100.0%)

3619 of 6459 relevant lines covered (56.03%)

17089.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.71
/Core/Key2Joy.Core/LowLevelInput/GamePad/SimulatedGamePadService.cs
1
using System;
2
using System.Linq;
3
using SimWinInput;
4

5
namespace Key2Joy.LowLevelInput.GamePad;
6

7
public class SimulatedGamePadService : IGamePadService
8
{
9
    private const int MAX_GAMEPADS = 4;
10
    private readonly IGamePad[] gamePads;
11

12
    public SimulatedGamePadService(IGamePad[] gamePads = null)
13✔
13
    {
14
        if (gamePads != null)
13✔
15
        {
16
            this.gamePads = gamePads;
4✔
17
            return;
4✔
18
        }
19

20
        this.gamePads = new IGamePad[MAX_GAMEPADS];
9✔
21

22
        for (var index = 0; index < MAX_GAMEPADS; index++)
90✔
23
        {
24
            this.gamePads[index] = new SimulatedGamePad(index);
36✔
25
        }
26
    }
9✔
27

28
    public void Initialize() => SimGamePad.Instance.Initialize();
×
29

30
    public void ShutDown() => SimGamePad.Instance.ShutDown();
2✔
31

32
    public IGamePad GetGamePad(int gamePadIndex)
33
        => this.gamePads[gamePadIndex];
1✔
34

35
    public IGamePad[] GetAllGamePads()
36
        => this.gamePads;
3✔
37

38
    public void EnsurePluggedIn(int gamePadIndex)
39
    {
40
        if (gamePadIndex is < 0 or >= MAX_GAMEPADS)
2✔
41
        {
42
            throw new ArgumentOutOfRangeException(nameof(gamePadIndex));
1✔
43
        }
44

45
        var gamePad = this.gamePads[gamePadIndex];
1✔
46

47
        if (gamePad.GetIsPluggedIn())
1!
48
        {
49
            return;
×
50
        }
51

52
        gamePad.PlugIn();
1✔
53
    }
1✔
54

55
    public void EnsureUnplugged(int gamePadIndex)
56
    {
57
        if (gamePadIndex is < 0 or >= MAX_GAMEPADS)
×
58
        {
59
            throw new ArgumentOutOfRangeException(nameof(gamePadIndex));
×
60
        }
61

62
        var gamePad = this.gamePads[gamePadIndex];
×
63

64
        if (!gamePad.GetIsPluggedIn())
×
65
        {
66
            return;
×
67
        }
68

69
        gamePad.Unplug();
×
70
    }
×
71

72
    public void EnsureAllUnplugged()
73
    {
74
        foreach (var gamePad in this.gamePads.Where(gamePad => gamePad.GetIsPluggedIn()))
26✔
75
        {
76
            gamePad.Unplug();
4✔
77
        }
78
    }
3✔
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc