Functions/Assertions/BeIn.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

function PesterBeIn($value, $expectedArrayOfValues) {
    return [bool]($expectedArrayOfValues -contains $value)
}

function PesterBeInFailureMessage($value, $expectedArrayOfValues) {
    if(-not ([bool]($expectedArrayOfValues -contains $value))) {
        return "Expected: ${value} to be in collection [$($expectedArrayOfValues -join ',')] but was not found."
    }
}

function NotPesterBeInFailureMessage($value, $expectedArrayOfValues) {
    if([bool]($expectedArrayOfValues -contains $value)) {
        return "Expected: ${value} to not be in collection [$($expectedArrayOfValues -join ',')] but was found."
    }
}