• 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

95.45
/Core/Key2Joy.Core/Plugins/MappingTypeFactory.cs
1
using System;
2
using System.Collections.Generic;
3
using Key2Joy.Contracts.Mapping;
4
using Key2Joy.Mapping.Actions.Scripting;
5

6
namespace Key2Joy.Plugins;
7

8
/// <summary>
9
/// Creates instances of types, simply using Activator.CreateInstance
10
/// </summary>
11
public class MappingTypeFactory
12
{
13
    public string FullTypeName { get; private set; }
1,472✔
14

15
    public MappingAttribute Attribute { get; private set; }
773✔
16
    public IEnumerable<ExposedMethod> ExposedMethods { get; private set; }
767✔
17

18
    public MappingTypeFactory(string fullTypeName, MappingAttribute attribute, IEnumerable<ExposedMethod> exposedMethods = null)
553✔
19
    {
20
        this.FullTypeName = fullTypeName;
553✔
21
        this.Attribute = attribute;
553✔
22
        this.ExposedMethods = exposedMethods ?? new List<ExposedMethod>();
553✔
23
    }
553✔
24

25
    public virtual T CreateInstance<T>(object[] constructorArguments) where T : AbstractMappingAspect => (T)Activator.CreateInstance(this.ToType(), constructorArguments);
506✔
26

27
    public virtual Type ToType() => Type.GetType(this.FullTypeName);
506✔
28
}
29

30
/// <summary>
31
/// Creates instances of types, simply using Activator.CreateInstance
32
/// </summary>
33
public class MappingTypeFactory<T> : MappingTypeFactory where T : AbstractMappingAspect
34
{
35
    public MappingTypeFactory(string fullTypeName, MappingAttribute attribute, IEnumerable<ExposedMethod> exposedMethods = null)
36
        : base(fullTypeName, attribute, exposedMethods)
452✔
37
    {
38
    }
452✔
39

40
    public virtual T CreateInstance(object[] constructorArguments) => base.CreateInstance<T>(constructorArguments);
203✔
41
}
42

43
/// <summary>
44
/// Creates the type by commanding the PluginHostProxy to create it.
45
/// </summary>
46
public class PluginMappingTypeFactory<T> : MappingTypeFactory<T> where T : AbstractMappingAspect
47
{
48
    private readonly PluginHostProxy pluginHost;
49
    private readonly Type hostBaseType;
50

51
    public PluginMappingTypeFactory(PluginHostProxy pluginHost, Type hostBaseType, string fullTypeName, MappingAttribute attribute, IReadOnlyList<ExposedMethod> exposedMethods = null)
52
        : base(fullTypeName, attribute, exposedMethods)
60✔
53
    {
54
        this.pluginHost = pluginHost;
60✔
55
        this.hostBaseType = hostBaseType;
60✔
56
    }
60✔
57

58
    public override T CreateInstance(object[] constructorArguments) => this.CreateInstance<T>(constructorArguments);
12✔
59

60
    public override T CreateInstance<T>(object[] constructorArguments) => this.pluginHost.CreateAspectInstance<T>(this.FullTypeName, constructorArguments);
12✔
61

62
    /// <summary>
63
    /// Since we can't get the Type in the other appdomain, we return the host/contract class it derives from instead.
64
    /// </summary>
65
    /// <returns></returns>
66
    public override Type ToType() => this.hostBaseType;
×
67
}
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