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

kysect / PowerShellRunner / 9758853126

02 Jul 2024 09:56AM UTC coverage: 56.868%. Remained the same
9758853126

push

github

FrediKats
Add IPowerShellObjectMapper

165 of 401 branches covered (41.15%)

Branch coverage included in aggregate %.

12 of 22 new or added lines in 3 files covered. (54.55%)

16 existing lines in 3 files now uncovered.

1222 of 2038 relevant lines covered (59.96%)

3.23 hits per line

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

68.18
/Sources/Kysect.PowerShellRunner/Executions/PowerShellVariableInitializer.cs
1
using Kysect.CommonLib.BaseTypes.Extensions;
2
using Kysect.PowerShellRunner.Abstractions.Accessors;
3
using Kysect.PowerShellRunner.Abstractions.Cmdlets;
4
using Kysect.PowerShellRunner.Abstractions.Objects;
5
using Kysect.PowerShellRunner.Abstractions.Queries;
6
using Kysect.PowerShellRunner.Abstractions.Variables;
7
using Kysect.PowerShellRunner.QueryBuilding;
8

9
namespace Kysect.PowerShellRunner.Executions;
10

11
public class PowerShellVariableInitializer
12
{
13
    private readonly IPowerShellAccessor _accessor;
14
    private readonly PowerShellVariable _variable;
15
    private readonly IPowerShellObjectMapper _powerShellObjectMapper;
16

17
    public PowerShellVariableInitializer(IPowerShellAccessor accessor, PowerShellVariable variable, IPowerShellObjectMapper powerShellObjectMapper)
18
    {
19
        _accessor = accessor.ThrowIfNull();
1✔
20
        _variable = variable.ThrowIfNull();
1✔
21
        _powerShellObjectMapper = powerShellObjectMapper.ThrowIfNull();
1✔
22
    }
1✔
23

24
    public PowerShellVariable With(PowerShellQuery query)
25
    {
UNCOV
26
        return Execute(query);
×
27
    }
28

29
    public PowerShellVariable<T> With<T>(PowerShellQuery query) where T : notnull
30
    {
31
        PowerShellVariable powerShellVariable = Execute(query);
1✔
32
        return Map<T>(powerShellVariable);
1✔
33
    }
34

35
    public PowerShellVariable<T> With<T>(IPowerShellCmdlet cmdletWrapper) where T : notnull
36
    {
37
        PowerShellQuery powerShellQuery = cmdletWrapper.BuildFromCmdlet();
×
38
        PowerShellVariable powerShellVariable = Execute(powerShellQuery);
×
UNCOV
39
        return Map<T>(powerShellVariable);
×
40
    }
41

42
    public PowerShellVariable<T> With<T>(IPowerShellCmdlet<T> cmdletWrapper) where T : notnull
43
    {
44
        PowerShellQuery powerShellQuery = cmdletWrapper.BuildFromCmdlet();
×
45
        PowerShellVariable powerShellVariable = Execute(powerShellQuery);
×
UNCOV
46
        return Map<T>(powerShellVariable);
×
47
    }
48

49
    private PowerShellVariable Execute(PowerShellQuery query)
50
    {
51
        query = query with { ResultVariable = _variable };
1✔
52

53
        _accessor.ExecuteAndGet(query);
1✔
54
        IReadOnlyCollection<IPowerShellObject> variableValue = _accessor.GetVariableVale(_variable);
1✔
55
        return new PowerShellVariable(_variable.Name, variableValue.ToList());
1✔
56
    }
57

58
    private PowerShellVariable<T> Map<T>(PowerShellVariable powerShellVariable) where T : notnull
59
    {
60
        var mappedValues = powerShellVariable
1✔
61
            .Values
1✔
62
            .Select(_powerShellObjectMapper.Map<T>)
1✔
63
            .ToList();
1✔
64

65
        return new PowerShellVariable<T>(powerShellVariable.Name, mappedValues);
1✔
66
    }
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