-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPSObjectConverterTests.cs
More file actions
31 lines (28 loc) · 969 Bytes
/
Copy pathPSObjectConverterTests.cs
File metadata and controls
31 lines (28 loc) · 969 Bytes
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
using System.Data;
using System.Management.Automation;
using DBAClientX.PowerShell;
using Xunit;
public class PSObjectConverterTests
{
[Fact]
public void DataRowToPSObjectCreatesProperties()
{
var table = new DataTable();
table.Columns.Add("Id", typeof(int));
table.Columns.Add("Name", typeof(string));
var row1 = table.NewRow();
row1["Id"] = 1;
row1["Name"] = "Alice";
table.Rows.Add(row1);
var row2 = table.NewRow();
row2["Id"] = 2;
row2["Name"] = "Bob";
table.Rows.Add(row2);
var ps1 = PSObjectConverter.DataRowToPSObject(row1);
Assert.Equal(1, ps1.Properties["Id"].Value);
Assert.Equal("Alice", ps1.Properties["Name"].Value);
var ps2 = PSObjectConverter.DataRowToPSObject(row2);
Assert.Equal(2, ps2.Properties["Id"].Value);
Assert.Equal("Bob", ps2.Properties["Name"].Value);
}
}