From 97c009226fb4a80dc4e9a412d174cf2f119c5fb1 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 21 Jun 2018 16:17:34 -0700 Subject: [PATCH 1/6] Add simple tests for module specifications --- .../Module/ModuleSpecification.Tests.ps1 | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 test/powershell/engine/Module/ModuleSpecification.Tests.ps1 diff --git a/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 b/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 new file mode 100644 index 00000000000..27e8585bb43 --- /dev/null +++ b/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 @@ -0,0 +1,110 @@ +function PermuteOnProperty +{ + param([hashtable[]]$Object, [string]$Key, [object]$Value) + + foreach ($obj in $Object) + { + $obj.Clone() + } + + foreach ($obj in $Object) + { + $o2 = $obj.Clone() + $o2.$Key = $Value + $o2 + } +} + +function PermuteObject +{ + param([hashtable]$InitialObject, [hashtable]$KeyValues) + + $l = $InitialObject + foreach ($key in $KeyValues.Keys) + { + $l = PermuteOnProperty -Object $l -Key $key -Value $KeyValues[$key] + } + + $l +} + +$guid = [guid]::NewGuid() + +$modSpecRequired = @{ + ModuleName = "ModSpecRequired" + RequiredVersion = "3.0.2" +} + +$requiredOptionalConstraints = @{ Guid = $guid } + +$modSpecRange = @{ + ModuleName = "ModSpecRequired" + ModuleVersion = "3.0.1" +} + +$rangeOptionalConstraints = @{ MaximumVersion = "3.2.0"; Guid = $guid } + +$modSpecInvalid = @{ + ModuleName = "ModSpecInvalid" + Guid = $guid + ModuleVersion = "1.2.3" + RequiredVersion = "1.2.4" +} + +Describe "Valid ModuleSpecification objects" { + BeforeAll { + $testCases = [System.Collections.Generic.List[hashtable]]::new() + + foreach ($case in (PermuteObject -InitialObject $modSpecRequired -KeyValues $requiredOptionalConstraints)) + { + $testCases.Add(@{ + ModuleSpecification = $case + Keys = ($case.Keys -join ",") + }) + } + + foreach ($case in (PermuteObject -InitialObject $modSpecRange -KeyValues $rangeOptionalConstraints)) + { + $testCases.Add(@{ + ModuleSpecification = $case + Keys = ($case.Keys -join ",") + }) + } + + $testCases = $testCases.ToArray() + } + + It "Can be created from Hashtable with keys: " -TestCases $testCases { + param([Microsoft.PowerShell.Commands.ModuleSpecification]$ModuleSpecification, [string]$Keys) + [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) | Should -Not -BeNull + } + + It "Can be reconstructed from self.ToString() with keys: " -TestCases $testCases { + param([Microsoft.PowerShell.Commands.ModuleSpecification]$ModuleSpecification, [string]$Keys) + + [Microsoft.PowerShell.Commands.ModuleSpecification]$clone = $null + [Microsoft.PowerShell.Commands.ModuleSpecification]::TryParse(($ModuleSpecification.ToString()), [ref]$clone) | Should -BeTrue + + $clone.Name | Should -Be $ModuleSpecification.Name + + if ($ModuleSpecification.RequiredVersion) + { + $clone.RequiredVersion | Should -Be $ModuleSpecification.RequiredVersion + } + + if ($ModuleSpecification.Version) + { + $clone.Version | Should -Be $ModuleSpecification.Version + } + + if ($ModuleSpecification.MaximumVersion) + { + $clone.MaximumVersion | Should -Be $ModuleSpecification.MaximumVersion + } + + if ($ModuleSpecification.Guid) + { + $clone.Guid | Should -Be $ModuleSpecification.Guid + } + } +} \ No newline at end of file From d9b363250e652c7f69d42f71b242fb0230961e23 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 21 Jun 2018 16:21:01 -0700 Subject: [PATCH 2/6] Renamed permutation functions --- .../Module/ModuleSpecification.Tests.ps1 | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 b/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 index 27e8585bb43..84e5bcca0db 100644 --- a/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 +++ b/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 @@ -1,28 +1,28 @@ -function PermuteOnProperty +function PermuteHashtableOnProperty { - param([hashtable[]]$Object, [string]$Key, [object]$Value) + param([hashtable[]]$Hashtable, [string]$Key, [object]$Value) - foreach ($obj in $Object) + foreach ($ht in $Hashtable) { - $obj.Clone() + $ht.Clone() } - foreach ($obj in $Object) + foreach ($ht in $Hashtable) { - $o2 = $obj.Clone() - $o2.$Key = $Value - $o2 + $ht2 = $ht.Clone() + $ht2.$Key = $Value + $ht2 } } -function PermuteObject +function PermuteHashtable { - param([hashtable]$InitialObject, [hashtable]$KeyValues) + param([hashtable]$InitialTable, [hashtable]$KeyValues) - $l = $InitialObject + $l = $InitialTable foreach ($key in $KeyValues.Keys) { - $l = PermuteOnProperty -Object $l -Key $key -Value $KeyValues[$key] + $l = PermuteOnProperty -Hashtable $l -Key $key -Value $KeyValues[$key] } $l @@ -55,7 +55,7 @@ Describe "Valid ModuleSpecification objects" { BeforeAll { $testCases = [System.Collections.Generic.List[hashtable]]::new() - foreach ($case in (PermuteObject -InitialObject $modSpecRequired -KeyValues $requiredOptionalConstraints)) + foreach ($case in (PermuteHashtable -InitialObject $modSpecRequired -KeyValues $requiredOptionalConstraints)) { $testCases.Add(@{ ModuleSpecification = $case @@ -63,7 +63,7 @@ Describe "Valid ModuleSpecification objects" { }) } - foreach ($case in (PermuteObject -InitialObject $modSpecRange -KeyValues $rangeOptionalConstraints)) + foreach ($case in (PermuteHashtable -InitialObject $modSpecRange -KeyValues $rangeOptionalConstraints)) { $testCases.Add(@{ ModuleSpecification = $case @@ -107,4 +107,4 @@ Describe "Valid ModuleSpecification objects" { $clone.Guid | Should -Be $ModuleSpecification.Guid } } -} \ No newline at end of file +} From 746c81f8208d2d29214a4c26d56bc35593a23b49 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 21 Jun 2018 21:34:32 -0700 Subject: [PATCH 3/6] [Feature] Add comparison tests --- .../Module/ModuleSpecification.Tests.ps1 | 207 +++++++++++++++--- 1 file changed, 177 insertions(+), 30 deletions(-) diff --git a/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 b/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 index 84e5bcca0db..82ade855ea8 100644 --- a/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 +++ b/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 @@ -1,3 +1,9 @@ + +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +# Take a hashtable and return two copies, +# one with the key/value pair, the other without function PermuteHashtableOnProperty { param([hashtable[]]$Hashtable, [string]$Key, [object]$Value) @@ -15,6 +21,9 @@ function PermuteHashtableOnProperty } } +# Take a base hashtable and produce all possible +# combinations of that hashtable with the keys +# and values in the key/value hashtable function PermuteHashtable { param([hashtable]$InitialTable, [hashtable]$KeyValues) @@ -22,7 +31,7 @@ function PermuteHashtable $l = $InitialTable foreach ($key in $KeyValues.Keys) { - $l = PermuteOnProperty -Hashtable $l -Key $key -Value $KeyValues[$key] + $l = PermuteHashtableOnProperty -Hashtable $l -Key $key -Value $KeyValues[$key] } $l @@ -44,18 +53,12 @@ $modSpecRange = @{ $rangeOptionalConstraints = @{ MaximumVersion = "3.2.0"; Guid = $guid } -$modSpecInvalid = @{ - ModuleName = "ModSpecInvalid" - Guid = $guid - ModuleVersion = "1.2.3" - RequiredVersion = "1.2.4" -} +Describe "ModuleSpecification objects and logic" { -Describe "Valid ModuleSpecification objects" { BeforeAll { $testCases = [System.Collections.Generic.List[hashtable]]::new() - foreach ($case in (PermuteHashtable -InitialObject $modSpecRequired -KeyValues $requiredOptionalConstraints)) + foreach ($case in (PermuteHashtable -InitialTable $modSpecRequired -KeyValues $requiredOptionalConstraints)) { $testCases.Add(@{ ModuleSpecification = $case @@ -63,7 +66,7 @@ Describe "Valid ModuleSpecification objects" { }) } - foreach ($case in (PermuteHashtable -InitialObject $modSpecRange -KeyValues $rangeOptionalConstraints)) + foreach ($case in (PermuteHashtable -InitialTable $modSpecRange -KeyValues $rangeOptionalConstraints)) { $testCases.Add(@{ ModuleSpecification = $case @@ -74,37 +77,181 @@ Describe "Valid ModuleSpecification objects" { $testCases = $testCases.ToArray() } - It "Can be created from Hashtable with keys: " -TestCases $testCases { - param([Microsoft.PowerShell.Commands.ModuleSpecification]$ModuleSpecification, [string]$Keys) - [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) | Should -Not -BeNull + Context "ModuleSpecification construction and string parsing" { + + BeforeAll { + $differentFieldCases = @( + @{ + TestName = "Guid" + ModSpec1 = @{ Guid = [guid]::NewGuid(); ModuleName = "TestModule"; ModuleVersion = "1.0" } + ModSpec2 = @{ Guid = [guid]::NewGuid(); ModuleName = "TestModule"; ModuleVersion = "1.0" } + }, + @{ + TestName = "RequiredVersion" + ModSpec1 = @{ ModuleName = "Module"; RequiredVersion = "3.0" } + ModSpec2 = @{ ModuleName = "Module"; RequiredVersion = "3.1" } + }, + @{ + TestName = "Version/MaxVersion-present" + ModSpec1 = @{ ModuleName = "ThirdModule"; ModuleVersion = "2.1" } + ModSpec2 = @{ ModuleName = "ThirdModule"; MaximumVersion = "2.1" } + }, + @{ + TestName = "RequiredVersion/Version-present" + ModSpec1 = @{ ModuleName = "FourthModule"; RequiredVersion = "3.0" } + ModSpec2 = @{ ModuleName = "FourthModule"; ModuleVersion = "3.0" } + } + ) + } + + It "Can be created from a name" { + $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]::new("NamedModule") + $ms | Should -Not -BeNull + $ms.Name | Should -BeExactly "NamedModule" + } + + It "Can be created from Hashtable with keys: " -TestCases $testCases { + param([hashtable]$ModuleSpecification, [string]$Keys) + $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) + + $ms.Name | Should -BeExactly $ModuleSpecification.ModuleName + + if ($ModuleSpecification.Guid) + { + $ms.Guid | Should -Be $ModuleSpecification.Guid + } + + if ($ModuleSpecification.ModuleVersion) + { + $ms.Version | Should -Be $ModuleSpecification.ModuleVersion + } + + if ($ModuleSpecification.RequiredVersion) + { + $ms.RequiredVersion | Should -Be $ModuleSpecification.RequiredVersion + } + + if ($ModuleSpecification.MaximumVersion) + { + $ms.MaximumVersion | Should -Be $ModuleSpecification.MaximumVersion + } + } + + It "Can be reconstructed from self.ToString() with keys: " -TestCases $testCases { + param([hashtable]$ModuleSpecification, [string]$Keys) + + $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) + + [Microsoft.PowerShell.Commands.ModuleSpecification]$clone = $null + [Microsoft.PowerShell.Commands.ModuleSpecification]::TryParse(($ms.ToString()), [ref]$clone) | Should -BeTrue + + $clone.Name | Should -Be $ModuleSpecification.ModuleName + + if ($ModuleSpecification.RequiredVersion) + { + $clone.RequiredVersion | Should -Be $ModuleSpecification.RequiredVersion + } + + if ($ModuleSpecification.Version) + { + $clone.Version | Should -Be $ModuleSpecification.Version + } + + if ($ModuleSpecification.MaximumVersion) + { + $clone.MaximumVersion | Should -Be $ModuleSpecification.MaximumVersion + } + + if ($ModuleSpecification.Guid) + { + $clone.Guid | Should -Be $ModuleSpecification.Guid + } + } } - It "Can be reconstructed from self.ToString() with keys: " -TestCases $testCases { - param([Microsoft.PowerShell.Commands.ModuleSpecification]$ModuleSpecification, [string]$Keys) + Context "ModuleSpecification comparison" { - [Microsoft.PowerShell.Commands.ModuleSpecification]$clone = $null - [Microsoft.PowerShell.Commands.ModuleSpecification]::TryParse(($ModuleSpecification.ToString()), [ref]$clone) | Should -BeTrue + BeforeAll { + $modSpecAsm = [Microsoft.PowerShell.Commands.ModuleSpecification].Assembly + $modSpecComparerType = $modSpecAsm.GetType("Microsoft.PowerShell.Commands.ModuleSpecificationComparer") + $comparer = [System.Activator]::CreateInstance($modSpecComparerType) + } - $clone.Name | Should -Be $ModuleSpecification.Name + It "Module specifications with same fields are equal" -TestCases $testCases { + param([hashtable]$ModuleSpecification, [string]$Keys) - if ($ModuleSpecification.RequiredVersion) - { - $clone.RequiredVersion | Should -Be $ModuleSpecification.RequiredVersion + $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) + $ms2 = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) + + $comparer.Equals($ms, $ms2) | Should -BeTrue } - if ($ModuleSpecification.Version) - { - $clone.Version | Should -Be $ModuleSpecification.Version + It "Module specifications with same fields have the same hash code" -TestCases $testCases { + param([hashtable]$ModuleSpecification, [string]$Keys) + + $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) + $ms2 = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) + + $comparer.GetHashCode($ms) | Should -Be $comparer.GetHashCode($ms2) } - if ($ModuleSpecification.MaximumVersion) - { - $clone.MaximumVersion | Should -Be $ModuleSpecification.MaximumVersion + It "Module specifications with different fields are not equal" -TestCases $differentFieldCases { + param($TestName, $ModSpec1, $ModSpec2) + $ms1 = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModSpec1) + $ms2 = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModSpec2) + + $comparer.Equals($ms1, $ms2) | Should -BeFalse } - if ($ModuleSpecification.Guid) - { - $clone.Guid | Should -Be $ModuleSpecification.Guid + It "Compares two null module specifications as equal" { + $comparer.Equals($null, $null) | Should -BeTrue + } + + It "Compares a null module specification with another as unequal" { + $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]::new(@{ + MOduleName = "NonNullModule" + Guid = [guid]::NewGuid() + RequiredVersion = "3.2.1" + }) + + $comparer.Equals($ms, $null) | Should -BeFalse + } + + It "Succeeds to get a hash code from a null module specification" { + $comparer.GetHashCode($null) | Should -Not -BeNull + } + } + + Context "Invalid ModuleSpecification initialization" { + BeforeAll { + $testCases = @( + @{ + TestName = "Version+RequiredVersion" + ModuleSpecification = @{ Name = "BadVersionModule"; ModuleVersion = "3.1"; RequiredVersion = "3.1" } + }, + @{ + TestName = "NoName" + ModuleSpecification = @{ ModuleVersion = "0.2" } + }, + @{ + TestName = "BadField" + ModuleSpecification = @{ Name = "StrangeFieldModule"; RequiredVersion = "7.4"; Duck = "1.2" } + }, + @{ + TestName = "BadType" + ModuleSpecification = @{ Name = "BadTypeModule"; RequiredVersion = "Hello!" } + } + ) + } + + It "Cannot create from a null argument" { + { [Microsoft.PowerShell.Commands.ModuleSpecification]::new($null) } | Should -Throw + } + + It "Cannot create from invalid module hashtables: " -TestCases $testCases { + param([string]$TestName, [hashtable]$ModuleSpecification) + + { [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) } | Should -Throw } } } From cff4aae8869317e29199d847bb6e7c2a64d4bd17 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 21 Jun 2018 21:52:26 -0700 Subject: [PATCH 4/6] Add CI tag to Describe block --- test/powershell/engine/Module/ModuleSpecification.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 b/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 index 82ade855ea8..7e610d506bc 100644 --- a/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 +++ b/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 @@ -53,7 +53,7 @@ $modSpecRange = @{ $rangeOptionalConstraints = @{ MaximumVersion = "3.2.0"; Guid = $guid } -Describe "ModuleSpecification objects and logic" { +Describe "ModuleSpecification objects and logic" -Tag "CI" { BeforeAll { $testCases = [System.Collections.Generic.List[hashtable]]::new() From c7312d2239fdaccaf4838a0e7a198fe4b1601573 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 21 Jun 2018 21:56:45 -0700 Subject: [PATCH 5/6] Remove newline at top of file --- test/powershell/engine/Module/ModuleSpecification.Tests.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 b/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 index 7e610d506bc..81876fcd332 100644 --- a/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 +++ b/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 @@ -1,4 +1,3 @@ - # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. From bed3e50212e633b104dafd4b36e826de0c5359f3 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Fri, 22 Jun 2018 17:04:22 -0700 Subject: [PATCH 6/6] Add using namespace to shorten type names --- .../Module/ModuleSpecification.Tests.ps1 | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 b/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 index 81876fcd332..f41f3a262f3 100644 --- a/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 +++ b/test/powershell/engine/Module/ModuleSpecification.Tests.ps1 @@ -1,6 +1,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +using namespace Microsoft.PowerShell.Commands + # Take a hashtable and return two copies, # one with the key/value pair, the other without function PermuteHashtableOnProperty @@ -104,14 +106,14 @@ Describe "ModuleSpecification objects and logic" -Tag "CI" { } It "Can be created from a name" { - $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]::new("NamedModule") + $ms = [ModuleSpecification]::new("NamedModule") $ms | Should -Not -BeNull $ms.Name | Should -BeExactly "NamedModule" } It "Can be created from Hashtable with keys: " -TestCases $testCases { param([hashtable]$ModuleSpecification, [string]$Keys) - $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) + $ms = [ModuleSpecification]::new($ModuleSpecification) $ms.Name | Should -BeExactly $ModuleSpecification.ModuleName @@ -139,10 +141,10 @@ Describe "ModuleSpecification objects and logic" -Tag "CI" { It "Can be reconstructed from self.ToString() with keys: " -TestCases $testCases { param([hashtable]$ModuleSpecification, [string]$Keys) - $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) + $ms = [ModuleSpecification]::new($ModuleSpecification) - [Microsoft.PowerShell.Commands.ModuleSpecification]$clone = $null - [Microsoft.PowerShell.Commands.ModuleSpecification]::TryParse(($ms.ToString()), [ref]$clone) | Should -BeTrue + [ModuleSpecification]$clone = $null + [ModuleSpecification]::TryParse(($ms.ToString()), [ref]$clone) | Should -BeTrue $clone.Name | Should -Be $ModuleSpecification.ModuleName @@ -171,7 +173,7 @@ Describe "ModuleSpecification objects and logic" -Tag "CI" { Context "ModuleSpecification comparison" { BeforeAll { - $modSpecAsm = [Microsoft.PowerShell.Commands.ModuleSpecification].Assembly + $modSpecAsm = [ModuleSpecification].Assembly $modSpecComparerType = $modSpecAsm.GetType("Microsoft.PowerShell.Commands.ModuleSpecificationComparer") $comparer = [System.Activator]::CreateInstance($modSpecComparerType) } @@ -179,8 +181,8 @@ Describe "ModuleSpecification objects and logic" -Tag "CI" { It "Module specifications with same fields are equal" -TestCases $testCases { param([hashtable]$ModuleSpecification, [string]$Keys) - $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) - $ms2 = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) + $ms = [ModuleSpecification]::new($ModuleSpecification) + $ms2 = [ModuleSpecification]::new($ModuleSpecification) $comparer.Equals($ms, $ms2) | Should -BeTrue } @@ -188,16 +190,16 @@ Describe "ModuleSpecification objects and logic" -Tag "CI" { It "Module specifications with same fields have the same hash code" -TestCases $testCases { param([hashtable]$ModuleSpecification, [string]$Keys) - $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) - $ms2 = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) + $ms = [ModuleSpecification]::new($ModuleSpecification) + $ms2 = [ModuleSpecification]::new($ModuleSpecification) $comparer.GetHashCode($ms) | Should -Be $comparer.GetHashCode($ms2) } It "Module specifications with different fields are not equal" -TestCases $differentFieldCases { param($TestName, $ModSpec1, $ModSpec2) - $ms1 = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModSpec1) - $ms2 = [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModSpec2) + $ms1 = [ModuleSpecification]::new($ModSpec1) + $ms2 = [ModuleSpecification]::new($ModSpec2) $comparer.Equals($ms1, $ms2) | Should -BeFalse } @@ -207,7 +209,7 @@ Describe "ModuleSpecification objects and logic" -Tag "CI" { } It "Compares a null module specification with another as unequal" { - $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]::new(@{ + $ms = [ModuleSpecification]::new(@{ MOduleName = "NonNullModule" Guid = [guid]::NewGuid() RequiredVersion = "3.2.1" @@ -244,13 +246,13 @@ Describe "ModuleSpecification objects and logic" -Tag "CI" { } It "Cannot create from a null argument" { - { [Microsoft.PowerShell.Commands.ModuleSpecification]::new($null) } | Should -Throw + { [ModuleSpecification]::new($null) } | Should -Throw } It "Cannot create from invalid module hashtables: " -TestCases $testCases { param([string]$TestName, [hashtable]$ModuleSpecification) - { [Microsoft.PowerShell.Commands.ModuleSpecification]::new($ModuleSpecification) } | Should -Throw + { [ModuleSpecification]::new($ModuleSpecification) } | Should -Throw } } }