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

luttje / Key2Joy / 6749638574

03 Nov 2023 08:00PM UTC coverage: 44.916% (+1.1%) from 43.795%
6749638574

push

github

luttje
fix JS failing on callback/function parameter + add tests

802 of 2447 branches covered (0.0%)

Branch coverage included in aggregate %.

75 of 76 new or added lines in 4 files covered. (98.68%)

147 existing lines in 11 files now uncovered.

4048 of 8351 relevant lines covered (48.47%)

17051.46 hits per line

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

29.63
/Core/Key2Joy.Core/Mapping/Actions/Scripting/BaseScriptAction.cs
1
using System.Collections.Generic;
2
using System.Text;
3
using Key2Joy.Contracts;
4
using Key2Joy.Contracts.Mapping;
5
using Key2Joy.Contracts.Mapping.Actions;
6
using Key2Joy.Contracts.Mapping.Triggers;
7

8
namespace Key2Joy.Mapping.Actions.Scripting;
9

10
public abstract class BaseScriptAction : CoreAction
11
{
12
    public static readonly object LockObject = new();
1✔
13

14
    public string Script { get; set; }
11✔
15
    public bool IsScriptPath { get; set; }
4✔
16

17
    protected string cachedFile;
18

19
    public BaseScriptAction(string name)
20
        : base(name)
18✔
21
    { }
18✔
22

23
    protected virtual string GetExecutableScript()
24
    {
25
        if (this.IsScriptPath)
1!
26
        {
UNCOV
27
            this.cachedFile ??= System.IO.File.ReadAllText(this.Script);
×
28

UNCOV
29
            return this.cachedFile;
×
30
        }
31

32
        return this.Script;
1✔
33
    }
34

35
    public abstract void RegisterScriptingEnum(ExposedEnumeration enumeration);
36

37
    /// <summary>
38
    /// Called to register scripting methods on the environment.
39
    /// </summary>
40
    /// <param name="exposedMethod">The method to be exposed to scripting</param>
41
    /// <param name="scriptActionInstance">The action on which the exposed method resides</param>
42
    public abstract void RegisterScriptingMethod(ExposedMethod exposedMethod, AbstractAction scriptActionInstance);
43

44
    public virtual void Print(params object[] args)
45
    {
UNCOV
46
        StringBuilder sb = new();
×
47
        for (var i = 0; i < args.Length; i++)
×
48
        {
UNCOV
49
            if (i > 0)
×
50
            {
UNCOV
51
                sb.Append("\t");
×
52
            }
53

UNCOV
54
            sb.Append(args[i]);
×
55
        }
56

UNCOV
57
        Output.WriteLine(sb);
×
58
    }
×
59

60
    public override string GetNameDisplay()
61
    {
UNCOV
62
        var truncatedScript = this.Script;
×
63

UNCOV
64
        return this.Name.Replace("{0}", truncatedScript);
×
65
    }
66

67
    public override void OnStartListening(AbstractTriggerListener listener, ref IList<AbstractAction> otherActions)
UNCOV
68
        => base.OnStartListening(listener, ref otherActions);
×
69
}
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

© 2025 Coveralls, Inc