2016-03-04 22:48:30 +00:00
|
|
|
Describe "Format-Wide" {
|
2015-10-06 19:04:57 +00:00
|
|
|
|
|
|
|
It "Should have the same output between the alias and the unaliased function" {
|
2016-04-25 21:41:17 +00:00
|
|
|
$nonaliased = Get-ChildItem | Format-Wide
|
|
|
|
$aliased = Get-ChildItem | fw
|
2015-10-06 19:04:57 +00:00
|
|
|
|
2016-04-25 21:41:17 +00:00
|
|
|
$($nonaliased | Out-String).CompareTo($($aliased | Out-String)) | Should Be 0
|
2015-10-06 19:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to specify the columns in output using the column switch" {
|
2016-05-03 03:12:35 +00:00
|
|
|
{ Get-ChildItem | Format-Wide -Column 3 } | Should Not Throw
|
2015-10-06 19:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to use the autosize switch" {
|
2016-05-03 03:12:35 +00:00
|
|
|
{ Get-ChildItem | Format-Wide -Autosize } | Should Not Throw
|
2015-10-06 19:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to take inputobject instead of pipe" {
|
2016-05-03 03:12:35 +00:00
|
|
|
{ Format-Wide -InputObject $(Get-ChildItem) } | Should Not Throw
|
2015-10-06 19:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to use the property switch" {
|
2016-05-03 03:12:35 +00:00
|
|
|
{ Format-Wide -InputObject $(Get-ChildItem) -Property Mode } | Should Not Throw
|
2015-10-06 19:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should throw an error when property switch and view switch are used together" {
|
2016-05-03 03:12:35 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Format-Wide -InputObject $(Get-ChildItem) -Property CreationTime -View aoeu
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
$_.FullyQualifiedErrorId | Should be "FormatCannotSpecifyViewAndProperty,Microsoft.PowerShell.Commands.FormatWideCommand"
|
|
|
|
}
|
2015-10-06 19:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should throw and suggest proper input when view is used with invalid input without the property switch" {
|
2016-05-03 03:12:35 +00:00
|
|
|
{ Format-Wide -InputObject $(Get-Process) -View aoeu } | Should Throw
|
2015-10-06 19:04:57 +00:00
|
|
|
}
|
|
|
|
}
|
2016-04-29 10:10:09 +00:00
|
|
|
|
|
|
|
Describe "Format-Wide DRT basic functionality" -Tags DRT{
|
2016-05-14 01:23:28 +00:00
|
|
|
It "Format-Wide with array should work" -Pending:($env:TRAVIS_OS_NAME -eq "osx") {
|
2016-04-29 10:10:09 +00:00
|
|
|
$al = (0..255)
|
|
|
|
$info = @{}
|
|
|
|
$info.array = $al
|
|
|
|
$result = $info | Format-Wide | Out-String
|
|
|
|
$result | Should Match "array"
|
|
|
|
}
|
|
|
|
|
|
|
|
It "Format-Wide with No Objects for End-To-End should work"{
|
|
|
|
$p = @{}
|
|
|
|
$result = $p | Format-Wide | Out-String
|
|
|
|
$result | Should BeNullOrEmpty
|
|
|
|
}
|
|
|
|
|
|
|
|
It "Format-Wide with Null Objects for End-To-End should work"{
|
|
|
|
$p = $null
|
|
|
|
$result = $p | Format-Wide | Out-String
|
|
|
|
$result | Should BeNullOrEmpty
|
|
|
|
}
|
|
|
|
|
|
|
|
It "Format-Wide with single line string for End-To-End should work"{
|
|
|
|
$p = "single line string"
|
|
|
|
$result = $p | Format-Wide | Out-String
|
|
|
|
$result | Should Match $p
|
|
|
|
}
|
|
|
|
|
|
|
|
It "Format-Wide with multiple line string for End-To-End should work"{
|
|
|
|
$p = "Line1\nLine2"
|
|
|
|
$result = $p | Format-Wide | Out-String
|
|
|
|
$result | Should Match "Line1"
|
|
|
|
$result | Should Match "Line2"
|
|
|
|
}
|
|
|
|
|
|
|
|
It "Format-Wide with string sequence for End-To-End should work"{
|
|
|
|
$p = "Line1","Line2"
|
|
|
|
$result = $p |Format-Wide | Out-String
|
|
|
|
$result | Should Match "Line1"
|
|
|
|
$result | Should Match "Line2"
|
|
|
|
}
|
|
|
|
|
2016-05-14 01:23:28 +00:00
|
|
|
It "Format-Wide with complex object for End-To-End should work" -Pending:($env:TRAVIS_OS_NAME -eq "osx") {
|
2016-04-29 10:10:09 +00:00
|
|
|
Add-Type -TypeDefinition "public enum MyDayOfWeek{Sun,Mon,Tue,Wed,Thr,Fri,Sat}"
|
|
|
|
$eto = New-Object MyDayOfWeek
|
|
|
|
$info = @{}
|
|
|
|
$info.intArray = 1,2,3,4
|
|
|
|
$info.arrayList = "string1","string2"
|
|
|
|
$info.enumerable = [MyDayOfWeek]$eto
|
|
|
|
$info.enumerableTestObject = $eto
|
|
|
|
$result = $info|Format-Wide|Out-String
|
|
|
|
$result | Should Match "intArray"
|
|
|
|
$result | Should Match "arrayList"
|
|
|
|
$result | Should Match "enumerable"
|
|
|
|
$result | Should Match "enumerableTestObject"
|
|
|
|
}
|
2016-05-18 07:34:17 +00:00
|
|
|
|
2016-05-18 08:30:12 +00:00
|
|
|
It "Format-Wide with multiple same class object with grouping should work" -Pending:($env:TRAVIS_OS_NAME -eq "osx"){
|
2016-05-18 07:34:17 +00:00
|
|
|
Add-Type -TypeDefinition "public class TestGroupingClass{public TestGroupingClass(string name,int length){Name = name;Length = length;}public string Name;public int Length;public string GroupingKey;}"
|
|
|
|
$testobject1 = New-Object TestGroupingClass 'name1',1
|
|
|
|
$testobject1.GroupingKey = "foo"
|
|
|
|
$testobject2 = New-Object TestGroupingClass 'name2',2
|
|
|
|
$testobject1.GroupingKey = "bar"
|
|
|
|
$testobject3 = New-Object TestGroupingClass 'name3',3
|
|
|
|
$testobject1.GroupingKey = "bar"
|
|
|
|
$testobjects = @($testobject1,$testobject2,$testobject3)
|
|
|
|
$result = $testobjects|Format-Wide -GroupBy GroupingKey|Out-String
|
|
|
|
$result | Should Match "GroupingKey: bar"
|
|
|
|
$result | Should Match "name1"
|
|
|
|
$result | Should Match " GroupingKey:"
|
|
|
|
$result | Should Match "name2\s+name3"
|
|
|
|
}
|
2016-05-14 01:23:28 +00:00
|
|
|
}
|