From 1d6ab11ea82ac66e9f1bd0e3276825fb4f4d048d Mon Sep 17 00:00:00 2001 From: JumpingYang001 Date: Thu, 19 May 2016 22:06:14 -0700 Subject: [PATCH] Update fix based on comment for DisplayXML Pester Test --- test/powershell/Format-Custom.Tests.ps1 | 16 ++++++++-------- test/powershell/Format-List.Tests.ps1 | 14 +++++++------- test/powershell/Format-Wide.Tests.ps1 | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/powershell/Format-Custom.Tests.ps1 b/test/powershell/Format-Custom.Tests.ps1 index 0b225966e..64afb70ff 100644 --- a/test/powershell/Format-Custom.Tests.ps1 +++ b/test/powershell/Format-Custom.Tests.ps1 @@ -198,8 +198,8 @@ class MyContainer1 $objectList = @($c1,$c2,$cDeep,$cx) $result = $objectList | Format-Custom | Out-String - $result = $result -replace "{","" -replace "}","" -replace " ","" -replace "`n","" -replace "\r","" - $expectedResult = $expectedResult -replace "{","" -replace "}","" -replace " ","" -replace "`n","" -replace "\r","" + $result = $result -replace "[{} `n\r]","" + $expectedResult = $expectedResult -replace "[{} `n\r]","" $result | Should Be $expectedResult } @@ -220,8 +220,8 @@ class MyContainer1 $objectList = @($c) $result = $objectList | Format-Custom | Out-String - $result = $result -replace "{","" -replace "}","" -replace " ","" -replace "`n","" -replace "\r","" - $expectedResult = $expectedResult -replace "{","" -replace "}","" -replace " ","" -replace "`n","" -replace "\r","" + $result = $result -replace "[{} `n\r]","" + $expectedResult = $expectedResult -replace "[{} `n\r]","" $result | Should Be $expectedResult } @@ -263,8 +263,8 @@ class MyContainer1 $objectList = @($root) $result = $objectList | Format-Custom | Out-String - $result = $result -replace "{","" -replace "}","" -replace " ","" -replace "`n","" -replace "\r","" - $expectedResult = $expectedResult -replace "{","" -replace "}","" -replace " ","" -replace "`n","" -replace "\r","" + $result = $result -replace "[{} `n\r]","" + $expectedResult = $expectedResult -replace "[{} `n\r]","" $result | Should Be $expectedResult } @@ -293,8 +293,8 @@ class MyLeaf2 $objectList = @($leaf1,$leaf2) $result = $objectList | Format-Custom | Out-String - $result = $result -replace "{","" -replace "}","" -replace " ","" -replace "`n","" -replace "\r","" - $expectedResult = $expectedResult -replace "{","" -replace "}","" -replace " ","" -replace "`n","" -replace "\r","" + $result = $result -replace "[{} `n\r]","" + $expectedResult = $expectedResult -replace "[{} `n\r]","" $result | Should Be $expectedResult } } diff --git a/test/powershell/Format-List.Tests.ps1 b/test/powershell/Format-List.Tests.ps1 index 0c24fe585..bd43b01d4 100644 --- a/test/powershell/Format-List.Tests.ps1 +++ b/test/powershell/Format-List.Tests.ps1 @@ -108,7 +108,7 @@ Describe "Format-List DRT basic functionality" -Tags DRT{ It "Format-List with complex object for End-To-End should work" -Pending:($env:TRAVIS_OS_NAME -eq "osx") { Add-Type -TypeDefinition "public enum MyDayOfWeek{Sun,Mon,Tue,Wed,Thr,Fri,Sat}" - $eto = New-Object MyDayOfWeek + $eto = [MyDayOfWeek]::New() $info = @{} $info.intArray = 1,2,3,4 $info.arrayList = "string1","string2" @@ -127,9 +127,9 @@ Describe "Format-List DRT basic functionality" -Tags DRT{ It "Format-List with multiple same class object should work" -Pending:($env:TRAVIS_OS_NAME -eq "osx"){ Add-Type -TypeDefinition "public class TestClass{public TestClass(string name,int length){Name = name;Length = length;}public string Name;public int Length;}" - $testobject1 = New-Object TestClass 'name1',1 - $testobject2 = New-Object TestClass 'name2',2 - $testobject3 = New-Object TestClass 'name3',3 + $testobject1 = [TestClass]::New('name1',1) + $testobject2 = [TestClass]::New('name2',2) + $testobject3 = [TestClass]::New('name3',3) $testobjects = @($testobject1,$testobject2,$testobject3) $result = $testobjects|Format-List|Out-String $result | Should Match "Name : name1" @@ -143,9 +143,9 @@ Describe "Format-List DRT basic functionality" -Tags DRT{ It "Format-List with multiple different class object should work" -Pending:($env:TRAVIS_OS_NAME -eq "osx"){ Add-Type -TypeDefinition "public class TestClass{public TestClass(string name,int length){Name = name;Length = length;}public string Name;public int Length;}" Add-Type -TypeDefinition "public class TestClass2{public TestClass2(string name,string value,int length){Name = name;Value = value; Length = length;}public string Name;public string Value;public int Length;}" - $testobject1 = New-Object TestClass 'name1',1 - $testobject2 = New-Object TestClass2 'name2',"value2",2 - $testobject3 = New-Object TestClass 'name3',3 + $testobject1 = [TestClass]::New('name1',1) + $testobject2 = [TestClass2]::New('name2',"value2",2) + $testobject3 = [TestClass]::New('name3',3) $testobjects = @($testobject1,$testobject2,$testobject3) $result = $testobjects|Format-List|Out-String $result | Should Match "Name : name1" diff --git a/test/powershell/Format-Wide.Tests.ps1 b/test/powershell/Format-Wide.Tests.ps1 index 015752378..c3a51491a 100644 --- a/test/powershell/Format-Wide.Tests.ps1 +++ b/test/powershell/Format-Wide.Tests.ps1 @@ -97,11 +97,11 @@ Describe "Format-Wide DRT basic functionality" -Tags DRT{ It "Format-Wide with multiple same class object with grouping should work" -Pending:($env:TRAVIS_OS_NAME -eq "osx"){ 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 = [TestGroupingClass]::New('name1',1) $testobject1.GroupingKey = "foo" - $testobject2 = New-Object TestGroupingClass 'name2',2 + $testobject2 = [TestGroupingClass]::New('name2',2) $testobject1.GroupingKey = "bar" - $testobject3 = New-Object TestGroupingClass 'name3',3 + $testobject3 = [TestGroupingClass]::New('name3',3) $testobject1.GroupingKey = "bar" $testobjects = @($testobject1,$testobject2,$testobject3) $result = $testobjects|Format-Wide -GroupBy GroupingKey|Out-String