Skip to content

Added Pester, ShouldProcess and Calculated Property PS Snippets #1764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 5, 2019
67 changes: 67 additions & 0 deletions snippets/PowerShell.json
Original file line number Diff line number Diff line change
Expand Up @@ -952,5 +952,72 @@
"#endregion"
],
"description": "Region Block for organizing and folding of your code"
},
"IfShouldProcess": {
"prefix": "IfShouldProcess",
"body": [
"if (\\$PSCmdlet.ShouldProcess(\"${1:Target}\", \"${2:Operation}\")) {",
"\t$0",
"}"
],
"description": "Creates ShouldProcess block"
},
"CalculatedProperty": {
"prefix": "Calculated-Property",
"body": [
"@{name='${1:PropertyName}';expression={${2:\\$_.PropertyValue}}}$0"
],
"description": "Creates a Calculated Property typically used with Select-Object."
},
"PesterDescribeContextIt": {
"prefix": "Describe-Context-It-Pester",
"body": [
"Describe \"${1:DescribeName}\" {",
"\tContext \"${2:ContextName}\" {",
"\t\tIt \"${3:ItName}\" {",
"\t\t\t${4:Assertion}",
"\t\t}$0",
"\t}",
"}"
],
"description": "Pester Describe block with nested Context & It blocks"
},
"PesterDescribeBlock": {
"prefix": "Describe-Pester",
"body": [
"Describe \"${1:DescribeName}\" {",
"\t$0",
"}"
],
"description": "Pester Describe block"
},
"PesterContextIt": {
"prefix": "Context-It-Pester",
"body": [
"Context \"${1:ContextName}\" {",
"\tIt \"${2:ItName}\" {",
"\t\t${3:Assertion}",
"\t}$0",
"}"
],
"description": "Pester - Context block with nested It block"
},
"PesterContext": {
"prefix": "Context-Pester",
"body": [
"Context \"${1:ContextName}\" {",
"\t$0",
"}"
],
"description": "Pester - Context block"
},
"PesterIt": {
"prefix": "It-Pester",
"body": [
"It \"${1:ItName}\" {",
"\t${2:Assertion}",
"}$0"
],
"description": "Pester - It block"
}
}