Skip to content

Commit 5962cb4

Browse files
brettmillerbTylerLeonhardt
authored andcommitted
Added Pester, ShouldProcess and Calculated Property PS Snippets (#1764)
* Added Calculated Property and ShouldProcess Snippets * Added Pester Describe, Context & It Snippets * Placeholder Rename for calc property snippet * Fixed description for Calculated Property * Calc Property Enhanced Description Co-Authored-By: brettmillerb <[email protected]> * Amended the tab stop for calc-property to include .
1 parent 716929c commit 5962cb4

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

snippets/PowerShell.json

+67
Original file line numberDiff line numberDiff line change
@@ -952,5 +952,72 @@
952952
"#endregion"
953953
],
954954
"description": "Region Block for organizing and folding of your code"
955+
},
956+
"IfShouldProcess": {
957+
"prefix": "IfShouldProcess",
958+
"body": [
959+
"if (\\$PSCmdlet.ShouldProcess(\"${1:Target}\", \"${2:Operation}\")) {",
960+
"\t$0",
961+
"}"
962+
],
963+
"description": "Creates ShouldProcess block"
964+
},
965+
"CalculatedProperty": {
966+
"prefix": "Calculated-Property",
967+
"body": [
968+
"@{name='${1:PropertyName}';expression={${2:\\$_.PropertyValue}}}$0"
969+
],
970+
"description": "Creates a Calculated Property typically used with Select-Object."
971+
},
972+
"PesterDescribeContextIt": {
973+
"prefix": "Describe-Context-It-Pester",
974+
"body": [
975+
"Describe \"${1:DescribeName}\" {",
976+
"\tContext \"${2:ContextName}\" {",
977+
"\t\tIt \"${3:ItName}\" {",
978+
"\t\t\t${4:Assertion}",
979+
"\t\t}$0",
980+
"\t}",
981+
"}"
982+
],
983+
"description": "Pester Describe block with nested Context & It blocks"
984+
},
985+
"PesterDescribeBlock": {
986+
"prefix": "Describe-Pester",
987+
"body": [
988+
"Describe \"${1:DescribeName}\" {",
989+
"\t$0",
990+
"}"
991+
],
992+
"description": "Pester Describe block"
993+
},
994+
"PesterContextIt": {
995+
"prefix": "Context-It-Pester",
996+
"body": [
997+
"Context \"${1:ContextName}\" {",
998+
"\tIt \"${2:ItName}\" {",
999+
"\t\t${3:Assertion}",
1000+
"\t}$0",
1001+
"}"
1002+
],
1003+
"description": "Pester - Context block with nested It block"
1004+
},
1005+
"PesterContext": {
1006+
"prefix": "Context-Pester",
1007+
"body": [
1008+
"Context \"${1:ContextName}\" {",
1009+
"\t$0",
1010+
"}"
1011+
],
1012+
"description": "Pester - Context block"
1013+
},
1014+
"PesterIt": {
1015+
"prefix": "It-Pester",
1016+
"body": [
1017+
"It \"${1:ItName}\" {",
1018+
"\t${2:Assertion}",
1019+
"}$0"
1020+
],
1021+
"description": "Pester - It block"
9551022
}
9561023
}

0 commit comments

Comments
 (0)