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

kysect / PowerShellRunner / 9758848204

02 Jul 2024 09:56AM UTC coverage: 56.868% (-0.2%) from 57.061%
9758848204

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%)

50 existing lines in 6 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

91.67
/Sources/Kysect.PowerShellRunner.Abstractions/Queries/PowerShellQuery.cs
1
using Kysect.CommonLib.BaseTypes.Extensions;
2
using Kysect.PowerShellRunner.Abstractions.Variables;
3
using System.Text;
4

5
namespace Kysect.PowerShellRunner.Abstractions.Queries;
6

7
public record struct PowerShellQuery(PowerShellVariable? ResultVariable, string Query, bool ContainsSensitiveInfo, string? RedirectionPath)
8
{
9
    public PowerShellQuery(string query) : this(null, query, false, null)
14✔
10
    {
11
    }
14✔
12

13
    public PowerShellQuery WithSwitch(string argumentKey)
14
    {
15
        return this with { Query = $"{Query} -{argumentKey}" };
3✔
16
    }
17

18
    public PowerShellQuery With<T>(string argumentKey, IPowerShellReferenceable<T> variable)
19
    {
20
        variable.ThrowIfNull();
2✔
21

22
        return this with { Query = $"{Query} -{argumentKey} {variable.AsReference()}" };
2✔
23
    }
24

25
    public PowerShellQuery WithNoFormat(string argumentKey, string argumentValue)
26
    {
27
        return this with { Query = $"{Query} -{argumentKey} {argumentValue}" };
2✔
28
    }
29

30
    public PowerShellQuery With(string argumentKey, string argumentValue)
31
    {
32
        return this with { Query = $"{Query} -{argumentKey} \"{argumentValue}\"" };
1✔
33
    }
34

35
    public PowerShellQuery With(string argumentKey, int argumentValue)
36
    {
37
        return this with { Query = $"{Query} -{argumentKey} {argumentValue}" };
1✔
38
    }
39

40
    public PowerShellQuery WithPipeline()
41
    {
42
        return this with { Query = $"{Query} |" };
1✔
43
    }
44

45
    public PowerShellQuery WherePropertyLike(string propertyName, string argumentValue)
46
    {
UNCOV
47
        return this with { Query = $"{Query} Where {propertyName} -clike \"{argumentValue}*\"" };
×
48
    }
49

50
    public PowerShellQuery WherePropertyEqual(string propertyName, string argumentValue)
51
    {
52
        return this with { Query = $"{Query} Where {propertyName} -eq \"{argumentValue}\"" };
1✔
53
    }
54

55
    public PowerShellQuery ContainsSensitiveDate()
56
    {
UNCOV
57
        return this with { ContainsSensitiveInfo = true };
×
58
    }
59

60
    public PowerShellQuery WithRedirection(string path)
61
    {
62
        return this with { RedirectionPath = path };
1✔
63
    }
64

65
    public readonly string Format()
66
    {
67
        var sb = new StringBuilder();
3✔
68

69
        if (ResultVariable is not null)
3✔
70
            sb.Append($"{ResultVariable.AsReference()} = ");
1✔
71

72
        sb.Append(Query);
3✔
73
        if (!string.IsNullOrEmpty(RedirectionPath))
3✔
74
            sb.Append($" *> \"{RedirectionPath}\"");
1✔
75

76
        return sb.ToString();
3✔
77
    }
78
}
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