@@ -927,7 +927,6 @@ Describe "Use-AzureRmProfile" {
927
927
Mock Install-Module { " Installing module..." }
928
928
Mock Import-Module - Verifiable { " Importing Module..." }
929
929
Mock Find-PotentialConflict {}
930
- if (($PSVersionTable.PSVersion.Major -ge 5 ) -and ($PSVersionTable.PSVersion.Minor -ge 1 )){
931
930
Context " Modules not installed" {
932
931
Mock Get-AzureRmModule - Verifiable {} - ParameterFilter {$Profile -eq " Profile1" -and $Module -eq " Module1" }
933
932
It " Should install modules" {
@@ -971,7 +970,6 @@ Describe "Use-AzureRmProfile" {
971
970
972
971
}
973
972
}
974
- }
975
973
Context " Invoke with invalid profile" {
976
974
It " Should throw" {
977
975
{ Use-AzureRmProfile - Profile ' WrongProfileName' } | Should Throw
@@ -983,7 +981,6 @@ Describe "Use-AzureRmProfile" {
983
981
{ Use-AzureRmProfile - Profile $null } | Should Throw
984
982
}
985
983
}
986
- if (($PSVersionTable.PSVersion.Major -ge 5 ) -and ($PSVersionTable.PSVersion.Minor -ge 1 )){
987
984
988
985
Context " Invoke with Scope as CurrentUser" {
989
986
Mock Get-AzureRmModule - Verifiable {} - ParameterFilter {$Profile -eq " Profile1" -and $Module -eq " Module1" }
@@ -1002,14 +999,12 @@ Describe "Use-AzureRmProfile" {
1002
999
Assert-VerifiableMocks
1003
1000
}
1004
1001
}
1005
- }
1006
1002
1007
1003
Context " Invoke with invalide module name" {
1008
1004
It " Should throw" {
1009
1005
{ Use-AzureRmProfile - Profile ' Profile1' - Module ' MockModule' } | Should Throw
1010
1006
}
1011
1007
}
1012
- if (($PSVersionTable.PSVersion.Major -ge 5 ) -and ($PSVersionTable.PSVersion.Minor -ge 1 )){
1013
1008
1014
1009
Context " Potential Conflict found" {
1015
1010
Mock Find-PotentialConflict - Verifiable { $true }
@@ -1029,10 +1024,9 @@ Describe "Use-AzureRmProfile" {
1029
1024
Mock Get-Module - Verifiable { $moduleObj }
1030
1025
It " Should skip importing module" {
1031
1026
$result = Use-AzureRmProfile - Profile ' Profile1' - ErrorVariable useError - ErrorAction SilentlyContinue
1032
- $useError -like " A different version of module Module1 is already imported in this session. Start a new PowerShell session and retry the operation. " | Should Be $true
1027
+ $useError.exception.message.contains ( " A different version of module" ) | Should Be $true
1033
1028
}
1034
1029
}
1035
- }
1036
1030
}
1037
1031
}
1038
1032
@@ -1041,16 +1035,15 @@ Describe "Install-AzureRmProfile" {
1041
1035
Mock Get-AzProfile - Verifiable { ($global :testProfileMap | ConvertFrom-Json ) }
1042
1036
Mock Get-AzureRmModule - Verifiable {} - ParameterFilter { $Profile -eq ' Profile1' -and $Module -eq ' Module1' }
1043
1037
Mock Get-AzureRmModule - Verifiable { " 1.0" } - ParameterFilter { $Profile -eq ' Profile1' -and $Module -eq ' Module2' }
1044
- if (( $PSVersionTable .PSVersion.Major -ge 5 ) -and ( $PSVersionTable .PSVersion.Minor -ge 1 )){
1045
-
1038
+ Mock Find-PotentialConflict - Verifiable { $false }
1039
+
1046
1040
Context " Invoke with valid profile name" {
1047
1041
Mock Install-Module - Verifiable { " Installing module Module1... Version 1.0" }
1048
1042
It " Should install Module1" {
1049
1043
(Install-AzureRmProfile - Profile ' Profile1' ) | Should be " Installing module Module1... Version 1.0"
1050
1044
Assert-VerifiableMocks
1051
1045
}
1052
1046
}
1053
- }
1054
1047
1055
1048
Context " Invoke with invalid profile name" {
1056
1049
It " Should throw" {
@@ -1063,7 +1056,6 @@ Describe "Install-AzureRmProfile" {
1063
1056
{ Install-AzureRmProfile - Profile $null } | Should Throw
1064
1057
}
1065
1058
}
1066
- if (($PSVersionTable.PSVersion.Major -ge 5 ) -and ($PSVersionTable.PSVersion.Minor -ge 1 )){
1067
1059
1068
1060
Context " Invoke with Scope as CurrentUser" {
1069
1061
Mock Get-AzureRmModule - Verifiable {} - ParameterFilter {$Profile -eq " Profile1" -and $Module -eq " Module1" }
@@ -1082,7 +1074,6 @@ Describe "Install-AzureRmProfile" {
1082
1074
Assert-VerifiableMocks
1083
1075
}
1084
1076
}
1085
- }
1086
1077
}
1087
1078
}
1088
1079
0 commit comments