add: test function
This commit is contained in:
@@ -1,10 +1,30 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
This function generates a large table with the specified number of lines.
|
||||||
|
.DESCRIPTION
|
||||||
|
This function generates a large table with the specified number of lines. The table has a header and each line has the same format.
|
||||||
|
.EXAMPLE
|
||||||
|
Initialize-LargeTestTable -lineCount 1000
|
||||||
|
.PARAMETER lineCount
|
||||||
|
The number of lines to generate.
|
||||||
|
.INPUTS
|
||||||
|
System.Int32
|
||||||
|
.OUTPUTS
|
||||||
|
System.String
|
||||||
|
.NOTES
|
||||||
|
The function is intended for testing purposes.
|
||||||
|
#>
|
||||||
function Initialize-LargeTestTable {
|
function Initialize-LargeTestTable {
|
||||||
|
[cmdletBinding()]
|
||||||
|
[OutputType([string])]
|
||||||
param(
|
param(
|
||||||
|
[Parameter()]
|
||||||
[int]$lineCount = 1000 # Number of lines to generate
|
[int]$lineCount = 1000 # Number of lines to generate
|
||||||
)
|
)
|
||||||
|
process {
|
||||||
$header = "UserPrincipalName|AuditEnabled|AdminActionsMissing|DelegateActionsMissing|OwnerActionsMissing"
|
$header = "UserPrincipalName|AuditEnabled|AdminActionsMissing|DelegateActionsMissing|OwnerActionsMissing"
|
||||||
$lineTemplate = "user{0}@criticalsolutions.net|True|FB,CP,MV|FB,MV|ML,MV,CR"
|
$lineTemplate = "user{0}@contosonorthwind.net|True|FB,CP,MV|FB,MV|ML,MV,CR"
|
||||||
|
# Generate the header and lines
|
||||||
$lines = @($header)
|
$lines = @($header)
|
||||||
for ($i = 1; $i -le $lineCount; $i++) {
|
for ($i = 1; $i -le $lineCount; $i++) {
|
||||||
$lines += [string]::Format($lineTemplate, $i)
|
$lines += [string]::Format($lineTemplate, $i)
|
||||||
@@ -13,3 +33,4 @@ function Initialize-LargeTestTable {
|
|||||||
Write-Host "Details character count: $($output.Length)"
|
Write-Host "Details character count: $($output.Length)"
|
||||||
return $output
|
return $output
|
||||||
}
|
}
|
||||||
|
}
|
27
tests/Unit/Private/Initialize-LargeTestTable.tests.ps1
Normal file
27
tests/Unit/Private/Initialize-LargeTestTable.tests.ps1
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
$ProjectPath = "$PSScriptRoot\..\..\.." | Convert-Path
|
||||||
|
$ProjectName = ((Get-ChildItem -Path $ProjectPath\*\*.psd1).Where{
|
||||||
|
($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) -and
|
||||||
|
$(try { Test-ModuleManifest $_.FullName -ErrorAction Stop } catch { $false } )
|
||||||
|
}).BaseName
|
||||||
|
|
||||||
|
|
||||||
|
Import-Module $ProjectName
|
||||||
|
|
||||||
|
InModuleScope $ProjectName {
|
||||||
|
Describe Get-PrivateFunction {
|
||||||
|
Context 'Default' {
|
||||||
|
BeforeEach {
|
||||||
|
$return = Get-PrivateFunction -PrivateData 'string'
|
||||||
|
}
|
||||||
|
|
||||||
|
It 'Returns a single object' {
|
||||||
|
($return | Measure-Object).Count | Should -Be 1
|
||||||
|
}
|
||||||
|
|
||||||
|
It 'Returns a string based on the parameter PrivateData' {
|
||||||
|
$return | Should -Be 'string'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user