full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Environment.ps1 | Environment.ps1 | function Get-PowerShellVersion
{
# accessing the value indirectly so it can be mocked
(Get-Variable 'PSVersionTable' -ValueOnly).PsVersion.Major
}
function Get-OperatingSystem
{
# Prior to v6, PowerShell was solely on Windows. In v6, the $IsWindows variable was introduced.
if ((Get-PowerShellV... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/TestsRunningInCleanRunspace.Tests.ps1 | TestsRunningInCleanRunspace.Tests.ps1 | function Invoke-PesterInJob ($ScriptBlock, [switch] $GenerateNUnitReport)
{
$PesterPath = Get-Module Pester | Select-Object -First 1 -ExpandProperty Path
$job = Start-Job {
param ($PesterPath, $TestDrive, $ScriptBlock, $GenerateNUnitReport)
Import-Module $PesterPath -Force | Out-Null
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/TestDrive.ps1 | TestDrive.ps1 | #
function New-TestDrive ([Switch]$PassThru, [string] $Path) {
if ($Path -notmatch '\S')
{
$directory = New-RandomTempDirectory
}
else
{
if (-not (& $SafeCommands['Test-Path'] -Path $Path))
{
& $SafeCommands['New-Item'] -ItemType Container -Path $Path | ... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/BreakAndContinue.Tests.ps1 | BreakAndContinue.Tests.ps1 | Describe 'Clean handling of break and continue' {
# If this test 'fails', it'll just cause most of the rest of the tests to never execute (and we won't see any actual failures.)
# The CI job monitors metrics, though, and will fail the build if the number of tests drops too much.
Context 'Break' {
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/New-Fixture.ps1 | New-Fixture.ps1 | function New-Fixture {
<#
.SYNOPSIS
This function generates two scripts, one that defines a function
and another one that contains its tests.
.DESCRIPTION
This function generates two scripts, one that defines a function
and another one that contains its tests. The files are by defau... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/GherkinHook.ps1 | GherkinHook.ps1 | function BeforeEachFeature {
<#
.Synopsis
Defines a ScriptBlock hook to run before each feature to set up the test environment
.Description
BeforeEachFeature hooks are run before each feature that is in (or above) the folder where the hook is defined.
This... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/TestResults.ps1 | TestResults.ps1 | function Get-HumanTime($Seconds) {
if($Seconds -gt 0.99) {
$time = [math]::Round($Seconds, 2)
$unit = 's'
}
else {
$time = [math]::Floor($Seconds * 1000)
$unit = 'ms'
}
return "$time$unit"
}
function GetFullPath ([string]$Path) {
if (-not [System.IO.... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/TestDrive.Tests.ps1 | TestDrive.Tests.ps1 | Set-StrictMode -Version Latest
if ($PSVersionTable.PSVersion.Major -lt 6 -or $IsWindows)
{
$tempPath = $env:TEMP
}
else
{
$tempPath = '/tmp'
}
Describe "Setup" {
It "returns a location that is in a temp area" {
$testDrivePath = (Get-Item $TestDrive).FullName
$testDrivePath -l... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/GherkinStep.Tests.ps1 | GherkinStep.Tests.ps1 | if ($PSVersionTable.PSVersion.Major -le 2) { return }
Set-StrictMode -Version Latest
Describe 'Testing Gerkin Step' {
It 'Generates a function named "GherkinStep" with mandatory name and test parameters' {
$command = &(Get-Module Pester) { Get-Command GherkinStep -Module Pester }
$command |... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Output.Tests.ps1 | Output.Tests.ps1 | InModuleScope -ModuleName Pester -ScriptBlock {
Describe 'Has-Flag' -Fixture {
It 'Returns true when setting and value are the same' {
$setting = [Pester.OutputTypes]::Passed
$value = [Pester.OutputTypes]::Passed
$value | Has-Flag $setting | Should Be $true
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/InModuleScope.Tests.ps1 | InModuleScope.Tests.ps1 | Set-StrictMode -Version Latest
Describe "Module scope separation" {
Context "When users define variables with the same name as Pester parameters" {
$test = "This is a test."
It "does not hide user variables" {
$test | Should Be 'This is a test.'
}
}
It "Does... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/In.Tests.ps1 | In.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "the In statement" {
Setup -Dir "test_path"
It "executes a command in that directory" {
In "$TestDrive" -Execute { "" | Out-File "test_file" }
"$TestDrive\test_file" | Should Exist
}
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/SetupTeardown.ps1 | SetupTeardown.ps1 | function BeforeEach
{
<#
.SYNOPSIS
Defines a series of steps to perform at the beginning of every It block within
the current Context or Describe block.
.DESCRIPTION
BeforeEach, AfterEach, BeforeAll, and AfterAll are unique in that they apply
to the entire Context or Describe block, regardless... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/GherkinHook.Tests.ps1 | GherkinHook.Tests.ps1 | if ($PSVersionTable.PSVersion.Major -le 2) { return }
Set-StrictMode -Version Latest
Describe 'Testing Gerkin Hook' {
It 'Generates a function named "BeforeEachFeature" with mandatory Tags and Script parameters' {
$command = &(Get-Module Pester) { Get-Command BeforeEachFeature -Module Pester }
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/GlobalMock-B.Tests.ps1 | GlobalMock-B.Tests.ps1 | # This test depends on some state set up in GlobalMock-A.Tests.ps1. The behavior we're verifying
# is that global functions that have been mocked are still properly set up even after the test
# script exits its scope.
$functionName = '01c1a57716fe4005ac1a7bf216f38ad0'
try
{
Describe 'Mocking Global Funct... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Coverage.ps1 | Coverage.ps1 | if ($PSVersionTable.PSVersion.Major -le 2)
{
function Exit-CoverageAnalysis { }
function Get-CoverageReport { }
function Write-CoverageReport { }
function Enter-CoverageAnalysis {
param ( $CodeCoverage )
if ($CodeCoverage) { & $SafeCommands['Write-Error'] 'Code coverage analysis... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/New-Fixture.Tests.ps1 | New-Fixture.Tests.ps1 | Set-StrictMode -Version Latest
Describe "New-Fixture" {
It "Name parameter is mandatory:" {
(get-command New-Fixture ).Parameters.Name.ParameterSets.__AllParameterSets.IsMandatory | Should Be $true
}
Context "Only Name parameter is specified:" {
It "Creates fixture in current direc... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Describe.Tests.ps1 | Describe.Tests.ps1 | Set-StrictMode -Version Latest
Describe 'Testing Describe' {
It 'Has a non-mandatory fixture parameter which throws the proper error message if missing' {
$command = Get-Command Describe -Module Pester
$command | Should Not Be $null
$parameter = $command.Parameters['Fixture']
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/New-MockObject.Tests.ps1 | New-MockObject.Tests.ps1 | describe 'New-MockObject' {
it 'instantiates an object from a class with no public constructors' {
$type = 'Microsoft.PowerShell.Commands.Language'
New-MockObject -Type $type | should beoftype $type
}
}
|
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/TestResults.Tests.ps1 | TestResults.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
if ((Get-OperatingSystem) -eq 'Windows') {
Describe "Write nunit test results" {
Setup -Dir "Results"
It "should write a successful test result" {
#create state
$TestResults = New-PesterS... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/PesterState.ps1 | PesterState.ps1 | function New-PesterState
{
param (
[String[]]$TagFilter,
[String[]]$ExcludeTagFilter,
[String[]]$TestNameFilter,
[System.Management.Automation.SessionState]$SessionState,
[Switch]$Strict,
[Pester.OutputTypes]$Show = 'All',
[object]$PesterOption
)... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/PesterState.Tests.ps1 | PesterState.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "New-PesterState" {
Context "TestNameFilter parameter is set" {
$p = new-pesterstate -TestNameFilter "filter"
it "sets the TestNameFilter property" {
$p.TestNameFilter | should be "filter"
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/New-MockObject.ps1 | New-MockObject.ps1 | function New-MockObject {
<#
.SYNOPSIS
This function instantiates a .NET object from a type. The assembly for the particular type must be
loaded.
.PARAMETER Type
The .NET type to create an object from.
.EXAMPLE
PS> $obj = New-MockObject -Type 'System.Diagnosti... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Gherkin.Tests.ps1 | Gherkin.Tests.ps1 | if ($PSVersionTable.PSVersion.Major -le 2) { return }
Set-StrictMode -Version Latest
$scriptRoot = Split-Path (Split-Path $MyInvocation.MyCommand.Path)
# Calling this in a job so we don't monkey with the active pester state that's already running
$job = Start-Job -ArgumentList $scriptRoot -ScriptBlock {
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Context.ps1 | Context.ps1 | function Context {
<#
.SYNOPSIS
Provides logical grouping of It blocks within a single Describe block.
.DESCRIPTION
Provides logical grouping of It blocks within a single Describe block.
Any Mocks defined inside a Context are removed at the end of the Context scope,
as are any files or folders added to the Tes... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Mock.Tests.ps1 | Mock.Tests.ps1 | Set-StrictMode -Version Latest
function FunctionUnderTest
{
[CmdletBinding()]
param (
[Parameter(Mandatory=$false)]
[string]
$param1
)
return "I am a real world test"
}
function FunctionUnderTestWithoutParams([string]$param1) {
return "I am a real world test... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Coverage.Tests.ps1 | Coverage.Tests.ps1 | if ($PSVersionTable.PSVersion.Major -le 2) { return }
InModuleScope Pester {
Describe 'Code Coverage Analysis' {
$root = (Get-PSDrive TestDrive).Root
$null = New-Item -Path $root\TestScript.ps1 -ItemType File -ErrorAction SilentlyContinue
Set-Content -Path $root\TestScript.ps1 -Va... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/It.ps1 | It.ps1 | function It {
<#
.SYNOPSIS
Validates the results of a test inside of a Describe block.
.DESCRIPTION
The It command is intended to be used inside of a Describe or Context Block.
If you are familiar with the AAA pattern (Arrange-Act-Assert), the body of
the It block is the appropriate location for an assert. The... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/In.ps1 | In.ps1 | function In {
<#
.SYNOPSIS
A convenience function that executes a script from a specified path.
.DESCRIPTION
Before the script block passed to the execute parameter is invoked,
the current location is set to the path specified. Once the script
block has been executed, the location will be reset to the location... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Environment.Tests.ps1 | Environment.Tests.ps1 | InModuleScope -ModuleName Pester {
Describe 'Get-PowerShellVersion' {
Mock Get-Variable
It 'Returns value of $PSVersionTable.PsVersion.Major' {
Mock Get-Variable -ParameterFilter { $Name -eq 'PSVersionTable' -and $ValueOnly } -MockWIth {
@{ PSVersion = [Version]'1.0.... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/SetupTeardown.Tests.ps1 | SetupTeardown.Tests.ps1 | Describe 'Describe-Scoped Test Case setup' {
BeforeEach {
$testVariable = 'From BeforeEach'
}
$testVariable = 'Set in Describe'
It 'Assigns the correct value in first test' {
$testVariable | Should Be 'From BeforeEach'
$testVariable = 'Set in It'
}
It 'Assi... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/GlobalMock-A.Tests.ps1 | GlobalMock-A.Tests.ps1 | # This script exists to create and mock a global function, then exit. The actual behavior
# that we need to test is covered in GlobalMock-B.Tests.ps1, where we make sure that the
# global function was properly restored in its scope.
$functionName = '01c1a57716fe4005ac1a7bf216f38ad0'
if (Test-Path Function:\$fu... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/InModuleScope.ps1 | InModuleScope.ps1 | function InModuleScope
{
<#
.SYNOPSIS
Allows you to execute parts of a test script within the
scope of a PowerShell script module.
.DESCRIPTION
By injecting some test code into the scope of a PowerShell
script module, you can use non-exported functions, aliases
and variables inside that module, ... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/GherkinStep.ps1 | GherkinStep.ps1 | function GherkinStep {
<#
.Synopsis
A step in a test, also known as a Given, When, or Then
.Description
Pester doesn't technically distinguish between the three kinds of steps.
However, we strongly recommend that you do!
These words were careful... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Output.ps1 | Output.ps1 | $Script:ReportStrings = DATA {
@{
StartMessage = 'Executing all tests in {0}'
FilterMessage = ' matching test name {0}'
TagMessage = ' with Tags {0}'
MessageOfs = "', '"
CoverageTitle = 'Code coverage report:'
CoverageMessage = 'Covered {2:P2} of... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Mock.ps1 | Mock.ps1 | function Mock {
<#
.SYNOPSIS
Mocks the behavior of an existing command with an alternate
implementation.
.DESCRIPTION
This creates new behavior for any existing command within the scope of a
Describe or Context block. The function allows you to specify a script block
that will become the command's new behav... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Describe.ps1 | Describe.ps1 | function Describe {
<#
.SYNOPSIS
Creates a logical group of tests.
.DESCRIPTION
Creates a logical group of tests. All Mocks and TestDrive contents
defined within a Describe block are scoped to that Describe; they
will no longer be present when the Describe block exits. A Describe
block may contain any numb... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/Match.ps1 | Match.ps1 | function PesterMatch($ActualValue, $RegularExpression, [switch] $Negate) {
[bool] $succeeded = $ActualValue -match $RegularExpression
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
{
if ($Negate)
{
$failureMessage = N... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/MatchExactly.Tests.ps1 | MatchExactly.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "MatchExactly" {
It "returns true for things that match exactly" {
'foobar' | Should MatchExactly 'ob'
'foobar' | Should -MatchExactly 'ob'
'foobar' | Should -CMATCH 'ob'
}
It "retu... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeIn.ps1 | BeIn.ps1 | function PesterBeIn($ActualValue, $ExpectedValue, [switch] $Negate)
{
[bool] $succeeded = $ExpectedValue -contains $ActualValue
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
{
if ($Negate)
{
$failureMessage = NotPeste... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/Set-TestInconclusive.ps1 | Set-TestInconclusive.ps1 | function New-InconclusiveErrorRecord ([string] $Message, [string] $File, [string] $Line, [string] $LineText) {
$exception = New-Object Exception $Message
$errorID = 'PesterTestInconclusive'
$errorCategory = [Management.Automation.ErrorCategory]::InvalidResult
# we use ErrorRecord.TargetObject to pas... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/PesterThrow.Tests.ps1 | PesterThrow.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterThrow" {
It "returns true if the statement throws an exception" {
{ throw } | Should Throw
{ throw } | Should -Throw
}
It "returns false if the statement does not throw an exception" {
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeNullOrEmpty.ps1 | BeNullOrEmpty.ps1 |
function PesterBeNullOrEmpty([object[]] $ActualValue, [switch] $Negate) {
if ($null -eq $ActualValue -or $ActualValue.Count -eq 0)
{
$succeeded = $true
}
elseif ($ActualValue.Count -eq 1)
{
$succeeded = [String]::IsNullOrEmpty($ActualValue[0])
}
else
{
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeLikeExactly.ps1 | BeLikeExactly.ps1 |
function PesterBeLikeExactly($value, $expectedMatch) {
return ($value -clike $expectedMatch)
}
function PesterBeLikeExactlyFailureMessage($value, $expectedMatch) {
return "Expected: {$value} to be exactly like the wildcard {$expectedMatch}"
}
function NotPesterBeLikeExactlyFailureMessage($value, $ex... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/ContainMultiline.Tests.ps1 | ContainMultiline.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterContainMultiline" {
Context "when testing file contents" {
Setup -File "test.txt" "this is line 1`nthis is line 2`nPester is awesome"
It "returns true if the file matches the specified content on one line" {... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/Should.Tests.ps1 | Should.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "Parse-ShouldArgs" {
It "identifies assertion functions" {
$parsedArgs = Parse-ShouldArgs TestFunction
$parsedArgs.AssertionMethod | Should Be TestFunction
$parsedArgs = Parse-ShouldArgs Not, TestFun... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeIn.Tests.ps1 | BeIn.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterBeIn" {
It "passes if value is in the collection" {
PesterBeIn 1 (@(1,2,3))
PesterBeIn 'a' (@(1,'a',3))
1 | Should BeIn @(1,2,3)
'a' | Should -BeIn @(1,'a',3)
}
It... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeLike.ps1 | BeLike.ps1 | function PesterBeLike($ActualValue, $ExpectedValue, [switch] $Negate)
{
[bool] $succeeded = $ActualValue -like $ExpectedValue
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
{
if ($Negate)
{
$failureMessage = NotPesterB... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/Exist.ps1 | Exist.ps1 | function PesterExist($ActualValue, [switch] $Negate) {
[bool] $succeeded = & $SafeCommands['Test-Path'] $ActualValue
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
{
if ($Negate)
{
$failureMessage = NotPesterExistFail... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeLikeExactly.Tests.ps1 | BeLikeExactly.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "BeLike" {
It "returns true for things that are like wildcard" {
PesterBeLikeExactly "FOOBAR" "*OB*" | Should Be $true
}
It "returns false for things that do not match" {
PesterBeLikeExactly "fo... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/PesterThrow.ps1 | PesterThrow.ps1 | function PesterThrow([scriptblock] $ActualValue, $ExpectedMessage, $ErrorId, [switch] $Negate) {
$script:ActualExceptionMessage = ""
$script:ActualExceptionWasThrown = $false
if ($null -eq $ActualValue) {
throw (New-Object -TypeName ArgumentNullException -ArgumentList "ActualValue","Scriptbloc... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeLessThan.Tests.ps1 | BeLessThan.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterBeLessThan" {
It "passes if value Less than expected" {
1 | Should BeLessThan 2
1 | Should -BeLessThan 2
1 | Should -LT 2
}
It "fails if values equal" {
3 | Shou... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeGreaterThan.ps1 | BeGreaterThan.ps1 | function PesterBeGreaterThan($ActualValue, $ExpectedValue, [switch] $Negate)
{
[bool] $succeeded = $ActualValue -gt $ExpectedValue
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
{
if ($Negate)
{
$failureMessage = NotPe... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeNullOrEmpty.Tests.ps1 | BeNullOrEmpty.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterBeNullOrEmpty" {
It "should return true if null" {
$null | Should BeNullOrEmpty
$null | Should -BeNullOrEmpty
}
It "should return true if empty string" {
'' | Should BeNullOr... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/MatchExactly.ps1 | MatchExactly.ps1 | function PesterMatchExactly($ActualValue, $RegularExpression, [switch] $Negate) {
[bool] $succeeded = $ActualValue -cmatch $RegularExpression
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
{
if ($Negate)
{
$failureMes... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/Match.Tests.ps1 | Match.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "Match" {
It "returns true for things that match" {
'foobar' | Should Match 'ob'
'foobar' | Should -Match 'ob'
}
It "returns false for things that do not match" {
'foobar' | Should ... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeGreaterThan.Tests.ps1 | BeGreaterThan.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterBeGreaterThan" {
It "passes if value greater than expected" {
2 | Should BeGreaterThan 1
2 | Should -BeGreaterThan 1
2 | Should -GT 1
}
It "fails if values equal" {
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/ContainMultiline.ps1 | ContainMultiline.ps1 | function PesterContainMultiline($ActualValue, $ExpectedContent, [switch] $Negate) {
$succeeded = [bool] ((Get-Content $ActualValue -delim ([char]0)) -match $ExpectedContent)
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
{
if ($Negate)
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeLike.Tests.ps1 | BeLike.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "BeLike" {
It "returns true for things that are like wildcard" {
"foobar" | Should BeLike "*ob*"
"foobar" | Should -BeLike "*ob*"
}
It "returns false for things that do not match" {
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/Be.ps1 | Be.ps1 | #Be
function PesterBe($ActualValue, $ExpectedValue, [switch] $Negate) {
[bool] $succeeded = ArraysAreEqual $ActualValue $ExpectedValue
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
{
if ($Negate)
{
$failureMessage =... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/Contain.Tests.ps1 | Contain.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterContain" {
Context "when testing file contents" {
Setup -File "test.txt" "this is line 1`nrush is awesome`nAnd this is Unicode: ☺"
It "returns true if the file contains the specified content" {
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeOfType.Tests.ps1 | BeOfType.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterBeOfType" {
It "passes if value is of the expected type" {
1 | Should BeOfType Int
2.0 | Should BeOfType ([double])
1 | Should -BeOfType Int
2.0 | Should -BeOfType ([double])
... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/Contain.ps1 | Contain.ps1 | function PesterContain($ActualValue, $ExpectedContent, [switch] $Negate) {
$succeeded = (@(& $SafeCommands['Get-Content'] -Encoding UTF8 $ActualValue) -match $ExpectedContent).Count -gt 0
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
{
if... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/Should.ps1 | Should.ps1 | function Parse-ShouldArgs([object[]] $shouldArgs) {
if ($null -eq $shouldArgs) { $shouldArgs = @() }
$parsedArgs = @{
PositiveAssertion = $true
ExpectedValue = $null
}
$assertionMethodIndex = 0
$expectedValueIndex = 1
if ($shouldArgs.Count -gt 0 -and $shouldArgs[0... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeOfType.ps1 | BeOfType.ps1 |
function PesterBeOfType($ActualValue, $ExpectedType, [switch] $Negate) {
$hash = @{ Succeeded = $true }
trap [System.Management.Automation.PSInvalidCastException] { $hash['Succeeded'] = $false; continue }
if($ExpectedType -is [string] -and !($ExpectedType -as [Type])) {
$ExpectedType = $Ex... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/Exist.Tests.ps1 | Exist.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterExist" {
It "returns true for paths that exist" {
$TestDrive | Should Exist
$TestDrive | Should -Exist
}
It "returns false for paths do not exist" {
"$TestDrive\nonexistant" ... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/BeLessThan.ps1 | BeLessThan.ps1 | function PesterBeLessThan($ActualValue, $ExpectedValue)
{
[bool] $succeeded = $ActualValue -lt $ExpectedValue
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
{
if ($Negate)
{
$failureMessage = NotPesterBeLessThanFailure... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/Be.Tests.ps1 | Be.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterBe" {
It "returns true if the 2 arguments are equal" {
1 | Should Be 1
1 | Should -Be 1
1 | Should -EQ 1
}
It "returns true if the 2 arguments are equal and have different case... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/ContainExactly.Tests.ps1 | ContainExactly.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterContainExactly" {
Context "when testing file contents" {
Setup -File "test.txt" "this is line 1`nPester is awesome`nAnd this is Unicode: ☺"
It "returns true if the file contains the specified content exactly... |
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Assertions/ContainExactly.ps1 | ContainExactly.ps1 | function PesterContainExactly($ActualValue, $ExpectedContent, [switch] $Negate) {
$succeeded = (@(& $SafeCommands['Get-Content'] -Encoding UTF8 $ActualValue) -cmatch $ExpectedContent).Count -gt 0
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
{
... |
PowerShellCorpus/PowerShellGallery/Posh-IBCLI/1.2/Private/Disable-SSLCertChecking.ps1 | Disable-SSLCertChecking.ps1 | function Disable-SSLCertChecking
{
[CmdletBinding()]
param()
# http://stackoverflow.com/a/38729034/75772
# https://d-fens.ch/2013/12/20/nobrainer-ssl-connection-error-when-using-powershell/
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{... |
PowerShellCorpus/PowerShellGallery/Posh-IBCLI/1.2/Public/Invoke-IBCLISetPromoteMaster.ps1 | Invoke-IBCLISetPromoteMaster.ps1 | function Invoke-IBCLISetPromoteMaster
{
[CmdletBinding()]
param(
[Parameter(
ParameterSetName='NewStream',
Mandatory=$true,
Position=0,
HelpMessage='Enter the Hostname or IP Address of an Infoblox appliance.'
)]
[ValidateNotNullOr... |
PowerShellCorpus/PowerShellGallery/Posh-IBCLI/1.2/Public/Invoke-IBCLISetMembership.ps1 | Invoke-IBCLISetMembership.ps1 | function Invoke-IBCLISetMembership
{
[CmdletBinding()]
param(
[Parameter(
ParameterSetName='NewStream',
Mandatory=$true,
Position=0,
HelpMessage='Enter the Hostname or IP Address of an Infoblox appliance.'
)]
[ValidateNotNullOrEmp... |
PowerShellCorpus/PowerShellGallery/Posh-IBCLI/1.2/Public/Get-IBCLILicenses.ps1 | Get-IBCLILicenses.ps1 | function Get-IBCLILicenses
{
[CmdletBinding()]
param(
[Parameter(
ParameterSetName='NewStream',
Mandatory=$true,
Position=0,
HelpMessage='Enter the Hostname or IP Address of an Infoblox appliance.'
)]
[ValidateNotNullOrEmpty()]
... |
PowerShellCorpus/PowerShellGallery/Posh-IBCLI/1.2/Public/Get-IBCLIStatus.ps1 | Get-IBCLIStatus.ps1 | function Get-IBCLIStatus
{
[CmdletBinding()]
param(
[Parameter(
ParameterSetName='NewStream',
Mandatory=$true,
Position=0,
HelpMessage='Enter the Hostname or IP Address of an Infoblox appliance.'
)]
[ValidateNotNullOrEmpty()]
... |
PowerShellCorpus/PowerShellGallery/Posh-IBCLI/1.2/Public/Connect-IBCLI.ps1 | Connect-IBCLI.ps1 | function Connect-IBCLI
{
[CmdletBinding()]
param(
[Parameter(
Mandatory=$true,
Position=0,
HelpMessage='Enter the Hostname or IP Address of an Infoblox appliance.'
)]
[ValidateNotNullOrEmpty()]
[string]
$ComputerName,
... |
PowerShellCorpus/PowerShellGallery/Posh-IBCLI/1.2/Public/Invoke-IBCLICommand.ps1 | Invoke-IBCLICommand.ps1 | function Invoke-IBCLICommand
{
[CmdletBinding()]
param(
[Parameter(
Mandatory=$true,
Position=0,
HelpMessage='Enter the Infoblox CLI command to run'
)]
[AllowEmptyString()]
[string]
$Command,
[Parameter(
... |
PowerShellCorpus/PowerShellGallery/Posh-IBCLI/1.2/Public/Get-IBCLIHardwareID.ps1 | Get-IBCLIHardwareID.ps1 | function Get-IBCLIHardwareID
{
[CmdletBinding()]
param(
[Parameter(
ParameterSetName='NewStream',
Mandatory=$true,
Position=0,
HelpMessage='Enter the Hostname or IP Address of an Infoblox appliance.'
)]
[ValidateNotNullOrEmpty()]
... |
PowerShellCorpus/PowerShellGallery/Posh-IBCLI/1.2/Public/Get-IBCLINetwork.ps1 | Get-IBCLINetwork.ps1 | function Get-IBCLINetwork
{
[CmdletBinding()]
param(
[Parameter(
ParameterSetName='NewStream',
Mandatory=$true,
Position=0,
HelpMessage='Enter the Hostname or IP Address of an Infoblox appliance.'
)]
[ValidateNotNullOrEmpty()]
... |
PowerShellCorpus/PowerShellGallery/Posh-IBCLI/1.2/Public/Disconnect-IBCLI.ps1 | Disconnect-IBCLI.ps1 | function Disconnect-IBCLI
{
[CmdletBinding()]
param(
[Parameter(
Mandatory=$true,
Position=1,
HelpMessage='Enter the ShellStream object returned by Connect-IBCLI.'
)]
[ValidateNotNull()]
[Renci.SshNet.ShellStream]
$ShellStrea... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Set-RegMultiString.ps1 | Set-RegMultiString.ps1 | function Set-RegMultiString
{
<#
.SYNOPSIS
Sets or creates an array of null-terminated strings (REG_MULTI_SZ) on local or remote computers.
.DESCRIPTION
Use Set-RegMultiString to set or create an array of null-terminated strings (REG_MULTI_SZ) on local or remote computers.
.PARA... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Set-RegString.ps1 | Set-RegString.ps1 | function Set-RegString
{
<#
.SYNOPSIS
Sets or creates a string (REG_SZ) registry value on local or remote computers.
.DESCRIPTION
Use Set-RegString to set or create registry string (REG_SZ) value on local or remote computers.
.PARAMETER ComputerName
An array of computer n... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Get-RegKey.ps1 | Get-RegKey.ps1 | function Get-RegKey
{
<#
.SYNOPSIS
Gets the registry keys on local or remote computers.
.DESCRIPTION
Use Get-RegKey to get registry keys on local or remote computers
.PARAMETER ComputerName
An array of computer names. The default is the local computer.
.PARAMETER Hive... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Set-RegBinary.ps1 | Set-RegBinary.ps1 | function Set-RegBinary
{
<#
.SYNOPSIS
Sets or creates a binary data registry value (REG_BINARY) from local or remote computers.
.DESCRIPTION
Use Set-RegBinary to set or create a binary data registry value (REG_BINARY) from local or remote computers.
.PARAMETER ComputerName
... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Get-RegExpandString.ps1 | Get-RegExpandString.ps1 | function Get-RegExpandString
{
<#
.SYNOPSIS
Retrieves a null-terminated string that contains unexpanded references to environment variables (REG_EXPAND_SZ) from local or remote computers.
.DESCRIPTION
Use Get-RegExpandString to retrieve a null-terminated string that contains unexpanded refe... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Test-RegKey.ps1 | Test-RegKey.ps1 | function Test-RegKey
{
<#
.SYNOPSIS
Determines if a registry key exists.
.DESCRIPTION
Use Test-RegKey to determine if a registry key exists.
.PARAMETER ComputerName
An array of computer names. The default is the local computer.
.PARAMETER Hive
The HKEY to open, ... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Get-RegString.ps1 | Get-RegString.ps1 | function Get-RegString
{
<#
.SYNOPSIS
Retrieves a registry string (REG_SZ) value from local or remote computers.
.DESCRIPTION
Use Get-RegString to retrieve a registry string (REG_SZ) value from local or remote computers.
.PARAMETER ComputerName
An array of computer names. The default... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Get-RegBinary.ps1 | Get-RegBinary.ps1 | function Get-RegBinary
{
<#
.SYNOPSIS
Retrieves a binary data registry value (REG_BINARY) from local or remote computers.
.DESCRIPTION
Use Get-RegBinary to retrieve a binary data registry value (REG_BINARY) from local or remote computers.
.PARAMETER ComputerName
An array of... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Set-RegExpandString.ps1 | Set-RegExpandString.ps1 | function Set-RegExpandString
{
<#
.SYNOPSIS
Sets or creates a string (REG_EXPAND_SZ) registry value on local or remote computers.
.DESCRIPTION
Use Set-RegExpandString to set or create registry string (REG_EXPAND_SZ) value on local or remote computers.
.PARAMETER ComputerName
An array of ... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Get-RegDefault.ps1 | Get-RegDefault.ps1 | function Get-RegDefault
{
<#
.SYNOPSIS
Retrieves registry default string (REG_SZ) value from local or remote computers.
.DESCRIPTION
Use Get-RegDefault to retrieve registry default string (REG_SZ) value from local or remote computers.
.PARAMETER ComputerName
An array of c... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Get-RegQWord.ps1 | Get-RegQWord.ps1 | function Get-RegQWord
{
<#
.SYNOPSIS
Retrieves a 64-bit binary number registry value (REG_QWORD) from local or remote computers.
.DESCRIPTION
Use Get-RegQWord to retrieve a 64-bit binary number registry value (REG_QWORD) from local or remote computers.
.PARAMETER ComputerName
... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Get-RegValue.ps1 | Get-RegValue.ps1 | function Get-RegValue
{
<#
.SYNOPSIS
Sets the default value (REG_SZ) of the registry key on local or remote computers.
.DESCRIPTION
Use Get-RegValue to set the default value (REG_SZ) of the registry key on local or remote computers.
.PARAMETER ComputerName
An array of com... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Test-RegValue.ps1 | Test-RegValue.ps1 | function Test-RegValue
{
<#
.SYNOPSIS
Determines if a registry value exists.
.DESCRIPTION
Use Test-RegValue to determine if the registry value exists.
.PARAMETER ComputerName
An array of computer names. The default is the local computer.
.PARAMETER Hive
The HKEY... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Get-RegDWord.ps1 | Get-RegDWord.ps1 | function Get-RegDWord
{
<#
.SYNOPSIS
Retrieves a 32-bit binary number (REG_DWORD) registry value from local or remote computers.
.DESCRIPTION
Use Get-RegDWord to retrieve a 32-bit binary number (REG_DWORD) registry value from local or remote computers.
.PARAMETER ComputerName
... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Set-RegDefault.ps1 | Set-RegDefault.ps1 | function Set-RegDefault
{
<#
.SYNOPSIS
Sets the default value (REG_SZ) of the registry key on local or remote computers.
.DESCRIPTION
Use Set-RegDefault to set the default value (REG_SZ) of the registry key on local or remote computers.
.PARAMETER ComputerName
An array of... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Remove-RegKey.ps1 | Remove-RegKey.ps1 | function Remove-RegKey
{
<#
.SYNOPSIS
Deletes the specified registry key from local or remote computers.
.DESCRIPTION
Use Remove-RegKey to delete the specified registry key from local or remote computers.
.PARAMETER ComputerName
An array of computer names. The default is ... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Set-RegQWord.ps1 | Set-RegQWord.ps1 | function Set-RegQWord
{
<#
.SYNOPSIS
Sets or creates a 64-bit binary number (REG_QWORD) on local or remote computers.
.DESCRIPTION
Use Set-RegQWord to set or create a 64-bit binary number (REG_QWORD) on local or remote computers.
.PARAMETER ComputerName
An array of computer ... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Set-RegDWord.ps1 | Set-RegDWord.ps1 | function Set-RegDWord
{
<#
.SYNOPSIS
Sets or creates a 32-bit binary number (REG_DWORD) on local or remote computers.
.DESCRIPTION
Use Set-RegDWord to set or create a 32-bit binary number (REG_DWORD) on local or remote computers.
.PARAMETER ComputerName
An array of comput... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/New-RegKey.ps1 | New-RegKey.ps1 | function New-RegKey
{
<#
.SYNOPSIS
Creates a new registry key on local or remote machines.
.DESCRIPTION
Use New-RegKey to create a new registry key on local or remote machines.
.PARAMETER ComputerName
An array of computer names. The default is the local computer.
.PAR... |
PowerShellCorpus/PowerShellGallery/PoshRegistry/0.0.2/Public/Get-RegMultiString.ps1 | Get-RegMultiString.ps1 | function Get-RegMultiString
{
<#
.SYNOPSIS
Retrieves an array of null-terminated strings (REG_MULTI_SZ) from local or remote computers.
.DESCRIPTION
Use Get-RegMultiString to retrieve an array of null-terminated strings (REG_MULTI_SZ) from local or remote computers.
.PARAMETER C... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.