forked from microsoft/PSRule
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTargetInfoTests.cs
53 lines (48 loc) · 1.98 KB
/
TargetInfoTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Management.Automation;
using Xunit;
namespace PSRule
{
public sealed class TargetInfoTests
{
[Fact]
public void TargetSourceInfo()
{
var source = new PSObject();
source.Properties.Add(new PSNoteProperty("file", "file.json"));
source.Properties.Add(new PSNoteProperty("line", 100));
source.Properties.Add(new PSNoteProperty("position", 1000));
source.Properties.Add(new PSNoteProperty("Type", "Origin"));
var info = new PSObject();
info.Properties.Add(new PSNoteProperty("source", new PSObject[] { source }));
var o = new PSObject();
o.Properties.Add(new PSNoteProperty("_PSRule", info));
o.ConvertTargetInfoProperty();
var actual = o.GetSourceInfo();
Assert.NotNull(actual);
Assert.Equal("file.json", actual[0].File);
Assert.Equal(100, actual[0].Line);
Assert.Equal(1000, actual[0].Position);
Assert.Equal("Origin", actual[0].Type);
}
[Fact]
public void TargetIssueInfo()
{
var issue = new PSObject();
issue.Properties.Add(new PSNoteProperty("Type", "CustomIssue"));
issue.Properties.Add(new PSNoteProperty("name", "Issue.1"));
issue.Properties.Add(new PSNoteProperty("message", "Some issue"));
var info = new PSObject();
info.Properties.Add(new PSNoteProperty("issue", new PSObject[] { issue }));
var o = new PSObject();
o.Properties.Add(new PSNoteProperty("_PSRule", info));
o.ConvertTargetInfoProperty();
var actual = o.GetIssueInfo();
Assert.NotNull(actual);
Assert.Equal("CustomIssue", actual[0].Type);
Assert.Equal("Issue.1", actual[0].Name);
Assert.Equal("Some issue", actual[0].Message);
}
}
}