From fd649c0f777ea44e7a46fb974492dcf311853a5b Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 8 Jun 2016 13:24:33 -0700 Subject: [PATCH] Revert "Merge pull request #1046 from PowerShell/GetMemberCommandTest" This reverts commit 7392c68bcb9df71cdc8598924f78bac1981e5c53, reversing changes made to 1ee6e4ef2d69e08c317f432c48783fc9267b322f. --- test/powershell/Get-Member.Tests.ps1 | 237 ---------------------- test/powershell/Update-TypeData.Tests.ps1 | 10 + 2 files changed, 10 insertions(+), 237 deletions(-) diff --git a/test/powershell/Get-Member.Tests.ps1 b/test/powershell/Get-Member.Tests.ps1 index cb5321523..06fb78de2 100644 --- a/test/powershell/Get-Member.Tests.ps1 +++ b/test/powershell/Get-Member.Tests.ps1 @@ -39,240 +39,3 @@ Describe "Get-Member" { Get-Member -InputObject $o | Should Not BeNullOrEmpty } } - -Describe "Get-Member DRT Unit Tests" -Tags DRT { - Context "Verify Get-Member with Class" { - BeforeAll { - Add-Type -TypeDefinition @" - public class Employee - { - private string firstName; - private string lastName; - private int yearsInMS; - - public string FirstName - { - get - { - return firstName; - } - set - { - firstName = value; - } - } - - - public string LastName - { - get - { - return lastName; - } - set - { - lastName = value; - } - } - - - public int YearsInMS - { - get - { - return yearsInMS; - } - set - { - yearsInMS = value; - } - } - - public void GetEmployee() {} - - public void SetEmployee() {} - - public Employee(string firstName, string lastName, int yearsInMS) - { - this.firstName = firstName; - this.lastName = lastName; - this.yearsInMS = yearsInMS; - } - } -"@ - - - $fileToDeleteName = Join-Path $TestDrive -ChildPath "getMemberTest.ps1xml" - $XMLFile= @" - - - Employee - - - PropertySetName - - FirstName - LastName - - - - FullSet - - FirstName - LastName - YearsInMS - - - - - - EmployeePartTime - - - PropertySetName - - FirstName - HoursPerWeek - - - - FullSet - - FirstName - LastName - HoursPerWeek - - - - - -"@ - - $XMLFile > $fileToDeleteName - Update-TypeData -AppendPath $fileToDeleteName - } - - It "Fail to get member without any input" { - try - { - Get-Member -MemberType All -ErrorAction Stop - Throw "Execution OK" - } - catch - { - $_.FullyQualifiedErrorId | Should Be 'NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand' - } - } - - It 'Get the expected Properties of "Employee" object' { - $emps = [Employee]::New("john", "smith", 5), [Employee]::New("joesph", "smith", 15), [Employee]::New("john", "smyth", 2) - $results = $emps | Get-Member -MemberType Property - $results.Length | Should Be 3 - $results[0].Name | Should Be "FirstName" - $results[1].Name | Should Be "LastName" - $results[2].Name | Should Be "YearsInMS" - } - - It 'Get the Public Methods of "Employee" object' { - $emps = [Employee]::New("john", "smith", 5), [Employee]::New("joesph", "smith", 15), [Employee]::New("john", "smyth", 2) - $methodList = "GetHashCode", "Equals", "ToString", "GetEmployee", "SetEmployee", "GetType" - $results = $emps | Get-Member -MemberType Method - $results.Length | Should Be $methodList.Length - $methodFound = @() - - for ($i = 0;$i -lt $methodList.Length;$i++) - { - for ($j = 0;$j -lt $results.Length;$j++) - { - if ($results[$j].Name.Equals($methodList[$i])) - { - $methodFound += $true - } - } - } - - for ($i = 0;$i -lt $methodList.Length;$i++) - { - $methodFound[$i] | Should Be $true - } - } - - It 'Get property sets defined in private members' { - $emps = [Employee]::New("john", "smith", 5), [Employee]::New("joesph", "smith", 15), [Employee]::New("john", "smyth", 2) - $results = $emps | Get-Member -MemberType PropertySet - $results.Length | Should Be 2 - $results[0].Name | Should Be "FullSet" - $results[1].Name | Should Be "PropertySetName" - } - } - - Context "Verify Get-Member with Static Parameter" { - It 'Get the static properties and methods of the object' { - $obj = New-Object -TypeName System.Int32 - $results = $obj | Get-Member -Static - $members = "MaxValue", "MinValue", "Parse", "TryParse" - foreach($member in $members) - { - if(!($results.Name -contains $member)) - { - Throw "Didn't find: $member" - } - } - } - - It "Get the static properties and methods of int instance" { - $results = 1 | Get-Member -Static - $members = "MaxValue", "MinValue", "Parse", "TryParse" - foreach($member in $members) - { - if(!($results.Name -contains $member)) - { - Throw "Didn't find: $member" - } - } - } - - It "Get the static properties and methods of int instance Wrapped" { - $results = [pscustomobject]1 | Get-Member -Static - $members = "MaxValue", "MinValue", "Parse", "TryParse" - foreach($member in $members) - { - if(!($results.Name -contains $member)) - { - Throw "Didn't find: $member" - } - } - } - } - - Context "Verify Get-Member with other parameters" { - It 'works with View Parameter' { - $results = [xml]'some text' | Get-Member -view adapted - $results.Length | Should Be 38 - } - - It 'Get hidden members'{ - $results = 'abc' | Get-Member -force - $hiddenMembers = "psbase", "psextended", "psadapted", "pstypenames", "psobject" - foreach($member in $hiddenMembers) - { - if(!($results.Name -contains $member)) - { - Throw "Didn't find: $member" - } - } - } - - It 'Get Set Property Accessors On PsBase'{ - $results = ('abc').psbase | Get-Member -force get_* - $expectedMembers = "get_Chars", "get_Length" - foreach($member in $expectedMembers) - { - if(!($results.Name -contains $member)) - { - Throw "Didn't find: $member" - } - } - } - } -} \ No newline at end of file diff --git a/test/powershell/Update-TypeData.Tests.ps1 b/test/powershell/Update-TypeData.Tests.ps1 index c57d40ec4..4c4f0e047 100644 --- a/test/powershell/Update-TypeData.Tests.ps1 +++ b/test/powershell/Update-TypeData.Tests.ps1 @@ -1,3 +1,13 @@ +Describe "Update-TypeData" { + + Context "Validate Update-Type updates correctly" { + + It "Should not throw upon reloading previous formatting file" { + { Update-TypeData } | Should Not throw + } + } +} + Describe "Update-TypeData basic functionality" -Tags DRT{ BeforeAll { $testfilename = "testfile.ps1xml"