@@ -11,10 +11,6 @@ InModuleScope "Handlers" {
1111 Clear-MockEnvironment
1212 }
1313
14- Mock Get-VstsTaskVariable { return " default-string" }
15- Mock Get-VstsTaskVariable { return 1 } - ParameterFilter { $AsInt -eq $true }
16- Mock Get-VstsTaskVariable { return $true } - ParameterFilter { $AsBool -eq $true }
17-
1814 $SchemaDefinitionPath = " $PSScriptRoot /resource/SFA.DAS.Test.schema.json"
1915 $SchemaDefinition = Get-Content - Path $SchemaDefinitionPath - Raw
2016 $SchemaObject = [Newtonsoft.Json.Schema.JSchema , Newtonsoft.Json.Schema , Version = 2.0 .0.0 , Culture = neutral , PublicKeyToken = 30ad4fe6b2a6aeed ]::Parse($SchemaDefinition )
@@ -23,52 +19,48 @@ InModuleScope "Handlers" {
2319 Context " When given a valid properties object" {
2420
2521 It " Should return a string when no parameters are passed" {
26-
22+ Mock Get-VstsTaskVariable { return " default-string " }
2723 $Property = Get-SchemaProperty - PropertyObject $SchemaObject.Properties [" PaymentsString" ]
2824 $Property | Should BeOfType [string ]
2925 Assert-MockCalled - CommandName Get-VstsTaskVariable - Times 1
3026 }
3127
3228 It " Should return an int when -AsInt is passed" {
33-
29+ Mock Get-VstsTaskVariable { return " 1 " }
3430 $Property = Get-SchemaProperty - PropertyObject $SchemaObject.Properties [" PaymentsInt" ] - AsInt
3531 $Property | Should BeOfType [int ]
36- Assert-MockCalled - CommandName Get-VstsTaskVariable - ParameterFilter { $AsInt -eq $true } - Times 1
32+ Assert-MockCalled - CommandName Get-VstsTaskVariable - Times 1
3733 }
3834
3935 It " Should return a decimal when -AsNumber is passed" {
40-
4136 Mock Get-VstsTaskVariable { return " 1.0" }
4237 $Property = Get-SchemaProperty - PropertyObject $SchemaObject.Properties [" PaymentsNumber" ] - AsNumber
4338 $Property | Should BeOfType [decimal ]
4439 Assert-MockCalled - CommandName Get-VstsTaskVariable - Times 1
4540 }
4641
4742 It " Should return an array when -AsArray is passed" {
48-
4943 Mock Get-VstsTaskVariable { return " ['one','two','three']" }
5044 $Property = Get-SchemaProperty - PropertyObject $SchemaObject.Properties [" PaymentsArray" ] - AsArray
5145 $Property.GetType ().BaseType.Name | Should Be ' Array'
5246 Assert-MockCalled - CommandName Get-VstsTaskVariable - Times 1
5347 }
5448
5549 It " Should return an bool when -AsBool is passed" {
56-
50+ Mock Get-VstsTaskVariable { return " True " }
5751 $Property = Get-SchemaProperty - PropertyObject $SchemaObject.Properties [" PaymentsBool" ] - AsBool
5852 $Property | Should BeOfType [bool ]
59- Assert-MockCalled - CommandName Get-VstsTaskVariable - ParameterFilter { $AsBool -eq $true } - Times 1
53+ Assert-MockCalled - CommandName Get-VstsTaskVariable - Times 1
6054 }
6155
6256 It " Should return the default value if no environment variable can be found and the default property is populated" {
63-
6457 Mock Get-VstsTaskVariable { return $null }
6558 $Property = Get-SchemaProperty - PropertyObject $SchemaObject.Properties [" PaymentsDefaultValue" ]
6659 $Property | Should Be " default-value"
6760 Assert-MockCalled - CommandName Get-VstsTaskVariable - Times 5
6861 }
6962
7063 It " Should throw an exception if no value can be found" {
71-
7264 Mock Get-VstsTaskVariable { return $null }
7365 { Get-SchemaProperty - PropertyObject $SchemaObject.Properties [" PaymentsString" ] } | Should Throw
7466 Assert-MockCalled - CommandName Get-VstsTaskVariable - Times 5
0 commit comments