Skip to content
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

Added some snippets #1297

Merged
merged 6 commits into from
Apr 30, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added Assertt Mock snippet
  • Loading branch information
SQLDBAWithABeard committed Apr 27, 2018
commit 00606c0a9c1c7cf6d08bab434698c20c1f82f06c
46 changes: 44 additions & 2 deletions docs/community_snippets.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,39 @@ _To contribute, check out our [guide here](#contributing)._

| Table of Contents |
|:------------------|
| [AssertMock](#assertmock): _Creates assert mock Pester test_ |
| [CalculatedProperty](#calculatedproperty): _Create a calculated property for use in a select-object call by @corbob_ |
| [DataTable](#datatable): _Creates a DataTable_ |
| [DateTimeWriteVerbose](#datetimewriteverbose): _Write-Verbose with the time and date pre-pended to your message by @ThmsRynr_ |
| [IfShouldProcess](#ifshouldprocess): _Added If Should Process_ |
| [MaxColumnLengthinDataTable](#maxcolumnlengthindatatable): _Gets the max length of string columns in datatables_ |
| [Parameter-Credential](#parameter-credential): _Add a standard credential parameter to your function by @omniomi_ |
| [PSCustomObject](#pscustomobject): _A simple PSCustomObject by @brettmillerb_ |
| [DataTable](#datatable): _Creates a DataTable_ |
| [MaxColumnLengthinDataTable](#maxcolumnlengthindatatable): _Gets the max length of string columns in datatables_ |


## Snippets

### Assert Mock

Creates Assert Mock for Pester Tests y @SQLDBAWithABeard

#### Snippet

```json
"AssertMock": {
"prefix": "AssertMock",
"body": [
"$$assertMockParams = @{",
"'CommandName' = '${1:Command}'",
"'Times' = ${2:1}",
"'Exactly' = $$true",
"}",
"Assert-MockCalled @assertMockParams"
],
"description": "AssertMock snippet for Pestering"
}
```

### CalculatedProperty

Create calculated property for use in Select Statements
Expand Down Expand Up @@ -92,6 +116,24 @@ Quickly add a `Write-Verbose` with the current date and time inserted before the
}
```

### IfShouldProcess

Add If Should Process with easy tab inputs

#### Snippet

```json
"IfShouldProcess": {
"prefix": "IfShouldProcess",
"body": [
"if ($$PSCmdlet.ShouldProcess(\"${1:The Item}\" , \"${2:The Change}\")) {",
" # Place Code here",
"}"
],
"description": "Creates an if should process"
}
```

### MaxColumnLengthinDataTable

Takes a datatable object and iterates through it to get the max length of the string columns - useful for data loads into a SQL Server table with fixed column widths by @SQLDBAWithABeard
Expand Down