diff --git a/Lability.psd1 b/Lability.psd1 index fd6037f2..5715d9c1 100644 --- a/Lability.psd1 +++ b/Lability.psd1 @@ -1,6 +1,6 @@ @{ RootModule = 'Lability.psm1'; - ModuleVersion = '0.10.1'; + ModuleVersion = '0.10.2'; GUID = '374126b4-f3d4-471d-b25e-767f69ee03d0'; Author = 'Iain Brighton'; CompanyName = 'Virtual Engine'; diff --git a/Min.Tests.ps1 b/Min.Tests.ps1 new file mode 100644 index 00000000..1554b35f --- /dev/null +++ b/Min.Tests.ps1 @@ -0,0 +1,98 @@ +$Here = Split-Path -Parent $MyInvocation.MyCommand.Path + +$PrivateFunctions = Get-ChildItem "$here\Private\" -Filter '*.ps1' -Recurse | Where-Object {$_.name -NotMatch "Tests.ps1"} +$PublicFunctions = Get-ChildItem "$here\Public\" -Filter '*.ps1' -Recurse | Where-Object {$_.name -NotMatch "Tests.ps1"} + +$PrivateFunctionsTests = Get-ChildItem "$here\Private\" -Filter '*Tests.ps1' -Recurse +$PublicFunctionsTests = Get-ChildItem "$here\Public\" -Filter '*Tests.ps1' -Recurse + +$Rules = Get-ScriptAnalyzerRule + +$manifest = Get-Item "$Here\Lability.psd1" + +$module = $manifest.BaseName + +Import-Module "$Here\Lability.psd1" + +$ModuleData = Get-Module $Module +$AllFunctions = & $moduleData {Param($modulename) Get-command -CommandType Function -Module $modulename} $module + +$PublicFunctionPath = "$here\Public\" +$PrivateFunctionPath = "$here\Private\" + +$TestsPath = "$here\Tests\" + +$CurrentTests = Get-ChildItem $TestsPath -Recurse -File + +if ($PrivateFunctions.count -gt 0) { + foreach($PrivateFunction in $PrivateFunctions) + { + + Describe "Testing Private Function - $($PrivateFunction.BaseName) for Standard Processing" { + + It "Is valid Powershell (Has no script errors)" { + + $contents = Get-Content -Path $PrivateFunction.FullName -ErrorAction Stop + $errors = $null + $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) + $errors.Count | Should Be 0 + } + + + } + + } + } + + +if ($PublicFunctions.count -gt 0) { + + foreach($PublicFunction in $PublicFunctions) + { + + Describe "Testing Public Function - $($PublicFunction.BaseName) for Standard Processing" { + + It "Is valid Powershell (Has no script errors)" { + + $contents = Get-Content -Path $PublicFunction.FullName -ErrorAction Stop + $errors = $null + $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) + $errors.Count | Should Be 0 + } + + } + <# + $function = $AllFunctions.Where{ $_.Name -eq $PublicFunction.BaseName} + $publicfunctionTests = $Publicfunctionstests.Where{$_.Name -match $PublicFunction.BaseName } + + foreach ($publicfunctionTest in $publicfunctionTests) { + . $($PublicFunctionTest.FullName) $function + } #> + } + } + + + +Describe 'ScriptAnalyzer Rule Testing' { + + Context 'Public Functions' { + + It 'Passes the Script Analyzer ' { + (Invoke-ScriptAnalyzer -Path $PublicFunctionPath -Recurse ).Count | Should Be 0 + + } + } + + Context 'Private Functions' { + + It 'Passes the Script Analyzer ' { + (Invoke-ScriptAnalyzer -Path $PrivateFunctionPath ).Count | Should Be 0 + + } + } +} + + +Foreach ($currentTest in $CurrentTests) { + . $currentTest.FullName + } \ No newline at end of file diff --git a/PesterTest.ps1 b/PesterTest.ps1 new file mode 100644 index 00000000..d3e9cdb2 --- /dev/null +++ b/PesterTest.ps1 @@ -0,0 +1,16 @@ + $Here = Split-Path -Parent $MyInvocation.MyCommand.Path + + + $invokePesterParams = @{ + Path = "$here\Min.Tests.ps1"; + OutputFile = "$here\TestResult.xml"; + OutputFormat = 'NUnitXml'; + Strict = $true; + PassThru = $true; + Verbose = $false; + } + + $testResult = Invoke-Pester @invokePesterParams; + if ($testResult.FailedCount -gt 0) { + Write-Error ('Failed "{0}" unit tests.' -f $testResult.FailedCount); + } diff --git a/Private/AddDiskImageHotfix.ps1 b/Private/AddDiskImageHotfix.ps1 new file mode 100644 index 00000000..f30e1239 --- /dev/null +++ b/Private/AddDiskImageHotfix.ps1 @@ -0,0 +1,60 @@ +function AddDiskImageHotfix { + +<# + .SYMOPSIS + Adds a Windows update/hotfix package to an image. +#> + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $Id, + + ## Mounted VHD(X) Operating System disk image + [Parameter(Mandatory)] + [ValidateNotNull()] + [System.Object] $Vhd, # Microsoft.Vhd.PowerShell.VirtualHardDisk + + ## Disk image partition scheme + [Parameter(Mandatory)] + [ValidateSet('MBR','GPT')] + [System.String] $PartitionStyle, + + ## Lab DSC configuration data + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + + if ($PartitionStyle -eq 'MBR') { + + $partitionType = 'IFS'; + } + elseif ($PartitionStyle -eq 'GPT') { + + $partitionType = 'Basic'; + } + $vhdDriveLetter = GetDiskImageDriveLetter -DiskImage $Vhd -PartitionType $partitionType; + + $resolveLabMediaParams = @{ + Id = $Id; + } + if ($PSBoundParameters.ContainsKey('ConfigurationData')) { + $resolveLabMediaParams['ConfigurationData'] = $ConfigurationData; + } + $media = ResolveLabMedia @resolveLabMediaParams; + + foreach ($hotfix in $media.Hotfixes) { + + $hotfixFileInfo = InvokeLabMediaHotfixDownload -Id $hotfix.Id -Uri $hotfix.Uri; + $packageName = [System.IO.Path]::GetFileNameWithoutExtension($hotfixFileInfo.FullName); + + AddDiskImagePackage -Name $packageName -Path $hotfixFileInfo.FullName -DestinationPath $vhdDriveLetter; + } + + } #end process + +} + diff --git a/Private/AddDiskImagePackage.ps1 b/Private/AddDiskImagePackage.ps1 new file mode 100644 index 00000000..59508b5f --- /dev/null +++ b/Private/AddDiskImagePackage.ps1 @@ -0,0 +1,54 @@ +function AddDiskImagePackage { + +<# + .SYNOPSIS + Adds a Windows package (.cab) to an image. This is implmented primarily to support injection of + packages into Nano server images. + .NOTES + The real difference between a hotfix and package is that a package can either be specified in the + master VHD(X) image creation OR be injected into VHD(X) differencing disk. +#> + [CmdletBinding()] + param ( + ## Package name (used for logging) + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## File path to the package (.cab) file + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Path, + + ## Destination operating system path (mounted VHD), i.e. G:\ + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath + ) + begin { + + ## We just want the drive letter + if ($DestinationPath.Length -gt 1) { + + $DestinationPath = $DestinationPath.Substring(0,1); + } + + } + process { + + $logPath = '{0}:\Windows\Logs\{1}' -f $DestinationPath, $labDefaults.ModuleName; + [ref] $null = NewDirectory -Path $logPath -Verbose:$false; + + WriteVerbose ($localized.AddingImagePackage -f $Name, $DestinationPath); + $addWindowsPackageParams = @{ + PackagePath = $Path; + Path = '{0}:\' -f $DestinationPath; + LogPath = '{0}\{1}.log' -f $logPath, $Name; + LogLevel = 'Errors'; + } + [ref] $null = Microsoft.Dism.Powershell\Add-WindowsPackage @addWindowsPackageParams -Verbose:$false; + + } #end process + +} + diff --git a/Private/AddWindowsOptionalFeature.ps1 b/Private/AddWindowsOptionalFeature.ps1 new file mode 100644 index 00000000..665631e6 --- /dev/null +++ b/Private/AddWindowsOptionalFeature.ps1 @@ -0,0 +1,46 @@ +function AddWindowsOptionalFeature { + +<# + .SYMOPSIS + Enables Windows optional features to an image. +#> + [CmdletBinding()] + param ( + ## Source package file path + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $ImagePath, + + ## Mounted VHD(X) Operating System disk drive + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + ## Windows packages to add to the image after expansion + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.String[]] $WindowsOptionalFeature, + + ## DISM log path + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] $LogPath = $DestinationPath + ) + process { + + WriteVerbose ($localized.AddingWindowsFeature -f ($WindowsOptionalFeature -join ','), $DestinationPath); + $enableWindowsOptionalFeatureParams = @{ + Source = $ImagePath; + Path = $DestinationPath; + LogPath = $LogPath; + FeatureName = $WindowsOptionalFeature; + LimitAccess = $true; + All = $true; + Verbose = $false; + } + $dismOutput = Microsoft.Dism.Powershell\Enable-WindowsOptionalFeature @enableWindowsOptionalFeatureParams; + + } #end process + +} + diff --git a/Private/AddWindowsPackage.ps1 b/Private/AddWindowsPackage.ps1 new file mode 100644 index 00000000..7fd3232c --- /dev/null +++ b/Private/AddWindowsPackage.ps1 @@ -0,0 +1,67 @@ +function AddWindowsPackage { + +<# + .SYNOPSIS + Adds a Windows package to an image. +#> + [CmdletBinding()] + param ( + ## Windows packages (.cab) files to add to the image after expansion + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.String[]] $Package, + + ## Path to the .cab files + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $PackagePath, + + ## Mounted VHD(X) Operating System disk drive + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + ## Package localization directory/extension (primarily used for Nano Server) + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $PackageLocale = 'en-US', + + ## DISM log path + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] $LogPath = $DestinationPath + ) + process { + + foreach ($packageName in $Package) { + + WriteVerbose ($localized.AddingWindowsPackage -f $packagename, $DestinationPath); + $packageFilename = '{0}.cab' -f $packageName; + $packageFilePath = Join-Path -Path $PackagePath -ChildPath $packageFilename; + AddDiskImagePackage -Name $packageName -Path $packageFilePath -DestinationPath $DestinationPath; + + ## Check for language-specific package (Change from Server 2016 TP releases and Server 2016 Nano RTM) + if ($PSBoundParameters.ContainsKey('PackageLocale')) { + + $localizedPackageName = '{0}_{1}' -f $packageName, $packageLocale; + $localizedPackageFilename = '{0}.cab' -f $localizedPackageName; + $localizedPackageDirectoryPath = Join-Path -Path $PackagePath -ChildPath $PackageLocale; + $localizedPackagePath = Join-Path -Path $localizedPackageDirectoryPath -ChildPath $localizedPackageFilename; + if (Test-Path -Path $localizedPackagePath -PathType Leaf) { + + WriteVerbose ($localized.AddingLocalizedWindowsPackage -f $localizedPackageName, $DestinationPath); + $addDiskImagePackageParams = @{ + Name = $localizedPackageName; + Path = $localizedPackagePath; + DestinationPath = $DestinationPath; + } + AddDiskImagePackage @addDiskImagePackageParams; + } + } + + } #end foreach package + + } #end process + +} + diff --git a/Private/CloseGitHubZipArchive.ps1 b/Private/CloseGitHubZipArchive.ps1 new file mode 100644 index 00000000..7b01e5d1 --- /dev/null +++ b/Private/CloseGitHubZipArchive.ps1 @@ -0,0 +1,22 @@ +function CloseGitHubZipArchive { + +<# + .SYNOPSIS + Tidies up and closes Zip Archive and file handles +#> + [CmdletBinding()] + param () + process { + + Write-Verbose ($localized.ClosingZipArchive -f $Path); + if ($null -ne $zipArchive) { + $zipArchive.Dispose(); + } + if ($null -ne $fileStream) { + $fileStream.Close(); + } + + } # end process + +} + diff --git a/Private/CloseZipArchive.ps1 b/Private/CloseZipArchive.ps1 new file mode 100644 index 00000000..5eaa9686 --- /dev/null +++ b/Private/CloseZipArchive.ps1 @@ -0,0 +1,22 @@ +function CloseZipArchive { + +<# + .SYNOPSIS + Tidies up and closes Zip Archive and file handles +#> + [CmdletBinding()] + param () + process { + + WriteVerbose -Message ($localized.ClosingZipArchive -f $Path); + if ($null -ne $zipArchive) { + $zipArchive.Dispose(); + } + if ($null -ne $fileStream) { + $fileStream.Close(); + } + + } # end process + +} + diff --git a/Private/ConvertPSObjectToHashtable.ps1 b/Private/ConvertPSObjectToHashtable.ps1 new file mode 100644 index 00000000..66a53c3e --- /dev/null +++ b/Private/ConvertPSObjectToHashtable.ps1 @@ -0,0 +1,47 @@ +function ConvertPSObjectToHashtable { + +<# + .SYNOPSIS + Converts a PSCustomObject's properties to a hashtable. +#> + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( + ## Object to convert to a hashtable + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [System.Management.Automation.PSObject[]] $InputObject, + + ## Do not add empty/null values to the generated hashtable + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $IgnoreNullValues + ) + process { + + foreach ($object in $InputObject) { + + $hashtable = @{ } + foreach ($property in $object.PSObject.Properties) { + + if ($IgnoreNullValues) { + if ([System.String]::IsNullOrEmpty($property.Value)) { + ## Ignore empty strings + continue; + } + } + + if ($property.TypeNameOfValue -eq 'System.Management.Automation.PSCustomObject') { + ## Convert nested custom objects to hashtables + $hashtable[$property.Name] = ConvertPSObjectToHashtable -InputObject $property.Value -IgnoreNullValues:$IgnoreNullValues; + } + else { + $hashtable[$property.Name] = $property.Value; + } + + } #end foreach property + Write-Output $hashtable; + + } + } #end proicess + +} + diff --git a/Private/ConvertToConfigurationData.ps1 b/Private/ConvertToConfigurationData.ps1 new file mode 100644 index 00000000..dee6e542 --- /dev/null +++ b/Private/ConvertToConfigurationData.ps1 @@ -0,0 +1,36 @@ +function ConvertToConfigurationData { + +<# + .SYNOPSIS + Converts a file path string to a hashtable. This mimics the -ConfigurationData parameter of the + Start-DscConfiguration cmdlet. + #> + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $ConfigurationData + ) + process { + + $configurationDataPath = Resolve-Path -Path $ConfigurationData -ErrorAction Stop; + if (-not (Test-Path -Path $configurationDataPath -PathType Leaf)) { + + throw ($localized.InvalidConfigurationDataFileError -f $ConfigurationData); + } + elseif ([System.IO.Path]::GetExtension($configurationDataPath) -ne '.psd1') { + + throw ($localized.InvalidConfigurationDataFileError -f $ConfigurationData); + } + $configurationDataContent = Get-Content -Path $configurationDataPath -Raw; + $configData = Invoke-Command -ScriptBlock ([System.Management.Automation.ScriptBlock]::Create($configurationDataContent)); + if ($configData -isnot [System.Collections.Hashtable]) { + + throw ($localized.InvalidConfigurationDataType -f $configData.GetType()); + } + return $configData; + + } #end process + +} + diff --git a/Private/CopyDirectory.ps1 b/Private/CopyDirectory.ps1 new file mode 100644 index 00000000..b2d51767 --- /dev/null +++ b/Private/CopyDirectory.ps1 @@ -0,0 +1,64 @@ +function CopyDirectory { + +<# + .SYNOPSIS + Copies a directory structure with progress. +#> + [CmdletBinding()] + param ( + ## Source directory path + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNull()] + [System.IO.DirectoryInfo] $SourcePath, + + ## Destination directory path + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.IO.DirectoryInfo] $DestinationPath, + + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.Management.Automation.SwitchParameter] $Force + ) + begin { + + if ((Get-Item $SourcePath) -isnot [System.IO.DirectoryInfo]) { + throw ($localized.CannotProcessArguentError -f 'CopyDirectory', 'SourcePath', $SourcePath, 'System.IO.DirectoryInfo'); + } + elseif (Test-Path -Path $SourcePath -PathType Leaf) { + throw ($localized.InvalidDestinationPathError -f $DestinationPath); + } + + } + process { + + $activity = $localized.CopyingResource -f $SourcePath.FullName, $DestinationPath; + $status = $localized.EnumeratingPath -f $SourcePath; + Write-Progress -Activity $activity -Status $status -PercentComplete 0; + $fileList = Get-ChildItem -Path $SourcePath -File -Recurse; + $currentDestinationPath = $SourcePath; + + for ($i = 0; $i -lt $fileList.Count; $i++) { + if ($currentDestinationPath -ne $fileList[$i].DirectoryName) { + ## We have a change of directory + $destinationDirectoryName = $fileList[$i].DirectoryName.Substring($SourcePath.FullName.Trim('\').Length); + $destinationDirectoryPath = Join-Path -Path $DestinationPath -ChildPath $destinationDirectoryName; + [ref] $null = New-Item -Path $destinationDirectoryPath -ItemType Directory -ErrorAction Ignore; + $currentDestinationPath = $fileList[$i].DirectoryName; + } + if (($i % 5) -eq 0) { + [System.Int16] $percentComplete = (($i + 1) / $fileList.Count) * 100; + $status = $localized.CopyingResourceStatus -f $i, $fileList.Count, $percentComplete; + Write-Progress -Activity $activity -Status $status -PercentComplete $percentComplete; + } + + $targetPath = Join-Path -Path $DestinationPath -ChildPath $fileList[$i].FullName.Replace($SourcePath, ''); + Copy-Item -Path $fileList[$i].FullName -Destination $targetPath -Force:$Force; + } #end for + + Write-Progress -Activity $activity -Completed; + + } #end process + +} + diff --git a/Private/ExpandDscModule.ps1 b/Private/ExpandDscModule.ps1 new file mode 100644 index 00000000..148ceace --- /dev/null +++ b/Private/ExpandDscModule.ps1 @@ -0,0 +1,42 @@ +function ExpandDscModule { + +<# + .SYNOPSIS + Extracts a DSC resource .zip archive using Windows Explorer and removes -master or -dev directory suffixes. +#> + [CmdletBinding()] + param ( + [Parameter(Mandatory)] + [System.String] $ModuleName, + + [Parameter(Mandatory)] + [System.String] $Path, + + [Parameter(Mandatory)] + [System.String] $DestinationPath, + + [Parameter()] + [System.Management.Automation.SwitchParameter] $Force + ) + process { + $targetPath = Join-Path -Path $DestinationPath -ChildPath $ModuleName; + if (-not (Test-Path -Path $targetPath) -or $Force) { + if (Test-Path -Path $targetPath) { + WriteVerbose ($localized.RemovingDirectory -f $targetPath); + Remove-Item -Path $targetPath -Recurse -Force -ErrorAction Stop; + } + WriteVerbose ($localized.ExpandingArchive -f $Path, $DestinationPath); + $shellApplication = New-Object -ComObject Shell.Application; + $archiveItems = $shellApplication.Namespace($Path).Items(); + $shellApplication.NameSpace($DestinationPath).CopyHere($archiveItems); + ## Rename any -master branch folder where no GitHub release available + Get-ChildItem -Path $DestinationPath -Directory | Where-Object { $_.Name -like '*-dev' -or $_.Name -like '*-master' } | ForEach-Object { + $destinationFilename = $_.Name -replace '-dev','' -replace '-master',''; + WriteVerbose ($localized.RenamingPath -f $_.FullName, $destinationFilename); + Rename-Item -Path $_.FullName -NewName $destinationFilename -ErrorAction Stop; + } + } + } #end process + +} + diff --git a/Private/ExpandGitHubZipArchive.ps1 b/Private/ExpandGitHubZipArchive.ps1 new file mode 100644 index 00000000..6521b4e0 --- /dev/null +++ b/Private/ExpandGitHubZipArchive.ps1 @@ -0,0 +1,99 @@ +function ExpandGitHubZipArchive { + +<# + .SYNOPSIS + Extracts a GitHub Zip archive. + .NOTES + This is an internal function and should not be called directly. + .LINK + This function is derived from the GitHubRepository (https://github.com/IainBrighton/GitHubRepositoryCompression) module. + .OUTPUTS + A System.IO.FileInfo object for each extracted file. +#> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + [OutputType([System.IO.FileInfo])] + param ( + # Source path to the Zip Archive. + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidateNotNullOrEmpty()] + [Alias('PSPath','FullName')] [System.String[]] $Path, + + # Destination file path to extract the Zip Archive item to. + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 1)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + # GitHub repository name + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Repository, + + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $OverrideRepository, + + # Overwrite existing files + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force + ) + begin { + + ## Validate destination path + if (-not (Test-Path -Path $DestinationPath -IsValid)) { + throw ($localized.InvalidDestinationPathError -f $DestinationPath); + } + + $DestinationPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($DestinationPath); + WriteVerbose ($localized.ResolvedDestinationPath -f $DestinationPath); + [Ref] $null = NewDirectory -Path $DestinationPath; + + foreach ($pathItem in $Path) { + + foreach ($resolvedPath in $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($pathItem)) { + WriteVerbose ($localized.ResolvedSourcePath -f $resolvedPath); + $LiteralPath += $resolvedPath; + } + } + + ## If all tests passed, load the required .NET assemblies + Write-Debug 'Loading ''System.IO.Compression'' .NET binaries.'; + Add-Type -AssemblyName 'System.IO.Compression'; + Add-Type -AssemblyName 'System.IO.Compression.FileSystem'; + + } # end begin + process { + + foreach ($pathEntry in $LiteralPath) { + + try { + + $zipArchive = [System.IO.Compression.ZipFile]::OpenRead($pathEntry); + $expandZipArchiveItemParams = @{ + InputObject = [ref] $zipArchive.Entries; + DestinationPath = $DestinationPath; + Repository = $Repository; + Force = $Force; + } + + if ($OverrideRepository) { + $expandZipArchiveItemParams['OverrideRepository'] = $OverrideRepository; + } + + ExpandGitHubZipArchiveItem @expandZipArchiveItemParams; + + } # end try + catch { + Write-Error $_.Exception; + } + finally { + ## Close the file handle + CloseGitHubZipArchive; + } + + } # end foreach + + } # end process + +} + diff --git a/Private/ExpandGitHubZipArchiveItem.ps1 b/Private/ExpandGitHubZipArchiveItem.ps1 new file mode 100644 index 00000000..9ea9752d --- /dev/null +++ b/Private/ExpandGitHubZipArchiveItem.ps1 @@ -0,0 +1,145 @@ +function ExpandGitHubZipArchiveItem { + +<# + .SYNOPSIS + Extracts file(s) from a GitHub Zip archive. + .NOTES + This is an internal function and should not be called directly. + .LINK + This function is derived from the VirtualEngine.Compression (https://github.com/VirtualEngine/Compression) module. + .OUTPUTS + A System.IO.FileInfo object for each extracted file. +#> + [CmdletBinding(DefaultParameterSetName = 'Path', SupportsShouldProcess, ConfirmImpact = 'Medium')] + [OutputType([System.IO.FileInfo])] + param ( + # Reference to Zip archive item. + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = 'InputObject')] + [ValidateNotNullOrEmpty()] + [System.IO.Compression.ZipArchiveEntry[]] [Ref] $InputObject, + + # Destination file path to extract the Zip Archive item to. + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 1)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + # GitHub repository name + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Repository, + + ## Override repository name + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $OverrideRepository, + + # Overwrite existing physical filesystem files + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force + ) + begin { + + Write-Debug 'Loading ''System.IO.Compression'' .NET binaries.'; + Add-Type -AssemblyName 'System.IO.Compression'; + Add-Type -AssemblyName 'System.IO.Compression.FileSystem'; + + } + process { + + try { + + ## Regex for locating the -\ root directory + $searchString = '^{0}-\S+?\\' -f $Repository; + $replacementString = '{0}\' -f $Repository; + if ($OverrideRepository) { + $replacementString = '{0}\' -f $OverrideRepository; + } + + [System.Int32] $fileCount = 0; + $moduleDestinationPath = Join-Path -Path $DestinationPath -ChildPath $Repository; + $activity = $localized.DecompressingArchive -f $moduleDestinationPath; + Write-Progress -Activity $activity -PercentComplete 0; + + foreach ($zipArchiveEntry in $InputObject) { + + $fileCount++; + if (($fileCount % 5) -eq 0) { + [System.Int16] $percentComplete = ($fileCount / $InputObject.Count) * 100 + $status = $localized.CopyingResourceStatus -f $fileCount, $InputObject.Count, $percentComplete; + Write-Progress -Activity $activity -Status $status -PercentComplete $percentComplete; + } + + if ($zipArchiveEntry.FullName.Contains('/')) { + + ## We need to create the directory path as the ExtractToFile extension method won't do this and will throw an exception + $pathSplit = $zipArchiveEntry.FullName.Split('/'); + $relativeDirectoryPath = New-Object System.Text.StringBuilder; + + ## Generate the relative directory name + for ($pathSplitPart = 0; $pathSplitPart -lt ($pathSplit.Count -1); $pathSplitPart++) { + [ref] $null = $relativeDirectoryPath.AppendFormat('{0}\', $pathSplit[$pathSplitPart]); + } + ## Rename the GitHub \-\ root directory to \\ + $relativePath = ($relativeDirectoryPath.ToString() -replace $searchString, $replacementString).TrimEnd('\'); + + ## Create the destination directory path, joining the relative directory name + $directoryPath = Join-Path -Path $DestinationPath -ChildPath $relativePath; + [ref] $null = NewDirectory -Path $directoryPath; + + $fullDestinationFilePath = Join-Path -Path $directoryPath -ChildPath $zipArchiveEntry.Name; + } # end if + else { + + ## Just a file in the root so just use the $DestinationPath + $fullDestinationFilePath = Join-Path -Path $DestinationPath -ChildPath $zipArchiveEntry.Name; + } # end else + + if ([System.String]::IsNullOrEmpty($zipArchiveEntry.Name)) { + + ## This is a folder and we need to create the directory path as the + ## ExtractToFile extension method won't do this and will throw an exception + $pathSplit = $zipArchiveEntry.FullName.Split('/'); + $relativeDirectoryPath = New-Object System.Text.StringBuilder; + + ## Generate the relative directory name + for ($pathSplitPart = 0; $pathSplitPart -lt ($pathSplit.Count -1); $pathSplitPart++) { + [ref] $null = $relativeDirectoryPath.AppendFormat('{0}\', $pathSplit[$pathSplitPart]); + } + + ## Rename the GitHub \-\ root directory to \\ + $relativePath = ($relativeDirectoryPath.ToString() -replace $searchString, $replacementString).TrimEnd('\'); + + ## Create the destination directory path, joining the relative directory name + $directoryPath = Join-Path -Path $DestinationPath -ChildPath $relativePath; + [ref] $null = NewDirectory -Path $directoryPath; + + $fullDestinationFilePath = Join-Path -Path $directoryPath -ChildPath $zipArchiveEntry.Name; + } + elseif (-not $Force -and (Test-Path -Path $fullDestinationFilePath -PathType Leaf)) { + + ## Are we overwriting existing files (-Force)? + Write-Warning ($localized.TargetFileExistsWarning -f $fullDestinationFilePath); + } + else { + + ## Just overwrite any existing file + if ($Force -or $PSCmdlet.ShouldProcess($fullDestinationFilePath, 'Expand')) { + Write-Debug ($localized.ExtractingZipArchiveEntry -f $fullDestinationFilePath); + [System.IO.Compression.ZipFileExtensions]::ExtractToFile($zipArchiveEntry, $fullDestinationFilePath, $true); + ## Return a FileInfo object to the pipline + Write-Output (Get-Item -Path $fullDestinationFilePath); + } + } # end if + } # end foreach zipArchiveEntry + + Write-Progress -Activity $activity -Completed; + + } # end try + catch { + Write-Error $_.Exception; + } + + } # end process + +} + diff --git a/Private/ExpandIso.ps1 b/Private/ExpandIso.ps1 new file mode 100644 index 00000000..709cb80e --- /dev/null +++ b/Private/ExpandIso.ps1 @@ -0,0 +1,32 @@ +function ExpandIso { + +<# + .SYNOPSIS + Expands an ISO disk image resource +#> + param ( + ## Source ISO file path + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Path, + + ## Destination folder path + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $DestinationPath + ) + process { + + WriteVerbose ($localized.MountingDiskImage -f $Path); + $iso = Mount-DiskImage -ImagePath $Path -StorageType ISO -Access ReadOnly -PassThru -Verbose:$false; + ## Refresh drives + [ref] $null = Get-PSDrive; + $isoDriveLetter = $iso | Get-Volume | Select-Object -ExpandProperty DriveLetter; + $sourcePath = '{0}:\' -f $isoDriveLetter; + WriteVerbose ($localized.ExpandingIsoResource -f $DestinationPath); + CopyDirectory -SourcePath $sourcePath -DestinationPath $DestinationPath -Force -Verbose:$false; + WriteVerbose ($localized.DismountingDiskImage -f $Path); + Dismount-DiskImage -ImagePath $Path; + + } #end process + +} + diff --git a/Private/ExpandLabResource.ps1 b/Private/ExpandLabResource.ps1 new file mode 100644 index 00000000..271fdc78 --- /dev/null +++ b/Private/ExpandLabResource.ps1 @@ -0,0 +1,157 @@ +function ExpandLabResource { + +<# + .SYNOPSIS + Copies files, e.g. EXEs, ISOs and ZIP file resources into a lab VM's mounted VHDX differencing disk image. + .NOTES + VHDX should already be mounted and passed in via the $DestinationPath parameter + Can expand ISO and ZIP files if the 'Expand' property is set to $true on the resource's properties. +#> + param ( + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Lab VM name + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## Destination mounted VHDX path to expand resources into + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + ## Source resource path + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ResourcePath + ) + begin { + + if (-not $ResourcePath) { + + $hostDefaults = GetConfigurationData -Configuration Host; + $ResourcePath = $hostDefaults.ResourcePath; + } + + } + process { + + ## Create the root destination (\Resources) container + if (-not (Test-Path -Path $DestinationPath -PathType Container)) { + + [ref] $null = New-Item -Path $DestinationPath -ItemType Directory -Force; + } + + $node = ResolveLabVMProperties -NodeName $Name -ConfigurationData $ConfigurationData -ErrorAction Stop; + foreach ($resourceId in $node.Resource) { + + WriteVerbose ($localized.AddingResource -f $resourceId); + $resource = ResolveLabResource -ConfigurationData $ConfigurationData -ResourceId $resourceId; + + ## Default to resource.Id unless there is a filename property defined! + $resourceSourcePath = Join-Path $resourcePath -ChildPath $resource.Id; + + if ($resource.Filename) { + + $resourceSourcePath = Join-Path $resourcePath -ChildPath $resource.Filename; + if ($resource.IsLocal) { + + $resourceSourcePath = Resolve-Path -Path $resource.Filename; + } + } + + if (-not (Test-Path -Path $resourceSourcePath) -and (-not $resource.IsLocal)) { + + $invokeLabResourceDownloadParams = @{ + ConfigurationData = $ConfigurationData; + ResourceId = $resourceId; + } + [ref] $null = Invoke-LabResourceDownload @invokeLabResourceDownloadParams; + } + + if (-not (Test-Path -Path $resourceSourcePath)) { + + throw ($localized.CannotResolveResourceIdError -f $resourceId); + } + + $resourceItem = Get-Item -Path $resourceSourcePath; + $resourceDestinationPath = $DestinationPath; + + if ($resource.DestinationPath -and (-not [System.String]::IsNullOrEmpty($resource.DestinationPath))) { + + $destinationDrive = Split-Path -Path $DestinationPath -Qualifier; + $resourceDestinationPath = Join-Path -Path $destinationDrive -ChildPath $resource.DestinationPath; + + ## We can't create a drive-rooted folder! + if (($resource.DestinationPath -ne '\') -and (-not (Test-Path -Path $resourceDestinationPath))) { + + [ref] $null = New-Item -Path $resourceDestinationPath -ItemType Directory -Force; + } + } + elseif ($resource.IsLocal -and ($resource.IsLocal -eq $true)) { + + $relativeLocalPath = ($resource.Filename).TrimStart('.'); + $resourceDestinationPath = Join-Path -Path $DestinationPath -ChildPath $relativeLocalPath; + } + + if (($resource.Expand) -and ($resource.Expand -eq $true)) { + + if ([System.String]::IsNullOrEmpty($resource.DestinationPath)) { + + ## No explicit destination path, so expand into the \ folder + $resourceDestinationPath = Join-Path -Path $DestinationPath -ChildPath $resource.Id; + } + + if (-not (Test-Path -Path $resourceDestinationPath)) { + + [ref] $null = New-Item -Path $resourceDestinationPath -ItemType Directory -Force; + } + + switch ([System.IO.Path]::GetExtension($resourceSourcePath)) { + + '.iso' { + + ExpandIso -Path $resourceItem.FullName -DestinationPath $resourceDestinationPath; + } + + '.zip' { + + WriteVerbose ($localized.ExpandingZipResource -f $resourceItem.FullName); + $expandZipArchiveParams = @{ + Path = $resourceItem.FullName; + DestinationPath = $resourceDestinationPath; + Verbose = $false; + } + [ref] $null = ExpandZipArchive @expandZipArchiveParams; + } + + Default { + + throw ($localized.ExpandNotSupportedError -f $resourceItem.Extension); + } + + } #end switch + } + else { + + WriteVerbose ($localized.CopyingFileResource -f $resourceDestinationPath); + $copyItemParams = @{ + Path = "$($resourceItem.FullName)"; + Destination = "$resourceDestinationPath"; + Force = $true; + Recurse = $true; + Verbose = $false; + } + Copy-Item @copyItemParams; + } + + } #end foreach ResourceId + + } #end process + +} + diff --git a/Private/ExpandModuleCache.ps1 b/Private/ExpandModuleCache.ps1 new file mode 100644 index 00000000..900e448e --- /dev/null +++ b/Private/ExpandModuleCache.ps1 @@ -0,0 +1,130 @@ +function ExpandModuleCache { + +<# + .SYNOPSIS + Extracts a cached PowerShell module to the specified destination module path. +#> + [CmdletBinding()] + [OutputType([System.IO.DirectoryInfo])] + param ( + ## PowerShell module hashtable + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.Collections.Hashtable[]] $Module, + + ## Destination directory path to download the PowerShell module/DSC resource module to + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + ## Removes existing module directory if present + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Clean, + + ## Catch all to be able to pass parameter via $PSBoundParameters + [Parameter(ValueFromRemainingArguments)] + $RemainingArguments + ) + begin { + + [ref] $null = $PSBoundParameters.Remove('RemainingArguments'); + + } + process { + + foreach ($moduleInfo in $Module) { + + $moduleFileInfo = GetModuleCache @moduleInfo; + $moduleSourcePath = $moduleFileInfo.FullName; + $moduleDestinationPath = Join-Path -Path $DestinationPath -ChildPath $moduleInfo.Name; + + if ($Clean -and (Test-Path -Path $moduleDestinationPath -PathType Container)) { + WriteVerbose -Message ($localized.CleaningModuleDirectory -f $moduleDestinationPath); + Remove-Item -Path $moduleDestinationPath -Recurse -Force -Confirm:$false; + } + + if ((-not $moduleInfo.ContainsKey('Provider')) -or + ($moduleInfo.Provider -eq 'PSGallery')) { + + WriteVerbose -Message ($localized.ExpandingModule -f $moduleDestinationPath); + $expandZipArchiveParams = @{ + Path = $moduleSourcePath; + DestinationPath = $moduleDestinationPath; + ExcludeNuSpecFiles = $true; + Force = $true; + Verbose = $false; + WarningAction = 'SilentlyContinue'; + } + [ref] $null = ExpandZipArchive @expandZipArchiveParams; + + } #end if PSGallery + elseif (($moduleInfo.ContainsKey('Provider')) -and + ($moduleInfo.Provider -eq 'GitHub')) { + + WriteVerbose -Message ($localized.ExpandingModule -f $moduleDestinationPath); + $expandGitHubZipArchiveParams = @{ + Path = $moduleSourcePath; + ## GitHub modules include the module directory. Therefore, we need the parent root directory + DestinationPath = Split-Path -Path $moduleDestinationPath -Parent;; + Repository = $moduleInfo.Name; + Force = $true; + Verbose = $false; + WarningAction = 'SilentlyContinue'; + } + + if ($moduleInfo.ContainsKey('OverrideRepository')) { + $expandGitHubZipArchiveParams['OverrideRepository'] = $moduleInfo.OverrideRepository; + } + + [ref] $null = ExpandGitHubZipArchive @expandGitHubZipArchiveParams; + + } #end if GitHub + elseif (($moduleInfo.ContainsKey('Provider')) -and + ($moduleInfo.Provider -eq 'FileSystem')) { + if ($null -ne $moduleFileInfo) { + + if ($moduleFileInfo -is [System.IO.FileInfo]) { + + WriteVerbose -Message ($localized.ExpandingModule -f $moduleDestinationPath); + $expandZipArchiveParams = @{ + Path = $moduleSourcePath; + DestinationPath = $moduleDestinationPath; + ExcludeNuSpecFiles = $true; + Force = $true; + Verbose = $false; + WarningAction = 'SilentlyContinue'; + } + [ref] $null = ExpandZipArchive @expandZipArchiveParams; + } + elseif ($moduleFileInfo -is [System.IO.DirectoryInfo]) { + + WriteVerbose -Message ($localized.CopyingModuleDirectory -f $moduleFileInfo.Name, $moduleDestinationPath); + ## If the target doesn't exist create it. We may be copying a versioned + ## module, i.e. \xJea\0.2.16.6 to \xJea.. + if (-not (Test-Path -Path $moduleDestinationPath -PathType Container)) { + New-Item -Path $moduleDestinationPath -ItemType Directory -Force; + } + $copyItemParams = @{ + Path = "$moduleSourcePath\*"; + Destination = $moduleDestinationPath; + Recurse = $true; + Force = $true; + Verbose = $false; + } + Copy-Item @copyItemParams; + } + + } + } #end if FileSystem + + ## Only output if we found a module during this pass + if ($null -ne $moduleFileInfo) { + Write-Output -InputObject (Get-Item -Path $moduleDestinationPath); + } + + } #end foreach module + + } #end process + +} + diff --git a/Private/ExpandWindowsImage.ps1 b/Private/ExpandWindowsImage.ps1 new file mode 100644 index 00000000..ef9f5310 --- /dev/null +++ b/Private/ExpandWindowsImage.ps1 @@ -0,0 +1,156 @@ +function ExpandWindowsImage { + +<# + .SYNOPSIS + Writes a .wim image to a mounted VHD/(X) file. +#> + [CmdletBinding(DefaultParameterSetName = 'Index')] + param ( + ## File path to WIM file or ISO file containing the WIM image + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $MediaPath, + + ## WIM image index to apply + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'Index')] + [System.Int32] $WimImageIndex, + + ## WIM image name to apply + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [ValidateNotNullOrEmpty()] + [System.String] $WimImageName, + + ## Mounted VHD(X) Operating System disk image + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.Object] $Vhd, # Microsoft.Vhd.PowerShell.VirtualHardDisk + + ## Disk image partition scheme + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateSet('MBR','GPT')] + [System.String] $PartitionStyle, + + ## Optional Windows features to add to the image after expansion (ISO only) + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.String[]] $WindowsOptionalFeature, + + ## Optional Windows features source path + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $SourcePath = '\sources\sxs', + + ## Relative source WIM file path (only used for ISOs) + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $WimPath = '\sources\install.wim', + + ## Optional Windows packages to add to the image after expansion (primarily used for Nano Server) + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.String[]] $Package, + + ## Relative packages (.cab) file path (primarily used for Nano Server) + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $PackagePath = '\packages', + + ## Package localization directory/extension (primarily used for Nano Server) + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $PackageLocale = 'en-US' + ) + process { + + ## Assume the media path is a literal path to a WIM file + $windowsImagePath = $MediaPath; + $mediaFileInfo = Get-Item -Path $MediaPath; + + if ($mediaFileInfo.Extension -eq '.ISO') { + + ## Mount ISO + WriteVerbose ($localized.MountingDiskImage -f $MediaPath); + $iso = Mount-DiskImage -ImagePath $MediaPath -StorageType ISO -Access ReadOnly -PassThru -Verbose:$false; + $iso = Get-DiskImage -ImagePath $iso.ImagePath; + $isoDriveLetter = $iso | Get-Volume | Select-Object -ExpandProperty DriveLetter; + ## Update the media path to point to the mounted ISO + $windowsImagePath = '{0}:{1}' -f $isoDriveLetter, $WimPath; + } + + if ($PSCmdlet.ParameterSetName -eq 'Name') { + + ## Locate the image index + $WimImageIndex = GetWindowsImageIndex -ImagePath $windowsImagePath -ImageName $WimImageName; + } + + if ($PartitionStyle -eq 'MBR') { + + $partitionType = 'IFS'; + } + elseif ($PartitionStyle -eq 'GPT') { + + $partitionType = 'Basic'; + } + $vhdDriveLetter = GetDiskImageDriveLetter -DiskImage $Vhd -PartitionType $partitionType; + + $logName = '{0}.log' -f [System.IO.Path]::GetFileNameWithoutExtension($Vhd.Path); + $logPath = Join-Path -Path $env:TEMP -ChildPath $logName; + WriteVerbose ($localized.ApplyingWindowsImage -f $WimImageIndex, $Vhd.Path); + $expandWindowsImage = @{ + ImagePath = $windowsImagePath; + ApplyPath = '{0}:\' -f $vhdDriveLetter; + LogPath = $logPath; + Index = $WimImageIndex; + } + $dismOutput = Expand-WindowsImage @expandWindowsImage -Verbose:$false; + + [ref] $null = Get-PSDrive; + + ## Add additional packages (.cab) files + if ($Package) { + + ## Default to relative package folder path + $addWindowsPackageParams = @{ + PackagePath = '{0}:{1}' -f $isoDriveLetter, $PackagePath; + DestinationPath = '{0}:\' -f $vhdDriveLetter; + LogPath = $logPath; + Package = $Package; + PackageLocale = $PackageLocale; + } + if (-not $PackagePath.StartsWith('\')) { + + ## Use the specified/literal path + $addWindowsPackageParams['PackagePath'] = $PackagePath; + } + $dismOutput = AddWindowsPackage @addWindowsPackageParams; + + } #end if Package + + ## Add additional features if required + if ($WindowsOptionalFeature) { + + ## Default to ISO relative source folder path + $addWindowsOptionalFeatureParams = @{ + ImagePath = '{0}:{1}' -f $isoDriveLetter, $SourcePath; + DestinationPath = '{0}:\' -f $vhdDriveLetter; + LogPath = $logPath; + WindowsOptionalFeature = $WindowsOptionalFeature; + } + if ($mediaFileInfo.Extension -eq '.WIM') { + + ## The Windows optional feature source path for .WIM files is a literal path + $addWindowsOptionalFeatureParams['ImagePath'] = $SourcePath; + } + $dismOutput = AddWindowsOptionalFeature @addWindowsOptionalFeatureParams; + } #end if WindowsOptionalFeature + + if ($mediaFileInfo.Extension -eq '.ISO') { + + ## Dismount ISO + WriteVerbose ($localized.DismountingDiskImage -f $MediaPath); + Dismount-DiskImage -ImagePath $MediaPath; + } + + } #end process + +} + diff --git a/Private/ExpandZipArchive.ps1 b/Private/ExpandZipArchive.ps1 new file mode 100644 index 00000000..2d8fe6fd --- /dev/null +++ b/Private/ExpandZipArchive.ps1 @@ -0,0 +1,89 @@ +function ExpandZipArchive { + +<# + .SYNOPSIS + Extracts a Zip archive. + .NOTES + This is an internal function and should not be called directly. + .LINK + This function is derived from the VirtualEngine.Compression (https://github.com/VirtualEngine/Compression) module. + .OUTPUTS + A System.IO.FileInfo object for each extracted file. +#> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] + [OutputType([System.IO.FileInfo])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + param ( + # Source path to the Zip Archive. + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0)] + [ValidateNotNullOrEmpty()] + [Alias('PSPath','FullName')] [System.String[]] $Path, + + # Destination file path to extract the Zip Archive item to. + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 1)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + # Excludes NuGet .nuspec specific files + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $ExcludeNuSpecFiles, + + # Overwrite existing files + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force + ) + begin { + + ## Validate destination path + if (-not (Test-Path -Path $DestinationPath -IsValid)) { + throw ($localized.InvalidDestinationPathError -f $DestinationPath); + } + + $DestinationPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($DestinationPath); + WriteVerbose -Message ($localized.ResolvedDestinationPath -f $DestinationPath); + [ref] $null = NewDirectory -Path $DestinationPath; + + foreach ($pathItem in $Path) { + foreach ($resolvedPath in $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($pathItem)) { + WriteVerbose -Message ($localized.ResolvedSourcePath -f $resolvedPath); + $LiteralPath += $resolvedPath; + } + } + + ## If all tests passed, load the required .NET assemblies + Write-Debug -Message 'Loading ''System.IO.Compression'' .NET binaries.'; + Add-Type -AssemblyName 'System.IO.Compression'; + Add-Type -AssemblyName 'System.IO.Compression.FileSystem'; + + } # end begin + process { + + foreach ($pathEntry in $LiteralPath) { + + try { + + $zipArchive = [System.IO.Compression.ZipFile]::OpenRead($pathEntry); + $expandZipArchiveItemParams = @{ + InputObject = [ref] $zipArchive.Entries; + DestinationPath = $DestinationPath; + ExcludeNuSpecFiles = $ExcludeNuSpecFiles; + Force = $Force; + } + + ExpandZipArchiveItem @expandZipArchiveItemParams; + + } # end try + catch { + Write-Error -Message $_.Exception; + } + finally { + ## Close the file handle + CloseZipArchive; + } + + } # end foreach + + } # end process + +} + diff --git a/Private/ExpandZipArchiveItem.ps1 b/Private/ExpandZipArchiveItem.ps1 new file mode 100644 index 00000000..5403f72a --- /dev/null +++ b/Private/ExpandZipArchiveItem.ps1 @@ -0,0 +1,128 @@ +function ExpandZipArchiveItem { + +<# + .SYNOPSIS + Extracts file(s) from a Zip archive. + .NOTES + This is an internal function and should not be called directly. + .LINK + This function is derived from the VirtualEngine.Compression (https://github.com/VirtualEngine/Compression) module. + .OUTPUTS + A System.IO.FileInfo object for each extracted file. +#> + [CmdletBinding(DefaultParameterSetName='Path', SupportsShouldProcess, ConfirmImpact = 'Medium')] + [OutputType([System.IO.FileInfo])] + param ( + # Reference to Zip archive item. + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = 'InputObject')] + [ValidateNotNullOrEmpty()] [System.IO.Compression.ZipArchiveEntry[]] [ref] $InputObject, + + # Destination file path to extract the Zip Archive item to. + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 1)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + # Excludes NuGet .nuspec specific files + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $ExcludeNuSpecFiles, + + # Overwrite existing physical filesystem files + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force + ) + begin { + + Write-Debug -Message 'Loading ''System.IO.Compression'' .NET binaries.'; + Add-Type -AssemblyName 'System.IO.Compression'; + Add-Type -AssemblyName 'System.IO.Compression.FileSystem'; + + } + process { + + try { + + [System.Int32] $fileCount = 0; + $activity = $localized.DecompressingArchive -f $DestinationPath; + Write-Progress -Activity $activity -PercentComplete 0; + foreach ($zipArchiveEntry in $InputObject) { + + $fileCount++; + if (($fileCount % 5) -eq 0) { + [System.Int16] $percentComplete = ($fileCount / $InputObject.Count) * 100 + $status = $localized.CopyingResourceStatus -f $fileCount, $InputObject.Count, $percentComplete; + Write-Progress -Activity $activity -Status $status -PercentComplete $percentComplete; + } + + ## Exclude the .nuspec specific files + if ($ExcludeNuSpecFiles -and ($zipArchiveEntry.FullName -match '(_rels\/)|(\[Content_Types\]\.xml)|(\w+\.nuspec)')) { + WriteVerbose -Message ($localized.IgnoringNuspecZipArchiveEntry -f $zipArchiveEntry.FullName); + continue; + } + + if ($zipArchiveEntry.FullName.Contains('/')) { + ## We need to create the directory path as the ExtractToFile extension method won't do this and will throw an exception + $pathSplit = $zipArchiveEntry.FullName.Split('/'); + $relativeDirectoryPath = New-Object -TypeName System.Text.StringBuilder; + + ## Generate the relative directory name + for ($pathSplitPart = 0; $pathSplitPart -lt ($pathSplit.Count -1); $pathSplitPart++) { + [ref] $null = $relativeDirectoryPath.AppendFormat('{0}\', $pathSplit[$pathSplitPart]); + } + $relativePath = $relativeDirectoryPath.ToString(); + + ## Create the destination directory path, joining the relative directory name + $directoryPath = Join-Path -Path $DestinationPath -ChildPath $relativePath; + [ref] $null = NewDirectory -Path $directoryPath; + + $fullDestinationFilePath = Join-Path -Path $directoryPath -ChildPath $zipArchiveEntry.Name; + } # end if + else { + ## Just a file in the root so just use the $DestinationPath + $fullDestinationFilePath = Join-Path -Path $DestinationPath -ChildPath $zipArchiveEntry.Name; + } # end else + + if ([System.String]::IsNullOrEmpty($zipArchiveEntry.Name)) { + ## This is a folder and we need to create the directory path as the + ## ExtractToFile extension method won't do this and will throw an exception + $pathSplit = $zipArchiveEntry.FullName.Split('/'); + $relativeDirectoryPath = New-Object -TypeName System.Text.StringBuilder; + + ## Generate the relative directory name + for ($pathSplitPart = 0; $pathSplitPart -lt ($pathSplit.Count -1); $pathSplitPart++) { + [ref] $null = $relativeDirectoryPath.AppendFormat('{0}\', $pathSplit[$pathSplitPart]); + } + $relativePath = $relativeDirectoryPath.ToString(); + + ## Create the destination directory path, joining the relative directory name + $directoryPath = Join-Path -Path $DestinationPath -ChildPath $relativePath; + [ref] $null = NewDirectory -Path $directoryPath; + + $fullDestinationFilePath = Join-Path -Path $directoryPath -ChildPath $zipArchiveEntry.Name; + } + elseif (-not $Force -and (Test-Path -Path $fullDestinationFilePath -PathType Leaf)) { + ## Are we overwriting existing files (-Force)? + WriteWarning -Message ($localized.TargetFileExistsWarning -f $fullDestinationFilePath); + } + else { + ## Just overwrite any existing file + if ($Force -or $PSCmdlet.ShouldProcess($fullDestinationFilePath, 'Expand')) { + WriteVerbose -Message ($localized.ExtractingZipArchiveEntry -f $fullDestinationFilePath); + [System.IO.Compression.ZipFileExtensions]::ExtractToFile($zipArchiveEntry, $fullDestinationFilePath, $true); + ## Return a FileInfo object to the pipline + Write-Output -InputObject (Get-Item -Path $fullDestinationFilePath); + } + } # end if + + } # end foreach zipArchiveEntry + + Write-Progress -Activity $activity -Completed; + + } # end try + catch { + Write-Error -Message $_.Exception; + } + + } # end process + +} + diff --git a/Private/GetConfigurationData.ps1 b/Private/GetConfigurationData.ps1 new file mode 100644 index 00000000..7e70fb75 --- /dev/null +++ b/Private/GetConfigurationData.ps1 @@ -0,0 +1,93 @@ +function GetConfigurationData { + +<# + .SYNOPSIS + Gets lab configuration data. +#> + [CmdletBinding()] + [OutputType([System.Management.Automation.PSCustomObject])] + param ( + [Parameter(Mandatory)] + [ValidateSet('Host','VM','Media','CustomMedia')] + [System.String] $Configuration + ) + process { + + $configurationPath = ResolveConfigurationDataPath -Configuration $Configuration -IncludeDefaultPath; + if (Test-Path -Path $configurationPath) { + $configurationData = Get-Content -Path $configurationPath -Raw | ConvertFrom-Json; + + switch ($Configuration) { + + 'VM' { + + ## This property may not be present in the original VM default file TODO: Could be deprecated in the future + if ($configurationData.PSObject.Properties.Name -notcontains 'CustomBootstrapOrder') { + + [ref] $null = Add-Member -InputObject $configurationData -MemberType NoteProperty -Name 'CustomBootstrapOrder' -Value 'MediaFirst'; + } + ## This property may not be present in the original VM default file TODO: Could be deprecated in the future + if ($configurationData.PSObject.Properties.Name -notcontains 'SecureBoot') { + + [ref] $null = Add-Member -InputObject $configurationData -MemberType NoteProperty -Name 'SecureBoot' -Value $true; + } + ## This property may not be present in the original VM default file TODO: Could be deprecated in the future + if ($configurationData.PSObject.Properties.Name -notcontains 'GuestIntegrationServices') { + + [ref] $null = Add-Member -InputObject $configurationData -MemberType NoteProperty -Name 'GuestIntegrationServices' -Value $false; + } + } + 'CustomMedia' { + + foreach ($mediaItem in $configurationData) { + + ## Add missing OperatingSystem property + if ($mediaItem.PSObject.Properties.Name -notcontains 'OperatingSystem') { + + [ref] $null = Add-Member -InputObject $mediaItem -MemberType NoteProperty -Name 'OperatingSystem' -Value 'Windows'; + } + } #end foreach media item + } + 'Host' { + + ## This property may not be present in the original machine configuration file + if ($configurationData.PSObject.Properties.Name -notcontains 'DisableLocalFileCaching') { + + [ref] $null = Add-Member -InputObject $configurationData -MemberType NoteProperty -Name 'DisableLocalFileCaching' -Value $false; + } + ## This property may not be present in the original machine configuration file + if ($configurationData.PSObject.Properties.Name -notcontains 'EnableCallStackLogging') { + + [ref] $null = Add-Member -InputObject $configurationData -MemberType NoteProperty -Name 'EnableCallStackLogging' -Value $false; + } + ## This property may not be present in the original machine configuration file + if ($configurationData.PSObject.Properties.Name -notcontains 'ModuleCachePath') { + + [ref] $null = Add-Member -InputObject $configurationData -MemberType NoteProperty -Name 'ModuleCachePath' -Value '%ALLUSERSPROFILE%\Lability\Modules'; + } + if ($configurationData.PSObject.Properties.Name -notcontains 'DismPath') { + + $dismDllName = 'Microsoft.Dism.PowerShell.dll'; + $dismDllPath = Join-Path -Path "$env:SystemRoot\System32\WindowsPowerShell\v1.0\Modules\Dism" -ChildPath $dismDllName -Resolve; + [ref] $null = Add-Member -InputObject $configurationData -MemberType NoteProperty -Name 'DismPath' -Value $dismDllPath; + } + + ## Remove deprecated UpdatePath, if present (Issue #77) + $configurationData.PSObject.Properties.Remove('UpdatePath'); + } + } #end switch + + # Expand any environment variables in configuration data + $configurationData.PSObject.Members | + Where-Object { ($_.MemberType -eq 'NoteProperty') -and ($_.IsSettable) -and ($_.TypeNameOfValue -eq 'System.String') } | + ForEach-Object { + $_.Value = [System.Environment]::ExpandEnvironmentVariables($_.Value); + } + + return $configurationData; + } + + } #end process + +} + diff --git a/Private/GetDiskImageDriveLetter.ps1 b/Private/GetDiskImageDriveLetter.ps1 new file mode 100644 index 00000000..b7457594 --- /dev/null +++ b/Private/GetDiskImageDriveLetter.ps1 @@ -0,0 +1,32 @@ +function GetDiskImageDriveLetter { + +<# + .SYNOPSIS + Return a disk image's associated/mounted drive letter. +#> + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [System.Object] $DiskImage, + + [Parameter(Mandatory)] + [ValidateSet('Basic','System','IFS')] + [System.String] $PartitionType + ) + process { + + # Microsoft.Vhd.PowerShell.VirtualHardDisk + $driveLetter = Get-Partition -DiskNumber $DiskImage.DiskNumber | + Where-Object Type -eq $PartitionType | + Where-Object DriveLetter | + Select-Object -Last 1 -ExpandProperty DriveLetter; + + if (-not $driveLetter) { + + throw ($localized.CannotLocateDiskImageLetter -f $DiskImage.Path); + } + return $driveLetter; + } + +} + diff --git a/Private/GetDscModule.ps1 b/Private/GetDscModule.ps1 new file mode 100644 index 00000000..339b67b8 --- /dev/null +++ b/Private/GetDscModule.ps1 @@ -0,0 +1,40 @@ +function GetDscModule { + +<# + .SYNOPSIS + Locates the directory path of the ResourceName within the specified DSC ModuleName. +#> + [CmdletBinding()] + [OutputType([System.String])] + param ( + [Parameter(Mandatory)] + [System.String] $ModuleName, + + [Parameter()] + [System.String] $ResourceName, + + [Parameter()] [ValidateNotNullOrEmpty()] + [System.String] $MinimumVersion + ) + process { + $module = Get-Module -Name $ModuleName -ListAvailable; + $dscModulePath = Split-Path -Path $module.Path -Parent; + if ($ResourceName) { + $ModuleName = '{0}\{1}' -f $ModuleName, $ResourceName; + $dscModulePath = Join-Path -Path $dscModulePath -ChildPath "DSCResources\$ResourceName"; + } + if (-not (Test-Path -Path $dscModulePath)) { + Write-Error -Message ($localized.DscResourceNotFoundError -f $ModuleName); + return $null; + } + if ($MinimumVersion) { + if ($Module.Version -lt [System.Version]$MinimumVersion) { + Write-Error -Message ($localized.ResourceVersionMismatchError -f $ModuleName, $module.Version.ToString(), $MinimumVersion); + return $null; + } + } + return $dscModulePath; + } #end process + +} + diff --git a/Private/GetDscResource.ps1 b/Private/GetDscResource.ps1 new file mode 100644 index 00000000..e85a0b50 --- /dev/null +++ b/Private/GetDscResource.ps1 @@ -0,0 +1,44 @@ +function GetDscResource { + +<# + .SYNOPSIS + Gets the ResourceName DSC resource configuration. + .DESCRIPTION + The GetDscResource cmdlet invokes the target $ResourceName\Get-TargetResource function using the supplied + $Parameters hashtable. +#> + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( + ## Name of the DSC resource to get + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $ResourceName, + + ## The DSC resource's Get-TargetResource parameter hashtable + [Parameter(Mandatory)] + [System.Collections.Hashtable] $Parameters + ) + process { + + $getTargetResourceCommand = 'Get-{0}TargetResource' -f $ResourceName; + Write-Debug ($localized.InvokingCommand -f $getTargetResourceCommand); + # Code to factor in the parameters which can be passed to the Get-TargetResource function. + $CommandInfo = Get-Command -Name $getTargetResourceCommand; + $RemoveParameters = $Parameters.Keys | + Where-Object -FilterScript { $($CommandInfo.Parameters.Keys) -notcontains $PSItem }; + $RemoveParameters | + ForEach-Object -Process { [ref] $null = $Parameters.Remove($PSItem) }; + + try { + $getDscResourceResult = & $getTargetResourceCommand @Parameters; + } + catch { + WriteWarning -Message ($localized.DscResourceFailedError -f $getTargetResourceCommand, $_); + } + + return $getDscResourceResult; + + } #end process + +} + diff --git a/Private/GetDscResourceModule.ps1 b/Private/GetDscResourceModule.ps1 new file mode 100644 index 00000000..54f9ac32 --- /dev/null +++ b/Private/GetDscResourceModule.ps1 @@ -0,0 +1,74 @@ +function GetDscResourceModule { + +<# + .SYNOPSIS + Enumerates a directory path and returns list of all valid DSC resources. + .DESCRIPTION + The GetDscResourceModule returns all the PowerShell DSC resource modules in the specified path. This is used to + determine which directories to copy to a VM's VHD(X) file. Only the latest version of module that is installed + is returned, removing any versioned folders that are introduced in WMF 5.0, but cannot be interpreted by + down-level WMF versions. + .NOTES + THIS METHOD IS DEPRECATED IN FAVOUR OF THE NEW MODULE CACHE FUNCTIONALITY + More context can be found here https://github.com/VirtualEngine/Lab/issues/25 +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingEmptyCatchBlock','')] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [System.String[]] $Path + ) + process { + + foreach ($basePath in $Path) { + + Get-ChildItem -Path $basePath -Directory | ForEach-Object { + + $moduleInfo = $PSItem; + ## Check to see if we have a MOF or class resource in the module + if (TestDscResourceModule -Path $moduleInfo.FullName -ModuleName $moduleInfo.Name) { + Write-Debug -Message ('Discovered DSC resource ''{0}''.' -f $moduleInfo.FullName); + $testModuleManifestPath = '{0}\{1}.psd1' -f $moduleInfo.FullName, $moduleInfo.Name; + ## Convert the .psd1 file into a hashtable (Test-ModuleManifest can actually load the module) + if (Test-Path -Path $testModuleManifestPath -PathType Leaf) { + + $module = ConvertToConfigurationData -ConfigurationData $testModuleManifestPath; + Write-Output -InputObject ([PSCustomObject] @{ + ModuleName = $moduleInfo.Name; + ModuleVersion = $module.ModuleVersion -as [System.Version]; + Path = $moduleInfo.FullName; + }); + } + } + else { + ## Enumerate each module\. subdirectory + Get-ChildItem -Path $moduleInfo.FullName -Directory | Where-Object Name -match '^\d+\.\d+' | ForEach-Object { + Write-Debug -Message ('Checking module versioned directory ''{0}''.' -f $PSItem.FullName); + ## Test to see if it's a DSC resource module + if (TestDscResourceModule -Path $PSItem.FullName -ModuleName $moduleInfo.Name) { + try { + Write-Debug -Message ('Discovered DSC resource ''{0}''.' -f $PSItem.FullName); + $testModuleManifestPath = '{0}\{1}.psd1' -f $PSItem.FullName, $moduleInfo.Name; + ## Convert the .psd1 file into a hashtable (Test-ModuleManifest can actually load the module) + $module = ConvertToConfigurationData -ConfigurationData $testModuleManifestPath; + Write-Output -InputObject ([PSCustomObject] @{ + ModuleName = $moduleInfo.Name; + ModuleVersion = [System.Version] $module.ModuleVersion; + Path = $PSItem.FullName; + }); + } + catch { } + } + } | #end foreach module\. sub directory + Sort-Object -Property ModuleVersion -Descending | Select-Object -First 1; + } + + } #end foreach module directory + + } #end foreach path + + } #end process + +} + diff --git a/Private/GetFormattedMessage.ps1 b/Private/GetFormattedMessage.ps1 new file mode 100644 index 00000000..d73f1c14 --- /dev/null +++ b/Private/GetFormattedMessage.ps1 @@ -0,0 +1,29 @@ +function GetFormattedMessage { + +<# + .SYNOPSIS + Generates a formatted output message. +#> + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Message + ) + process { + + if (($labDefaults.CallStackLogging) -and ($labDefaults.CallStackLogging -eq $true)) { + $parentCallStack = (Get-PSCallStack)[1]; # store the parent Call Stack + $functionName = $parentCallStack.FunctionName; + $lineNumber = $parentCallStack.ScriptLineNumber; + $scriptName = ($parentCallStack.Location -split ':')[0]; + $formattedMessage = '[{0}] [Script:{1}] [Function:{2}] [Line:{3}] {4}' -f (Get-Date).ToLongTimeString(), $scriptName, $functionName, $lineNumber, $Message; + } + else { + $formattedMessage = '[{0}] {1}' -f (Get-Date).ToLongTimeString(), $Message; + } + return $formattedMessage; + + } #end process + +} + diff --git a/Private/GetLabHostDSCConfigurationPath.ps1 b/Private/GetLabHostDSCConfigurationPath.ps1 new file mode 100644 index 00000000..b94f1ff3 --- /dev/null +++ b/Private/GetLabHostDSCConfigurationPath.ps1 @@ -0,0 +1,18 @@ +function GetLabHostDSCConfigurationPath { + +<# + .SYNOPSIS + Shortcut function to resolve the host's default ConfigurationPath property +#> + [CmdletBinding()] + [OutputType([System.String])] + param ( ) + process { + + $labHostDefaults = GetConfigurationData -Configuration Host; + return $labHostDefaults.ConfigurationPath; + + } #end process + +} + diff --git a/Private/GetLabHostSetupConfiguration.ps1 b/Private/GetLabHostSetupConfiguration.ps1 new file mode 100644 index 00000000..c3863f80 --- /dev/null +++ b/Private/GetLabHostSetupConfiguration.ps1 @@ -0,0 +1,79 @@ +function GetLabHostSetupConfiguration { + +<# + .SYNOPSIS + Returns an array of hashtables defining the desired host configuration. + .DESCRIPTION + The GetLabHostSetupConfiguration function returns an array of hashtables used to determine whether the + host is in the desired configuration. + .NOTES + The configuration is passed to avoid repeated calls to Get-LabHostDefault and polluting verbose output. +#> + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( ) + process { + [System.Boolean] $isDesktop = (Get-CimInstance -ClassName Win32_OperatingSystem -Verbose:$false).ProductType -eq 1; + ## Due to the differences in client/server deployment for Hyper-V, determine the correct method before creating the host configuration array. + $labHostSetupConfiguration = @(); + + if ($isDesktop) { + Write-Debug -Message 'Implementing desktop configuration.'; + $labHostSetupConfiguration += @{ + UseDefault = $true; + Description = 'Hyper-V role'; + ModuleName = 'PSDesiredStateConfiguration'; + ResourceName = 'MSFT_WindowsOptionalFeature'; + Prefix = 'WindowsOptionalFeature'; + Parameters = @{ + Ensure = 'Enable'; + Name = 'Microsoft-Hyper-V-All'; + } + }; + } + else { + Write-Debug -Message 'Implementing server configuration.'; + $labHostSetupConfiguration += @{ + UseDefault = $true; + Description = 'Hyper-V Role'; + ModuleName = 'PSDesiredStateConfiguration'; + ResourceName = 'MSFT_RoleResource'; + Prefix = 'WindowsFeature'; + Parameters = @{ + Ensure = 'Present'; + Name = 'Hyper-V'; + IncludeAllSubFeature = $true; + } + }; + $labHostSetupConfiguration += @{ + UseDefault = $true; + Description = 'Hyper-V Tools'; + ModuleName = 'PSDesiredStateConfiguration'; + ResourceName = 'MSFT_RoleResource'; + Prefix = 'WindowsFeature'; + Parameters = @{ + Ensure = 'Present'; + Name = 'RSAT-Hyper-V-Tools'; + IncludeAllSubFeature = $true; + } + }; + } #end Server configuration + + $labHostSetupConfiguration += @{ + ## Check for a reboot before continuing + UseDefault = $false; + Description = 'Pending reboot'; + ModuleName = 'xPendingReboot'; + ResourceName = 'MSFT_xPendingReboot'; + Prefix = 'PendingReboot'; + Parameters = @{ + Name = 'TestingForHypervReboot'; + SkipCcmClientSDK = $true; + } + }; + + return $labHostSetupConfiguration; + } #end process + +} + diff --git a/Private/GetLabVMDisk.ps1 b/Private/GetLabVMDisk.ps1 new file mode 100644 index 00000000..db2ec0b8 --- /dev/null +++ b/Private/GetLabVMDisk.ps1 @@ -0,0 +1,44 @@ +function GetLabVMDisk { + +<# + .SYNOPSIS + Retrieves lab virtual machine disk (VHDX) is present. + .DESCRIPTION + Gets a VM disk configuration using the xVHD DSC resource. +#> + [CmdletBinding()] + param ( + ## VM/node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Name, + + ## Media Id + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Media, + + ## Lab DSC configuration data + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + $hostDefaults = GetConfigurationData -Configuration Host; + if ($PSBoundParameters.ContainsKey('ConfigurationData')) { + $image = Get-LabImage -Id $Media -ConfigurationData $ConfigurationData; + } + else { + $image = Get-LabImage -Id $Media; + } + $vhd = @{ + Name = $Name; + Path = $hostDefaults.DifferencingVhdPath; + ParentPath = $image.ImagePath; + Generation = $image.Generation; + } + ImportDscResource -ModuleName xHyper-V -ResourceName MSFT_xVHD -Prefix VHD; + GetDscResource -ResourceName VHD -Parameters $vhd; + } #end process + +} + diff --git a/Private/GetLabVMSnapshot.ps1 b/Private/GetLabVMSnapshot.ps1 new file mode 100644 index 00000000..837f5565 --- /dev/null +++ b/Private/GetLabVMSnapshot.ps1 @@ -0,0 +1,30 @@ +function GetLabVMSnapshot { + +<# + .SYNOPSIS + Gets snapshots of all virtual machines with the specified snapshot name. +#> + [CmdletBinding()] + param ( + ## VM/node name. + [Parameter(Mandatory, ValueFromPipeline)] [ValidateNotNullOrEmpty()] + [System.String[]] $Name, + + ## Snapshot name to restore. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.String] $SnapshotName + ) + process { + foreach ($vmName in $Name) { + $snapshot = Get-VMSnapshot -VMName $vmName -Name $SnapshotName -ErrorAction SilentlyContinue; + if (-not $snapshot) { + WriteWarning -Message ($localized.SnapshotMissingWarning -f $SnapshotName, $vmName); + } + else { + Write-Output -InputObject $snapshot; + } + } #end foreach VM + } #end process + +} + diff --git a/Private/GetModule.ps1 b/Private/GetModule.ps1 new file mode 100644 index 00000000..d9a4b7fe --- /dev/null +++ b/Private/GetModule.ps1 @@ -0,0 +1,33 @@ +function GetModule { + +<# + .SYNOPSIS + Tests whether an exising PowerShell module meets the minimum or required version +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Name + ) + process { + + WriteVerbose -Message ($localized.LocatingModule -f $Name); + ## Only return modules in the %ProgramFiles%\WindowsPowerShell\Modules location, ignore other $env:PSModulePaths + $programFiles = [System.Environment]::GetFolderPath('ProgramFiles'); + $modulesPath = ('{0}\WindowsPowerShell\Modules' -f $programFiles).Replace('\','\\'); + $module = Get-Module -Name $Name -ListAvailable -Verbose:$false | Where-Object Path -match $modulesPath; + + if (-not $module) { + WriteVerbose -Message ($localized.ModuleNotFound -f $Name); + } + else { + WriteVerbose -Message ($localized.ModuleFoundInPath -f $module.Path); + } + return $module; + + } #end process + +} + diff --git a/Private/GetModuleCache.ps1 b/Private/GetModuleCache.ps1 new file mode 100644 index 00000000..58137b2d --- /dev/null +++ b/Private/GetModuleCache.ps1 @@ -0,0 +1,202 @@ +function GetModuleCache { + +<# + .SYNOPSIS + Returns the requested cached PowerShell module zip [System.IO.FileInfo] object. + .NOTES + File system modules are not stored in the module cache. +#> + [CmdletBinding(DefaultParameterSetName = 'Name')] + [OutputType([System.IO.FileInfo])] + param ( + ## PowerShell module/DSC resource module name + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## The minimum version of the module required + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [ValidateNotNullOrEmpty()] + [System.Version] $MinimumVersion, + + ## The exact version of the module required + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.Version] $RequiredVersion, + + ## GitHub repository owner + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Owner, + + ## GitHub repository branch + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Branch, + + ## Source Filesystem module path + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Path, + + ## Provider used to download the module + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateSet('PSGallery','GitHub','FileSystem')] + [System.String] $Provider, + + ## Lability PowerShell module info hashtable + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Module')] + [ValidateNotNullOrEmpty()] + [System.Collections.Hashtable] $Module, + + ## Catch all to be able to pass parameter via $PSBoundParameters + [Parameter(ValueFromRemainingArguments)] $RemainingArguments + ) + begin { + + if ([System.String]::IsNullOrEmpty($Provider)) { + $Provider = 'PSGallery' + } + + if ($PSCmdlet.ParameterSetName -eq 'Module') { + + if ([System.String]::IsNullOrEmpty($Module.Name)) { + throw ($localized.RequiredModuleParameterError -f 'Name'); + } + + $Name = $Module.Name + + if (-not [System.String]::IsNullOrEmpty($Module.Provider)) { + $Provider = $Module.Provider; + } + if (-not [System.String]::IsNullOrEmpty($Module.MinimumVersion)) { + $MinimumVersion = $Module.MinimumVersion; + } + if (-not [System.String]::IsNullOrEmpty($Module.RequiredVersion)) { + $RequiredVersion = $Module.RequiredVersion; + } + if (-not [System.String]::IsNullOrEmpty($Module.Owner)) { + $Owner = $Module.Owner; + } + if (-not [System.String]::IsNullOrEmpty($Module.Branch)) { + $Branch = $Module.Branch; + } + if (-not [System.String]::IsNullOrEmpty($Module.Path)) { + $Path = $Module.Path; + } + + } #end if Module + + if ($Provider -eq 'GitHub') { + + if ([System.String]::IsNullOrEmpty($Owner)) { + throw ($localized.RequiredModuleParameterError -f 'Owner'); + } + + ## Default to master branch if none specified + if ([System.String]::IsNullOrEmpty($Branch)) { + $Branch = 'master'; + } + + } #end if GitHub + elseif ($Provider -eq 'FileSystem') { + + if ([System.String]::IsNullOrEmpty($Path)) { + throw ($localized.RequiredModuleParameterError -f 'Path'); + } + elseif (-not (Test-Path -Path $Path)) { + throw ($localized.InvalidPathError -f 'Module', $Path); + } + else { + + ## If we have a file, ensure it's a .Zip file + $fileSystemInfo = Get-Item -Path $Path; + if ($fileSystemInfo -is [System.IO.FileInfo]) { + if ($fileSystemInfo.Extension -ne '.zip') { + throw ($localized.InvalidModulePathExtensionError -f $Path); + } + } + } + + } #end if FileSystem + + } + process { + + $moduleCachePath = (GetConfigurationData -Configuration Host).ModuleCachePath; + + ## If no provider specified, default to the PSGallery + if (([System.String]::IsNullOrEmpty($Provider)) -or ($Provider -eq 'PSGallery')) { + + ## PowerShell Gallery modules are just suffixed with -v.zip + $moduleRegex = '^{0}-v.+\.zip$' -f $Name; + } + elseif ($Provider -eq 'GitHub') { + + ## GitHub modules are suffixed with -v__.zip + $moduleRegex = '^{0}(-v.+)?_{1}_{2}\.zip$' -f $Name, $Owner, $Branch; + } + Write-Debug -Message ("Searching for files matching pattern '$moduleRegex'."); + if ($Provider -in 'FileSystem') { + + ## We have a directory or a .zip file, so just return this + return (Get-Item -Path $Path); + } + elseif ($Provider -in 'PSGallery','GitHub') { + $modules = Get-ChildItem -Path $moduleCachePath -ErrorAction SilentlyContinue | + Where-Object Name -match $moduleRegex | + ForEach-Object { + + Write-Debug -Message ("Discovered file '$($_.FullName)'."); + $trimStart = '{0}-v' -f $Name; + $moduleVersionString = $PSItem.Name.TrimStart($trimStart); + $moduleVersionString = $moduleVersionString -replace '(_\S+_\S+)?\.zip', ''; + + ## If we have no version number, default to the lowest version + if ([System.String]::IsNullOrEmpty($moduleVersionString)) { + $moduleVersionString = '0.0'; + } + + $discoveredModule = [PSCustomObject] @{ + Name = $Name; + Version = $moduleVersionString -as [System.Version]; + FileInfo = $PSItem; + } + Write-Output -InputObject $discoveredModule; + } + } + + if ($null -ne $RequiredVersion) { + Write-Debug -Message ("Checking for modules that match version '$RequiredVersion'."); + Write-Output -InputObject ( + $modules | Where-Object { $_.Version -eq $RequiredVersion } | + Select-Object -ExpandProperty FileInfo); + } + elseif ($null -ne $MinimumVersion) { + Write-Debug -Message ("Checking for modules with a minimum version of '$MinimumVersion'."); + Write-Output -InputObject ( + $modules | Where-Object Version -ge $MinimumVersion | + Sort-Object -Property Version | + Select-Object -Last 1 -ExpandProperty FileInfo); + } + else { + Write-Debug -Message ("Checking for the latest module version."); + Write-Output -InputObject ( + $modules | Sort-Object -Property Version | + Select-Object -Last 1 -ExpandProperty FileInfo); + } + + } #end process + +} + diff --git a/Private/GetModuleCacheManifest.ps1 b/Private/GetModuleCacheManifest.ps1 new file mode 100644 index 00000000..05c5e5d1 --- /dev/null +++ b/Private/GetModuleCacheManifest.ps1 @@ -0,0 +1,78 @@ +function GetModuleCacheManifest { + +<# + .SYNOPSIS + Returns a zipped module's manifest. +#> + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( + ## File path to the zipped module + [Parameter(Mandatory)] + [System.String] $Path, + + [ValidateSet('PSGallery','GitHub')] + [System.String] $Provider = 'PSGallery' + ) + begin { + + if (-not (Test-Path -Path $Path -PathType Leaf)) { + throw ($localized.InvalidPathError -f 'Module', $Path); + } + + } + process { + + Write-Debug -Message 'Loading ''System.IO.Compression'' .NET binaries.'; + [ref] $null = [System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression"); + [ref] $null = [System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem"); + + $moduleFileInfo = Get-Item -Path $Path; + + if ($Provider -eq 'PSGallery') { + $moduleName = $moduleFileInfo.Name -replace '\.zip', ''; + } + elseif ($Provider -eq 'GitHub') { + ## If we have a GitHub module, trim the _Owner_Branch.zip; if we have a PSGallery module, trim the .zip + $moduleName = $moduleFileInfo.Name -replace '_\S+_\S+\.zip', ''; + } + + $moduleManifestName = '{0}.psd1' -f $moduleName; + $temporaryArchivePath = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath "$moduleName.psd1"; + + try { + + ### Open the ZipArchive with read access + WriteVerbose -Message ($localized.OpeningArchive -f $moduleFileInfo.FullName); + $archive = New-Object System.IO.Compression.ZipArchive(New-Object System.IO.FileStream($moduleFileInfo.FullName, [System.IO.FileMode]::Open)); + + ## Zip archive entries are case-sensitive, therefore, we need to search for a match and can't use ::GetEntry() + foreach ($archiveEntry in $archive.Entries) { + if ($archiveEntry.Name -eq $moduleManifestName) { + $moduleManifestArchiveEntry = $archiveEntry; + } + } + + [System.IO.Compression.ZipFileExtensions]::ExtractToFile($moduleManifestArchiveEntry, $temporaryArchivePath, $true); + $moduleManifest = ConvertToConfigurationData -ConfigurationData $temporaryArchivePath; + } + + catch { + + Write-Error ($localized.ReadingArchiveItemError -f $moduleManifestName); + } + finally { + + if ($null -ne $archive) { + WriteVerbose -Message ($localized.ClosingArchive -f $moduleFileInfo.FullName); + $archive.Dispose(); + } + Remove-Item -Path $temporaryArchivePath -Force; + } + + return $moduleManifest; + + } #end process + +} + diff --git a/Private/GetResourceDownload.ps1 b/Private/GetResourceDownload.ps1 new file mode 100644 index 00000000..b2667c84 --- /dev/null +++ b/Private/GetResourceDownload.ps1 @@ -0,0 +1,55 @@ +function GetResourceDownload { + +<# + .SYNOPSIS + Retrieves a downloaded resource's checksum. + .NOTES + Based upon https://github.com/iainbrighton/cRemoteFile/blob/master/DSCResources/VE_RemoteFile/VE_RemoteFile.ps1 +#> + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Uri, + + [Parameter(ValueFromPipelineByPropertyName)] + [AllowNull()] + [System.String] $Checksum, + + [Parameter(ValueFromPipelineByPropertyName)] + [System.UInt32] $BufferSize = 64KB + ##TODO: Support Headers and UserAgent + ) + process { + + $checksumPath = '{0}.checksum' -f $DestinationPath; + if (-not (Test-Path -Path $DestinationPath)) { + WriteVerbose ($localized.MissingResourceFile -f $DestinationPath); + } + elseif (-not (Test-Path -Path $checksumPath)) { + [ref] $null = SetResourceChecksum -Path $DestinationPath; + } + if (Test-Path -Path $checksumPath) { + Write-Debug -Message ('MD5 checksum file ''{0}'' found.' -f $checksumPath); + $md5Checksum = (Get-Content -Path $checksumPath -Raw).Trim(); + Write-Debug -Message ('Discovered MD5 checksum ''{0}''.' -f $md5Checksum); + } + else { + Write-Debug -Message ('MD5 checksum file ''{0}'' not found.' -f $checksumPath); + } + $resource = @{ + DestinationPath = $DestinationPath; + Uri = $Uri; + Checksum = $md5Checksum; + } + return $resource; + + } #end process + +} + diff --git a/Private/GetVirtualMachineProperties.ps1 b/Private/GetVirtualMachineProperties.ps1 new file mode 100644 index 00000000..b9ed1e0a --- /dev/null +++ b/Private/GetVirtualMachineProperties.ps1 @@ -0,0 +1,102 @@ +function GetVirtualMachineProperties { + +<# + .SYNOPSIS + Gets the DSC xVMHyperV properties. +#> + param ( + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] + [System.String] $Name, + + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] + [System.String[]] $SwitchName, + + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] + [System.String] $Media, + + [Parameter(Mandatory)] + [System.UInt64] $StartupMemory, + + [Parameter(Mandatory)] + [System.UInt64] $MinimumMemory, + + [Parameter(Mandatory)] + [System.UInt64] $MaximumMemory, + + [Parameter(Mandatory)] + [System.Int32] $ProcessorCount, + + [Parameter()] [AllowNull()] + [System.String[]] $MACAddress, + + [Parameter()] + [System.Boolean] $SecureBoot, + + [Parameter()] + [System.Boolean] $GuestIntegrationServices, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + ## Resolve the media to determine whether we require a Generation 1 or 2 VM.. + if ($PSBoundParameters.ContainsKey('ConfigurationData')) { + $labMedia = ResolveLabMedia -Id $Media -ConfigurationData $ConfigurationData; + $labImage = Get-LabImage -Id $Media -ConfigurationData $ConfigurationData; + } + else { + $labMedia = ResolveLabMedia -Id $Media; + $labImage = Get-LabImage -Id $Media; + } + if (-not $labImage) { + ## Should only trigger during a Reset-VM where parent image is not available?! + ## It will be downloaded during any NewLabVM calls.. + $labImage = @{ Generation = 'VHDX'; } + } + $labMediaArchitecture = $labMedia.Architecture; + + if (-not [System.String]::IsNullOrEmpty($labMedia.CustomData.PartitionStyle)) { + ## The partition style has been overridden so use this + if ($labMedia.CustomData.PartitionStyle -eq 'MBR') { + $labMediaArchitecture = 'x86'; + } + elseif ($labMedia.CustomData.PartitionStyle -eq 'GPT') { + $labMediaArchitecture = 'x64'; + } + } + + if ($labImage.Generation -eq 'VHD') { + ## VHD files are only supported in G1 VMs + $PSBoundParameters.Add('Generation', 1); + } + elseif ($labMediaArchitecture -eq 'x86') { + $PSBoundParameters.Add('Generation', 1); + } + elseif ($labMediaArchitecture -eq 'x64') { + $PSBoundParameters.Add('Generation', 2); + } + + if ($null -eq $MACAddress) { + [ref] $null = $PSBoundParameters.Remove('MACAddress'); + } + + if ($PSBoundParameters.ContainsKey('GuestIntegrationServices')) { + [ref] $null = $PSBoundParameters.Add('EnableGuestService', $GuestIntegrationServices); + [ref] $null = $PSBoundParameters.Remove('GuestIntegrationServices'); + } + + $vhdPath = ResolveLabVMDiskPath -Name $Name -Generation $labImage.Generation; + + [ref] $null = $PSBoundParameters.Remove('Media'); + [ref] $null = $PSBoundParameters.Remove('ConfigurationData'); + [ref] $null = $PSBoundParameters.Add('VhdPath', $vhdPath); + [ref] $null = $PSBoundParameters.Add('RestartIfNeeded', $true); + + return $PSBoundParameters; + } #end process + +} + diff --git a/Private/GetWindowsImageIndex.ps1 b/Private/GetWindowsImageIndex.ps1 new file mode 100644 index 00000000..52429e86 --- /dev/null +++ b/Private/GetWindowsImageIndex.ps1 @@ -0,0 +1,30 @@ +function GetWindowsImageIndex { + +<# + .SYNOPSIS + Locates the specified WIM image index by its name, i.e. SERVERSTANDARD or SERVERDATACENTERSTANDARD + .OUTPUTS + The WIM image index. +#> + [CmdletBinding()] + [OutputType([System.Int32])] + param ( + # WIM image path + [Parameter(Mandatory, ValueFromPipeline)] [ValidateNotNullOrEmpty()] + [System.String] $ImagePath, + + # Windows image name + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.String] $ImageName + ) + process { + + WriteVerbose ($localized.LocatingWimImageIndex -f $ImageName); + Get-WindowsImage -ImagePath $ImagePath -Verbose:$false | + Where-Object ImageName -eq $ImageName | + Select-Object -ExpandProperty ImageIndex; + + } #end process + +} + diff --git a/Private/GetWindowsImageName.ps1 b/Private/GetWindowsImageName.ps1 new file mode 100644 index 00000000..310060de --- /dev/null +++ b/Private/GetWindowsImageName.ps1 @@ -0,0 +1,30 @@ +function GetWindowsImageName { + +<# + .SYNOPSIS + Locates the specified WIM image name by its index. +#> + [CmdletBinding()] + [OutputType([System.String])] + param ( + # WIM image path + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $ImagePath, + + # Windows image index + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.Int32] $ImageIndex + ) + process { + + WriteVerbose ($localized.LocatingWimImageName -f $ImageIndex); + Get-WindowsImage -ImagePath $ImagePath -Verbose:$false | + Where-Object ImageIndex -eq $ImageIndex | + Select-Object -ExpandProperty ImageName; + + } #end process + +} + diff --git a/Private/ImportDismModule.ps1 b/Private/ImportDismModule.ps1 new file mode 100644 index 00000000..fbac1b7c --- /dev/null +++ b/Private/ImportDismModule.ps1 @@ -0,0 +1,19 @@ +function ImportDismModule { + +<# + .SYNOPSIS + Imports the required DISM dll. +#> + [CmdletBinding()] + param ( ) + process { + + $dismPath = (Get-LabHostDefault).DismPath; + Remove-Module -Name 'Microsoft.Dism.PowerShell' -ErrorAction SilentlyContinue; + $dismModule = Import-Module -Name $dismPath -Force -Scope Global -PassThru -Verbose:$false; + WriteVerbose -Message ("Loaded Dism module version '{0}'." -f $dismModule.Version); + + } #end process + +} + diff --git a/Private/ImportDscResource.ps1 b/Private/ImportDscResource.ps1 new file mode 100644 index 00000000..9f532d61 --- /dev/null +++ b/Private/ImportDscResource.ps1 @@ -0,0 +1,61 @@ +function ImportDscResource { + +<# + .SYNOPSIS + Imports a DSC module resource. + .DESCRIPTION + Imports a DSC resource as Test-TargetResource and Set-TargetResource etc. +#> + [CmdletBinding()] + param ( + ## DSC resource's module name containing the resource + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $ModuleName, + + ## DSC resource's name to import + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $ResourceName, + + ## Local prefix, defaults to the resource name + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Prefix = $ResourceName, + + ## Use the built-in/default DSC resource + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $UseDefault + ) + process { + + ## Check whether the resource is already imported/registered + Write-Debug ($localized.CheckingDscResource -f $ModuleName, $ResourceName); + $testCommandName = 'Test-{0}TargetResource' -f $Prefix; + + if (-not (Get-Command -Name $testCommandName -ErrorAction SilentlyContinue)) { + + if ($UseDefault) { + WriteVerbose ($localized.ImportingDscResource -f $ModuleName, $ResourceName); + $resourcePath = GetDscModule -ModuleName $ModuleName -ResourceName $ResourceName -ErrorAction Stop; + } + else { + WriteVerbose ($localized.ImportingBundledDscResource -f $ModuleName, $ResourceName); + $dscModuleRootPath = '{0}\{1}\{2}\DSCResources' -f $labDefaults.ModuleRoot, $labDefaults.DscResourceDirectory, $ModuleName; + $dscResourcePath = '{0}\{0}.psm1' -f $ResourceName; + $resourcePath = Join-Path -Path $dscModuleRootPath -ChildPath $dscResourcePath; + } + + if ($resourcePath) { + ## Import the DSC module into the module's global scope to improve performance + Import-Module -Name $resourcePath -Prefix $Prefix -Force -Verbose:$false -Scope Global; + } + + } + else { + + Write-Debug -Message ($localized.DscResourceAlreadyImported -f $ModuleName, $ResourceName); + } + + } #end process + +} + diff --git a/Private/InvokeDscResource.ps1 b/Private/InvokeDscResource.ps1 new file mode 100644 index 00000000..7b535175 --- /dev/null +++ b/Private/InvokeDscResource.ps1 @@ -0,0 +1,35 @@ +function InvokeDscResource { + +<# + .SYNOPSIS + Runs the ResourceName DSC resource ensuring it's in the desired state. + .DESCRIPTION + The InvokeDscResource cmdlet invokes the target $ResourceName\Test-TargetResource function using the supplied + $Parameters hastable. If the resource is not in the desired state, the $ResourceName\Set-TargetResource + function is called with the $Parameters hashtable to attempt to correct the resource. +#> + [CmdletBinding()] + param ( + [Parameter(Mandatory)] + [System.String] $ResourceName, + + [Parameter(Mandatory)] + [System.Collections.Hashtable] $Parameters + ) + process { + + if (-not (TestDscResource @PSBoundParameters)) { + if ($ResourceName -match 'PendingReboot') { + throw $localized.PendingRebootWarning; + } + return (SetDscResource @PSBoundParameters); + } + else { + $setTargetResourceCommand = 'Set-{0}TargetResource' -f $ResourceName; + WriteVerbose ($localized.SkippingCommand -f $setTargetResourceCommand); + } + + } #end process + +} + diff --git a/Private/InvokeExecutable.ps1 b/Private/InvokeExecutable.ps1 new file mode 100644 index 00000000..fb04738e --- /dev/null +++ b/Private/InvokeExecutable.ps1 @@ -0,0 +1,51 @@ +function InvokeExecutable { + +<# + .SYNOPSIS + Runs an executable and redirects StdOut and StdErr. +#> + [CmdletBinding()] + [OutputType([System.Int32])] + param ( + # Executable path + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [System.String] $Path, + + # Executable arguments + [Parameter(Mandatory)] + [ValidateNotNull()] + [System.Array] $Arguments, + + # Redirected StdOut and StdErr log name + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] $LogName = ('{0}.log' -f $Path) + ) + process { + + $processArgs = @{ + FilePath = $Path; + ArgumentList = $Arguments; + Wait = $true; + RedirectStandardOutput = '{0}\{1}-StdOut.log' -f $env:temp, $LogName; + RedirectStandardError = '{0}\{1}-StdErr.log' -f $env:temp, $LogName; + NoNewWindow = $true; + PassThru = $true; + } + Write-Debug -Message ($localized.RedirectingOutput -f 'StdOut', $processArgs.RedirectStandardOutput); + Write-Debug -Message ($localized.RedirectingOutput -f 'StdErr', $processArgs.RedirectStandardError); + WriteVerbose ($localized.StartingProcess -f $Path, [System.String]::Join(' ', $Arguments)); + $process = Start-Process @processArgs; + if ($process.ExitCode -ne 0) { + WriteWarning ($localized.ProcessExitCode -f $Path, $process.ExitCode) + } + else { + WriteVerbose ($localized.ProcessExitCode -f $Path, $process.ExitCode); + } + ##TODO: Should this actually return the exit code?! + + } #end process + +} + diff --git a/Private/InvokeLabMediaHotfixDownload.ps1 b/Private/InvokeLabMediaHotfixDownload.ps1 new file mode 100644 index 00000000..b301d73b --- /dev/null +++ b/Private/InvokeLabMediaHotfixDownload.ps1 @@ -0,0 +1,50 @@ +function InvokeLabMediaHotfixDownload { + +<# + .SYNOPSIS + Downloads resources. + .DESCRIPTION + Initiates a download of a media resource. If the resource has already been downloaded and the checksum + is correct, it won't be re-downloaded. To force download of a ISO/VHDX use the -Force switch. + .NOTES + ISO/WIM media is downloaded to the default IsoPath location. VHD(X) files are downloaded directly into the + ParentVhdPath location. +#> + [CmdletBinding()] + [OutputType([System.IO.FileInfo])] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $Id, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Uri, + + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Checksum, + + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force + ) + process { + + $hostDefaults = GetConfigurationData -Configuration Host; + $destinationPath = Join-Path -Path $hostDefaults.HotfixPath -ChildPath $Id; + $invokeResourceDownloadParams = @{ + DestinationPath = $destinationPath; + Uri = $Uri; + } + if ($Checksum) { + + [ref] $null = $invokeResourceDownloadParams.Add('Checksum', $Checksum); + } + + [ref] $null = InvokeResourceDownload @invokeResourceDownloadParams -Force:$Force; + return (Get-Item -Path $destinationPath); + + } #end process + +} + diff --git a/Private/InvokeLabMediaImageDownload.ps1 b/Private/InvokeLabMediaImageDownload.ps1 new file mode 100644 index 00000000..755b765e --- /dev/null +++ b/Private/InvokeLabMediaImageDownload.ps1 @@ -0,0 +1,68 @@ +function InvokeLabMediaImageDownload { + +<# + .SYNOPSIS + Downloads ISO/WIM/VHDX media resources. + .DESCRIPTION + Initiates a download of a media resource. If the resource has already been downloaded and the checksum is + correct, it won't be re-downloaded. To force download of a ISO/VHDX use the -Force switch. + .NOTES + ISO media is downloaded to the default IsoPath location. VHD(X) files are downloaded directly into the + ParentVhdPath location. +#> + [CmdletBinding()] + [OutputType([System.IO.FileInfo])] + param ( + ## Lab media object + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNull()] + [System.Object] $Media, + + ## Force (re)download of the resource + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force + ) + process { + $hostDefaults = GetConfigurationData -Configuration Host; + + $invokeResourceDownloadParams = @{ + DestinationPath = Join-Path -Path $hostDefaults.IsoPath -ChildPath $media.Filename; + Uri = $media.Uri; + Checksum = $media.Checksum; + } + if ($media.MediaType -eq 'VHD') { + + $invokeResourceDownloadParams['DestinationPath'] = Join-Path -Path $hostDefaults.ParentVhdPath -ChildPath $media.Filename; + } + + $mediaUri = New-Object -TypeName System.Uri -ArgumentList $Media.Uri; + if ($mediaUri.Scheme -eq 'File') { + + ## Use a bigger buffer for local file copies.. + $invokeResourceDownloadParams['BufferSize'] = 1MB; + } + + if ($media.MediaType -eq 'VHD') { + + ## Always download VHDXs regardless of Uri type + [ref] $null = InvokeResourceDownload @invokeResourceDownloadParams -Force:$Force; + } + elseif (($mediaUri.Scheme -eq 'File') -and ($media.MediaType -eq 'WIM') -and $hostDefaults.DisableLocalFileCaching) + ## TODO: elseif (($mediaUri.Scheme -eq 'File') -and $hostDefaults.DisableLocalFileCaching) + { + ## NOTE: Only WIM media can currently be run from a file share (see https://github.com/VirtualEngine/Lab/issues/28) + ## Caching is disabled and we have a file resource, so just return the source URI path + WriteVerbose ($localized.MediaFileCachingDisabled -f $Media.Id); + $invokeResourceDownloadParams['DestinationPath'] = $mediaUri.LocalPath; + } + else { + + ## Caching is enabled or it's a http/https source + [ref] $null = InvokeResourceDownload @invokeResourceDownloadParams -Force:$Force; + } + return (Get-Item -Path $invokeResourceDownloadParams.DestinationPath); + + } #end process + +} + diff --git a/Private/InvokeModuleCacheDownload.ps1 b/Private/InvokeModuleCacheDownload.ps1 new file mode 100644 index 00000000..ba3bbd52 --- /dev/null +++ b/Private/InvokeModuleCacheDownload.ps1 @@ -0,0 +1,153 @@ +function InvokeModuleCacheDownload { + +<# + .SYNOPSIS + Downloads a PowerShell module (DSC resource) into the module cache. +#> + [CmdletBinding(DefaultParameterSetName = 'Name')] + [OutputType([System.IO.FileInfo])] + param ( + ## PowerShell module/DSC resource module name + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## The minimum version of the module required + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [ValidateNotNullOrEmpty()] + [System.Version] $MinimumVersion, + + ## The exact version of the module required + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.Version] $RequiredVersion, + + ## GitHub repository owner + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Owner, + + ## The GitHub repository name, normally the DSC module's name + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Repository = $Name, + + ## GitHub repository branch + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Branch, + + ## Source Filesystem module path + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Path, + + ## Provider used to download the module + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateSet('PSGallery','GitHub','FileSystem')] + [System.String] $Provider, + + ## Lability PowerShell module info hashtable + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Module')] + [ValidateNotNullOrEmpty()] + [System.Collections.Hashtable[]] $Module, + + ## Destination directory path to download the PowerShell module/DSC resource module to + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath = (GetConfigurationData -Configuration Host).ModuleCachePath, + + ## Force a download of the module(s) even if they already exist in the cache. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force, + + ## Catch all to be able to pass parameter via $PSBoundParameters + [Parameter(ValueFromRemainingArguments)] + $RemainingArguments + ) + begin { + + ## Remove -RemainingArguments to stop it being passed on. + [ref] $null = $PSBoundParameters.Remove('RemainingArguments'); + if ($PSCmdlet.ParameterSetName -ne 'Module') { + + ## Create a module hashtable + $newModule = @{ + Name = $Name; + Repository = $Repository; + } + if ($PSBoundParameters.ContainsKey('MinimumVersion')) { + $newModule['MinimumVersion'] = $MinimumVersion; + } + if ($PSBoundParameters.ContainsKey('RequiredVersion')) { + $newModule['RequiredVersion'] = $RequiredVersion; + } + if ($PSBoundParameters.ContainsKey('Owner')) { + $newModule['Owner'] = $Owner; + } + if ($PSBoundParameters.ContainsKey('Branch')) { + $newModule['Branch'] = $Branch; + } + if ($PSBoundParameters.ContainsKey('Path')) { + $newModule['Path'] = $Path; + } + if ($PSBoundParameters.ContainsKey('Provider')) { + $newModule['Provider'] = $Provider; + } + + $Module = $newModule; + } + + } + process { + + foreach ($moduleInfo in $Module) { + + if ((-not (TestModuleCache @moduleInfo)) -or ($Force)) { + + if ((-not $moduleInfo.ContainsKey('Provider')) -or ($moduleInfo['Provider'] -eq 'PSGallery')) { + + if ($moduleInfo.ContainsKey('RequiredVersion')) { + WriteVerbose -Message ($localized.ModuleVersionNotCached -f $moduleInfo.Name, $moduleInfo.RequiredVersion); + } + elseif ($moduleInfo.ContainsKey('MinimumVersion')) { + WriteVerbose -Message ($localized.ModuleMinmumVersionNotCached -f $moduleInfo.Name, $moduleInfo.MinimumVersion); + } + else { + WriteVerbose -Message ($localized.ModuleNotCached -f $moduleInfo.Name); + } + + InvokeModuleDownloadFromPSGallery @moduleInfo; + } + elseif ($moduleInfo['Provider'] -eq 'GitHub') { + + WriteVerbose -Message ($localized.ModuleNotCached -f $moduleInfo.Name); + InvokeModuleDownloadFromGitHub @moduleInfo; + } + elseif ($moduleInfo['Provider'] -eq 'FileSystem') { + ## We should never get here as filesystem modules are not cached. + ## If the test doesn't throw, it should return $true. + } + } + else { + GetModuleCache @moduleInfo; + } + + } #end foreach module + + } #end process + +} + diff --git a/Private/InvokeModuleDownloadFromGitHub.ps1 b/Private/InvokeModuleDownloadFromGitHub.ps1 new file mode 100644 index 00000000..54a3b9a8 --- /dev/null +++ b/Private/InvokeModuleDownloadFromGitHub.ps1 @@ -0,0 +1,84 @@ +function InvokeModuleDownloadFromGitHub { + + <# + .SYNOPSIS + Downloads a DSC resource if it has not already been downloaded from Github. + .NOTES + Uses the GitHubRepository module! +#> + [CmdletBinding()] + [OutputType([System.IO.DirectoryInfo])] + param ( + ## PowerShell DSC resource module name + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## Destination directory path to download the PowerShell module/DSC resource module to + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath = (GetConfigurationData -Configuration Host).ModuleCachePath, + + + ## The GitHub repository owner, typically 'PowerShell' + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Owner, + + ## The GitHub repository name, normally the DSC module's name + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Repository = $Name, + + ## The GitHub branch to download, defaults to the 'master' branch + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Branch = 'master', + + ## Override the local directory name. Only used if the repository name does not + ## match the DSC module name + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $OverrideRepositoryName = $Name, + + ## Force a download, overwriting any existing resources + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force, + + ## Catch all, for splatting parameters + [Parameter(ValueFromRemainingArguments)] + $RemainingArguments + ) + begin { + + if (-not $PSBoundParameters.ContainsKey('Owner')) { + throw ($localized.MissingParameterError -f 'Owner'); + } + if (-not $PSBoundParameters.ContainsKey('Branch')) { + WriteWarning -Message ($localized.NoModuleBranchSpecified -f $Name); + } + + ## Remove -RemainingArguments to stop it being passed on. + [ref] $null = $PSBoundParameters.Remove('RemainingArguments'); + ## Add Repository and Branch as they might not have been explicitly passed. + $PSBoundParameters['Repository'] = $Repository; + $PSBoundParameters['Branch'] = $Branch; + + } + process { + + ## GitHub modules are suffixed with .Owner_Branch.zip + $destinationModuleName = '{0}_{1}_{2}.zip' -f $Name, $Owner, $Branch; + $moduleCacheDestinationPath = Join-Path -Path $DestinationPath -ChildPath $destinationModuleName; + $setResourceDownloadParams = @{ + DestinationPath = $moduleCacheDestinationPath; + Uri = ResolveGitHubModuleUri @PSBoundParameters; + NoCheckSum = $true; + } + $moduleDestinationPath = SetResourceDownload @setResourceDownloadParams; + return (RenameModuleCacheVersion -Name $Name -Path $moduleDestinationPath -Owner $Owner -Branch $Branch); + + } #end process + +} + diff --git a/Private/InvokeModuleDownloadFromPSGallery.ps1 b/Private/InvokeModuleDownloadFromPSGallery.ps1 new file mode 100644 index 00000000..6b3d20c0 --- /dev/null +++ b/Private/InvokeModuleDownloadFromPSGallery.ps1 @@ -0,0 +1,49 @@ +function InvokeModuleDownloadFromPSGallery { + +<# + .SYNOPSIS + Downloads a PowerShell module/DSC resource from the PowerShell gallery to the host's module cache. +#> + [CmdletBinding(DefaultParameterSetName = 'LatestAvailable')] + [OutputType([System.IO.FileInfo])] + param ( + ## PowerShell module/DSC resource module name + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## Destination directory path to download the PowerShell module/DSC resource module to + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath = (GetConfigurationData -Configuration Host).ModuleCachePath, + + ## The minimum version of the module required + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'MinimumVersion')] + [ValidateNotNullOrEmpty()] + [System.Version] $MinimumVersion, + + ## The exact version of the module required + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'RequiredVersion')] + [ValidateNotNullOrEmpty()] + [System.Version] $RequiredVersion, + + ## Catch all, for splatting parameters + [Parameter(ValueFromRemainingArguments)] + $RemainingArguments + ) + process { + + $destinationModuleName = '{0}.zip' -f $Name; + $moduleCacheDestinationPath = Join-Path -Path $DestinationPath -ChildPath $destinationModuleName; + $setResourceDownloadParams = @{ + DestinationPath = $moduleCacheDestinationPath; + Uri = ResolvePSGalleryModuleUri @PSBoundParameters; + NoCheckSum = $true; + } + $moduleDestinationPath = SetResourceDownload @setResourceDownloadParams; + return (RenameModuleCacheVersion -Name $Name -Path $moduleDestinationPath); + + } #end process + +} + diff --git a/Private/InvokeResourceDownload.ps1 b/Private/InvokeResourceDownload.ps1 new file mode 100644 index 00000000..5fd29cdc --- /dev/null +++ b/Private/InvokeResourceDownload.ps1 @@ -0,0 +1,39 @@ +function InvokeResourceDownload { + +<# + .SYNOPSIS + Downloads a web resource if it has not already been downloaded or the checksum is incorrect. +#> + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Uri, + + [Parameter(ValueFromPipelineByPropertyName)] + [AllowNull()] + [System.String] $Checksum, + + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force, + + [Parameter(ValueFromPipelineByPropertyName)] + [System.UInt32] $BufferSize = 64KB + ##TODO: Support Headers and UserAgent + ) + process { + [ref] $null = $PSBoundParameters.Remove('Force'); + if (-not (TestResourceDownload @PSBoundParameters) -or $Force) { + SetResourceDownload @PSBoundParameters -Verbose:$false; + } + $resource = GetResourceDownload @PSBoundParameters; + return [PSCustomObject] $resource; + } #end process + +} + diff --git a/Private/InvokeWebClientDownload.ps1 b/Private/InvokeWebClientDownload.ps1 new file mode 100644 index 00000000..749f7396 --- /dev/null +++ b/Private/InvokeWebClientDownload.ps1 @@ -0,0 +1,101 @@ +function InvokeWebClientDownload { + +<# + .SYNOPSIS + Downloads a (web) resource using System.Net.WebClient. + .NOTES + This solves issue #19 when running downloading resources using BITS under alternative credentials. +#> + [CmdletBinding()] + [OutputType([System.IO.FileInfo])] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $DestinationPath, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Uri, + + [Parameter(ValueFromPipelineByPropertyName)] + [System.UInt32] $BufferSize = 64KB, + + [Parameter(ValueFromPipelineByPropertyName)] [AllowNull()] + [System.Management.Automation.PSCredential] + [System.Management.Automation.CredentialAttribute()] + $Credential + ) + process { + + try { + + [System.Net.WebClient] $webClient = New-Object -TypeName 'System.Net.WebClient'; + $webClient.Headers.Add('user-agent', $labDefaults.ModuleName); + $webClient.Proxy = [System.Net.WebRequest]::GetSystemWebProxy(); + + if (-not $webClient.Proxy.IsBypassed($Uri)) { + $proxyInfo = $webClient.Proxy.GetProxy($Uri); + WriteVerbose ($localized.UsingProxyServer -f $proxyInfo.AbsoluteUri); + } + + if ($Credential) { + $webClient.Credentials = $Credential; + $webClient.Proxy.Credentials = $Credential; + } + else { + $webClient.UseDefaultCredentials = $true; + $webClient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials; + } + + [System.IO.Stream] $inputStream = $webClient.OpenRead($Uri); + [System.UInt64] $contentLength = $webClient.ResponseHeaders['Content-Length']; + $path = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($DestinationPath); + [System.IO.Stream] $outputStream = [System.IO.File]::Create($path); + [System.Byte[]] $buffer = New-Object -TypeName System.Byte[] -ArgumentList $BufferSize; + [System.UInt64] $bytesRead = 0; + [System.UInt64] $totalBytes = 0; + $writeProgessActivity = $localized.DownloadingActivity -f $Uri; + + do { + + $bytesRead = $inputStream.Read($buffer, 0, $buffer.Length); + $totalBytes += $bytesRead; + $outputStream.Write($buffer, 0, $bytesRead); + ## Avoid divide by zero + if ($contentLength -gt 0) { + [System.Byte] $percentComplete = ($totalBytes/$contentLength) * 100; + $writeProgressParams = @{ + Activity = $writeProgessActivity; + PercentComplete = $percentComplete; + Status = $localized.DownloadStatus -f $totalBytes, $contentLength, $percentComplete; + } + Write-Progress @writeProgressParams; + } + } + while ($bytesRead -ne 0) + + $outputStream.Close(); + return (Get-Item -Path $path); + } + catch { + + throw ($localized.WebResourceDownloadFailedError -f $Uri); + } + finally { + + if ($null -ne $writeProgressActivity) { + Write-Progress -Activity $writeProgessActivity -Completed; + } + if ($null -ne $outputStream) { + $outputStream.Close(); + } + if ($null -ne $inputStream) { + $inputStream.Close(); + } + if ($null -ne $webClient) { + $webClient.Dispose(); + } + } + + } #end process + +} + diff --git a/Private/NewBootStrap.ps1 b/Private/NewBootStrap.ps1 new file mode 100644 index 00000000..5d1940f6 --- /dev/null +++ b/Private/NewBootStrap.ps1 @@ -0,0 +1,108 @@ +function NewBootStrap { + +<# + .SYNOPSIS + Creates a lab DSC BootStrap script block. +#> + [CmdletBinding()] + [OutputType([System.Management.Automation.ScriptBlock])] + param ( + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $CoreCLR + ) + process { + + $coreCLRScriptBlock = { +## Lability CoreCLR DSC Bootstrap +$VerbosePreference = 'Continue'; + +## TODO: Need to find a Nano equivalent of CertUtil.exe! + +<#CustomBootStrapInjectionPoint#> + +if (Test-Path -Path "$env:SystemDrive\BootStrap\localhost.meta.mof") { + Set-DscLocalConfigurationManager -Path "$env:SystemDrive\BootStrap\" -Verbose; +} + +if (Test-Path -Path "$env:SystemDrive\BootStrap\localhost.mof") { + Start-DscConfiguration -Path "$env:SystemDrive\Bootstrap\" -Force -Wait -Verbose -ErrorAction Stop; +} #end if localhost.mof + +} #end CoreCLR bootstrap scriptblock + + $scriptBlock = { +## Lability DSC Bootstrap +$VerbosePreference = 'Continue'; +$DebugPreference = 'Continue'; +$transcriptPath = '{0}\BootStrap\Bootstrap-{1}.log' -f $env:SystemDrive, (Get-Date).ToString('yyyyMMdd-hhmmss'); +Start-Transcript -Path $transcriptPath -Force; + +certutil.exe -addstore -f "Root" "$env:SYSTEMDRIVE\BootStrap\LabRoot.cer"; +## Import the .PFX certificate with a blank password +"" | certutil.exe -f -importpfx "$env:SYSTEMDRIVE\BootStrap\LabClient.pfx"; + +<#CustomBootStrapInjectionPoint#> + +## Account for large configurations being "pushed" and increase the default from 500KB to 1024KB (1MB) +Set-Item -Path WSMan:\localhost\MaxEnvelopeSizekb -Value 1024 -Force -Verbose; + +if (Test-Path -Path "$env:SystemDrive\BootStrap\localhost.meta.mof") { + Set-DscLocalConfigurationManager -Path "$env:SystemDrive\BootStrap\" -Verbose; +} + +$localhostMofPath = "$env:SystemDrive\BootStrap\localhost.mof"; +if (Test-Path -Path $localhostMofPath) { + + if ($PSVersionTable.PSVersion.Major -eq 4) { + + ## Convert the .mof to v4 compatible - credit to Mike Robbins + ## http://mikefrobbins.com/2014/10/30/powershell-desired-state-configuration-error-undefined-property-configurationname/ + $mof = Get-Content -Path $localhostMofPath; + $mof -replace '^\sName=.*;$|^\sConfigurationName\s=.*;$' | Set-Content -Path $localhostMofPath -Encoding Unicode -Force; + } + while ($true) { + ## Replay the configuration until the LCM bloody-well takes it (more of a WMF 4 thing)! + try { + + if (Test-Path -Path "$env:SystemRoot\System32\Configuration\Pending.mof") { + + Start-DscConfiguration -UseExisting -Force -Wait -Verbose -ErrorAction Stop; + break; + } + else { + + Start-DscConfiguration -Path "$env:SystemDrive\Bootstrap\" -Force -Wait -Verbose -ErrorAction Stop; + break; + } + } + catch { + + Write-Error -Message $_; + ## SIGH. Try restarting WMI.. + if (-not ($interation % 10)) { + + ## SIGH. Try removing the configuration and restarting WMI.. + Remove-DscConfigurationDocument -Stage Current,Pending,Previous -Force; + Restart-Service -Name Winmgmt -Force; + } + Start-Sleep -Seconds 5; + $interation++; + } + } #end while +} #end if localhost.mof + +Stop-Transcript; +} #end bootstrap scriptblock + + if ($CoreCLR) { + + return $coreCLRScriptBlock; + } + else { + + return $scriptBlock; + } + } #end process + +} + diff --git a/Private/NewDirectory.ps1 b/Private/NewDirectory.ps1 new file mode 100644 index 00000000..0593dba3 --- /dev/null +++ b/Private/NewDirectory.ps1 @@ -0,0 +1,69 @@ +function NewDirectory { + +<# + .SYNOPSIS + Creates a filesystem directory. + .DESCRIPTION + The New-Directory cmdlet will create the target directory if it doesn't already exist. If the target path + already exists, the cmdlet does nothing. +#> + [CmdletBinding(DefaultParameterSetName = 'ByString', SupportsShouldProcess)] + [OutputType([System.IO.DirectoryInfo])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + param ( + # Target filesystem directory to create + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = 'ByDirectoryInfo')] + [ValidateNotNullOrEmpty()] + [System.IO.DirectoryInfo[]] $InputObject, + + # Target filesystem directory to create + [Parameter(Mandatory, ValueFromPipelineByPropertyName, Position = 0, ParameterSetName = 'ByString')] + [ValidateNotNullOrEmpty()] + [Alias('PSPath')] + [System.String[]] $Path + ) + process { + + Write-Debug -Message ("Using parameter set '{0}'." -f $PSCmdlet.ParameterSetName); + switch ($PSCmdlet.ParameterSetName) { + + 'ByString' { + + foreach ($directory in $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path)) { + Write-Debug -Message ("Testing target directory '{0}'." -f $directory); + if (!(Test-Path -Path $directory -PathType Container)) { + if ($PSCmdlet.ShouldProcess($directory, "Create directory")) { + WriteVerbose ($localized.CreatingDirectory -f $directory); + New-Item -Path $directory -ItemType Directory; + } + } else { + Write-Debug -Message ($localized.DirectoryExists -f $directory); + Get-Item -Path $directory; + } + } #end foreach directory + + } #end byString + + 'ByDirectoryInfo' { + + foreach ($directoryInfo in $InputObject) { + Write-Debug -Message ("Testing target directory '{0}'." -f $directoryInfo.FullName); + if (!($directoryInfo.Exists)) { + if ($PSCmdlet.ShouldProcess($directoryInfo.FullName, "Create directory")) { + WriteVerbose ($localized.CreatingDirectory -f $directoryInfo.FullName); + New-Item -Path $directoryInfo.FullName -ItemType Directory; + } + } else { + Write-Debug -Message ($localized.DirectoryExists -f $directoryInfo.FullName); + $directoryInfo; + } + } #end foreach directoryInfo + + } #end byDirectoryInfo + + } #end switch + + } #end process + +} + diff --git a/Private/NewDiskImage.ps1 b/Private/NewDiskImage.ps1 new file mode 100644 index 00000000..4a3be687 --- /dev/null +++ b/Private/NewDiskImage.ps1 @@ -0,0 +1,75 @@ +function NewDiskImage { + +<# + .SYNOPSIS + Create a new formatted disk image. +#> + [CmdletBinding()] + param ( + ## VHD/x file path + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [System.String] $Path, + + ## Disk image partition scheme + [Parameter(Mandatory)] + [ValidateSet('MBR','GPT')] + [System.String] $PartitionStyle, + + ## Disk image size in bytes + [Parameter()] + [System.UInt64] $Size = 127GB, + + ## Overwrite/recreate existing disk image + [Parameter()] + [System.Management.Automation.SwitchParameter] $Force, + + ## Do not dismount the VHD/x and return a reference + [Parameter()] + [System.Management.Automation.SwitchParameter] $Passthru + ) + begin { + + if ((Test-Path -Path $Path -PathType Leaf) -and (-not $Force)) { + + throw ($localized.ImageAlreadyExistsError -f $Path); + } + elseif ((Test-Path -Path $Path -PathType Leaf) -and ($Force)) { + + Dismount-VHD -Path $Path -ErrorAction Stop; + WriteVerbose ($localized.RemovingDiskImage -f $Path); + Remove-Item -Path $Path -Force -ErrorAction Stop; + } + + } #end begin + process { + + WriteVerbose ($localized.CreatingDiskImage -f $Path); + $vhd = New-Vhd -Path $Path -Dynamic -SizeBytes $Size; + WriteVerbose ($localized.MountingDiskImage -f $Path); + $vhdMount = Mount-VHD -Path $Path -Passthru; + WriteVerbose ($localized.InitializingDiskImage -f $Path); + [ref] $null = Initialize-Disk -Number $vhdMount.DiskNumber -PartitionStyle $PartitionStyle -PassThru; + + switch ($PartitionStyle) { + 'MBR' { + NewDiskImageMbr -Vhd $vhdMount; + } + 'GPT' { + NewDiskImageGpt -Vhd $vhdMount; + } + } + + if ($Passthru) { + + return $vhdMount; + } + else { + + Dismount-VHD -Path $Path; + } + + } #end process + +} + diff --git a/Private/NewDiskImageGpt.ps1 b/Private/NewDiskImageGpt.ps1 new file mode 100644 index 00000000..684cf036 --- /dev/null +++ b/Private/NewDiskImageGpt.ps1 @@ -0,0 +1,38 @@ +function NewDiskImageGpt { + +<# + .SYNOPSIS + Create a new GPT-formatted disk image. +#> + [CmdletBinding()] + param ( + ## Mounted VHD(X) Operating System disk image + [Parameter(Mandatory)] + [ValidateNotNull()] + [System.Object] $Vhd # Microsoft.Vhd.PowerShell.VirtualHardDisk + ) + process { + + ## Temporarily disable Windows Explorer popup disk initialization and format notifications + ## http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/29/use-powershell-to-initialize-raw-disks-and-partition-and-format-volumes.aspx + Stop-Service -Name 'ShellHWDetection' -Force -ErrorAction Ignore; + + WriteVerbose ($localized.CreatingDiskPartition -f 'EFI'); + $efiPartition = New-Partition -DiskNumber $Vhd.DiskNumber -Size 250MB -GptType '{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}' -AssignDriveLetter; + WriteVerbose ($localized.FormattingDiskPartition -f 'EFI'); + NewDiskPartFat32Partition -DiskNumber $Vhd.DiskNumber -PartitionNumber $efiPartition.PartitionNumber; + + WriteVerbose ($localized.CreatingDiskPartition -f 'MSR'); + [ref] $null = New-Partition -DiskNumber $Vhd.DiskNumber -Size 128MB -GptType '{e3c9e316-0b5c-4db8-817d-f92df00215ae}'; + + WriteVerbose ($localized.CreatingDiskPartition -f 'Windows'); + $osPartition = New-Partition -DiskNumber $Vhd.DiskNumber -UseMaximumSize -GptType '{ebd0a0a2-b9e5-4433-87c0-68b6b72699c7}' -AssignDriveLetter; + WriteVerbose ($localized.FormattingDiskPartition -f 'Windows'); + $osVolume = Format-Volume -Partition $osPartition -FileSystem NTFS -Force -Confirm:$false; + + Start-Service -Name 'ShellHWDetection'; + + } #end process + +} + diff --git a/Private/NewDiskImageMbr.ps1 b/Private/NewDiskImageMbr.ps1 new file mode 100644 index 00000000..3be6e75a --- /dev/null +++ b/Private/NewDiskImageMbr.ps1 @@ -0,0 +1,32 @@ +function NewDiskImageMbr { + +<# + .SYNOPSIS + Create a new MBR-formatted disk image. +#> + [CmdletBinding()] + param ( + ## Mounted VHD(X) Operating System disk image + [Parameter(Mandatory)] + [ValidateNotNull()] + [System.Object] $Vhd # Microsoft.Vhd.PowerShell.VirtualHardDisk + ) + process { + + ## Temporarily disable Windows Explorer popup disk initialization and format notifications + ## http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/29/use-powershell-to-initialize-raw-disks-and-partition-and-format-volumes.aspx + Stop-Service -Name 'ShellHWDetection' -Force -ErrorAction Ignore; + + WriteVerbose ($localized.CreatingDiskPartition -f 'Windows'); + $osPartition = New-Partition -DiskNumber $Vhd.DiskNumber -UseMaximumSize -MbrType IFS -IsActive | + Add-PartitionAccessPath -AssignDriveLetter -PassThru | + Get-Partition; + WriteVerbose ($localized.FormattingDiskPartition -f 'Windows'); + $osVolume = Format-Volume -Partition $osPartition -FileSystem NTFS -Force -Confirm:$false; + + Start-Service -Name 'ShellHWDetection'; + + } #end proces + +} + diff --git a/Private/NewDiskPartFat32Partition.ps1 b/Private/NewDiskPartFat32Partition.ps1 new file mode 100644 index 00000000..23e7392a --- /dev/null +++ b/Private/NewDiskPartFat32Partition.ps1 @@ -0,0 +1,24 @@ +function NewDiskPartFat32Partition { + +<# + .SYNOPSIS + Uses DISKPART.EXE to create a new Fat32 system partition. This permits mocking of DISKPART calls. +#> + [CmdletBinding()] + param ( + [Parameter(Mandatory)] + [System.Int32] $DiskNumber, + + [Parameter(Mandatory)] + [System.Int32] $PartitionNumber + ) + process { + @" +select disk $DiskNumber +select partition $PartitionNumber +format fs=fat32 label="System" +"@ | & "$env:SystemRoot\System32\DiskPart.exe" | Out-Null; + } + +} + diff --git a/Private/NewLabMedia.ps1 b/Private/NewLabMedia.ps1 new file mode 100644 index 00000000..984e889a --- /dev/null +++ b/Private/NewLabMedia.ps1 @@ -0,0 +1,98 @@ +function NewLabMedia { + +<# + .SYNOPSIS + Creates a new lab media object. + .DESCRIPTION + Permits validation of custom NonNodeData\Lability\Media entries. +#> + [CmdletBinding()] + param ( + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Id = $(throw ($localized.MissingParameterError -f 'Id')), + + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Filename = $(throw ($localized.MissingParameterError -f 'Filename')), + + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Description = '', + + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet('x86','x64')] + [System.String] $Architecture = $(throw ($localized.MissingParameterError -f 'Architecture')), + + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $ImageName = '', + + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet('ISO','VHD')] + [System.String] $MediaType = $(throw ($localized.MissingParameterError -f 'MediaType')), + + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Uri = $(throw ($localized.MissingParameterError -f 'Uri')), + + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $Checksum = '', + + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $ProductKey = '', + + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet('Windows','Linux')] + [System.String] $OperatingSystem = 'Windows', + + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.Collections.Hashtable] $CustomData = @{}, + + [Parameter(ValueFromPipelineByPropertyName)] + [AllowNull()] + [System.Array] $Hotfixes + ) + begin { + + ## Confirm we have a valid Uri + try { + + $resolvedUri = New-Object -TypeName 'System.Uri' -ArgumentList $Uri; + if ($resolvedUri.Scheme -notin 'http','https','file') { + throw ($localized.UnsupportedUriSchemeError -f $resolvedUri.Scheme); + } + } + catch { + + throw $_; + } + + } + process { + + $labMedia = [PSCustomObject] @{ + Id = $Id; + Filename = $Filename; + Description = $Description; + Architecture = $Architecture; + ImageName = $ImageName; + MediaType = $MediaType; + OperatingSystem = $OperatingSystem; + Uri = [System.Uri] $Uri; + Checksum = $Checksum; + CustomData = $CustomData; + Hotfixes = $Hotfixes; + } + + ## Ensure any explicit product key overrides the CustomData value + if ($ProductKey) { + + $CustomData['ProductKey'] = $ProductKey; + } + return $labMedia; + + } #end process + +} + diff --git a/Private/NewLabSwitch.ps1 b/Private/NewLabSwitch.ps1 new file mode 100644 index 00000000..653f1c13 --- /dev/null +++ b/Private/NewLabSwitch.ps1 @@ -0,0 +1,53 @@ +function NewLabSwitch { + +<# + .SYNOPSIS + Creates a new lab network switch object. + .DESCRIPTION + Permits validation of custom NonNodeData\Lability\Network entries. +#> + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( + ## Virtual switch name + [Parameter(Mandatory, ValueFromPipeline)] [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## Virtual switch type + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [ValidateSet('Internal','External','Private')] + [System.String] $Type, + + ## Physical network adapter name (for external switches) + [Parameter(ValueFromPipelineByPropertyName)] [ValidateNotNull()] + [System.String] $NetAdapterName, + + ## Share host access (for external virtual switches) + [Parameter(ValueFromPipelineByPropertyName)] [ValidateNotNull()] + [System.Boolean] $AllowManagementOS = $false, + + ## Virtual switch availability + [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('Present','Absent')] + [System.String] $Ensure = 'Present' + ) + begin { + if (($Type -eq 'External') -and (-not $NetAdapterName)) { + throw ($localized.MissingParameterError -f 'NetAdapterName'); + } + } #end begin + process { + $newLabSwitch = @{ + Name = $Name; + Type = $Type; + NetAdapterName = $NetAdapterName; + AllowManagementOS = $AllowManagementOS; + Ensure = $Ensure; + } + if ($Type -ne 'External') { + [ref] $null = $newLabSwitch.Remove('NetAdapterName'); + [ref] $null = $newLabSwitch.Remove('AllowManagementOS'); + } + return $newLabSwitch; + } #end process + +} + diff --git a/Private/NewLabVM.ps1 b/Private/NewLabVM.ps1 new file mode 100644 index 00000000..c7a21cc5 --- /dev/null +++ b/Private/NewLabVM.ps1 @@ -0,0 +1,189 @@ +function NewLabVM { + +<# + .SYNOPSIS + Creates and configures a lab virtual machine. + .DESCRIPTION + Creates an new VM, creating the switch if required, injecting all + resources and snapshotting as required. +#> + [CmdletBinding(DefaultParameterSetName = 'PSCredential')] + param ( + ## Specifies the lab virtual machine/node name. + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Local administrator password of the VM. The username is NOT used. + [Parameter(ParameterSetName = 'PSCredential', ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.Management.Automation.PSCredential] + [System.Management.Automation.CredentialAttribute()] + $Credential = (& $credentialCheckScriptBlock), + + ## Local administrator password of the VM. + [Parameter(Mandatory, ParameterSetName = 'Password', ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.Security.SecureString] $Password, + + ## Virtual machine DSC .mof and .meta.mof location + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $Path = (GetLabHostDSCConfigurationPath), + + ## Skip creating baseline snapshots + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $NoSnapshot, + + ## Is a quick VM, e.g. created via the New-LabVM cmdlet + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $IsQuickVM + ) + begin { + + ## If we have only a secure string, create a PSCredential + if ($PSCmdlet.ParameterSetName -eq 'Password') { + $Credential = New-Object -TypeName 'System.Management.Automation.PSCredential' -ArgumentList 'LocalAdministrator', $Password; + } + if (-not $Credential) {throw ($localized.CannotProcessCommandError -f 'Credential'); } + elseif ($Credential.Password.Length -eq 0) { throw ($localized.CannotBindArgumentError -f 'Password'); } + + } + process { + + $node = ResolveLabVMProperties -NodeName $Name -ConfigurationData $ConfigurationData -ErrorAction Stop; + $NodeName = $node.NodeName; + ## Display name includes any environment prefix/suffix + $displayName = $node.NodeDisplayName; + + if (-not (TestComputerName -ComputerName $displayName)) { + + throw (localized.InvalidComputerNameError -f $displayName); + } + + ## Don't attempt to check certificates for 'Quick VMs' + if (-not $IsQuickVM) { + + ## Check for certificate before we (re)create the VM + if (-not [System.String]::IsNullOrWhitespace($node.ClientCertificatePath)) { + + $expandedClientCertificatePath = [System.Environment]::ExpandEnvironmentVariables($node.ClientCertificatePath); + if (-not (Test-Path -Path $expandedClientCertificatePath -PathType Leaf)) { + + throw ($localized.CannotFindCertificateError -f 'Client', $node.ClientCertificatePath); + } + } + else { + + WriteWarning ($localized.NoCertificateFoundWarning -f 'Client'); + } + + if (-not [System.String]::IsNullOrWhitespace($node.RootCertificatePath)) { + + $expandedRootCertificatePath = [System.Environment]::ExpandEnvironmentVariables($node.RootCertificatePath); + if (-not (Test-Path -Path $expandedRootCertificatePath -PathType Leaf)) { + + throw ($localized.CannotFindCertificateError -f 'Root', $node.RootCertificatePath); + } + } + else { + + WriteWarning ($localized.NoCertificateFoundWarning -f 'Root'); + } + + } #end if not quick VM + + foreach ($switchName in $node.SwitchName) { + + WriteVerbose ($localized.SettingVMConfiguration -f 'Virtual Switch', $switchName); + SetLabSwitch -Name $switchName -ConfigurationData $ConfigurationData; + } + + if (-not (Test-LabImage -Id $node.Media -ConfigurationData $ConfigurationData)) { + + [ref] $null = New-LabImage -Id $node.Media -ConfigurationData $ConfigurationData; + } + + WriteVerbose ($localized.ResettingVMConfiguration -f 'VHDX', "$displayName.vhdx"); + ResetLabVMDisk -Name $DisplayName -Media $node.Media -ConfigurationData $ConfigurationData -ErrorAction Stop; + + WriteVerbose ($localized.SettingVMConfiguration -f 'VM', $displayName); + $setLabVirtualMachineParams = @{ + Name = $DisplayName; + SwitchName = $node.SwitchName; + Media = $node.Media; + StartupMemory = $node.StartupMemory; + MinimumMemory = $node.MinimumMemory; + MaximumMemory = $node.MaximumMemory; + ProcessorCount = $node.ProcessorCount; + MACAddress = $node.MACAddress; + SecureBoot = $node.SecureBoot; + GuestIntegrationServices = $node.GuestIntegrationServices; + ConfigurationData = $ConfigurationData; + } + SetLabVirtualMachine @setLabVirtualMachineParams; + + $media = ResolveLabMedia -Id $node.Media -ConfigurationData $ConfigurationData; + if ($media.OperatingSystem -eq 'Linux') { + ## Skip injecting files for Linux VMs.. + } + else { + + WriteVerbose ($localized.AddingVMCustomization -f 'VM'); + $setLabVMDiskFileParams = @{ + NodeName = $NodeName; + ConfigurationData = $ConfigurationData; + Path = $Path; + Credential = $Credential; + CoreCLR = $media.CustomData.SetupComplete -eq 'CoreCLR'; + } + + $resolveCustomBootStrapParams = @{ + CustomBootstrapOrder = $node.CustomBootstrapOrder; + ConfigurationCustomBootstrap = $node.CustomBootstrap; + MediaCustomBootStrap = $media.CustomData.CustomBootstrap; + } + + $customBootstrap = ResolveCustomBootStrap @resolveCustomBootStrapParams; + if ($customBootstrap) { + + $setLabVMDiskFileParams['CustomBootstrap'] = $customBootstrap; + } + + if (-not [System.String]::IsNullOrEmpty($media.CustomData.ProductKey)) { + + $setLabVMDiskFileParams['ProductKey'] = $media.CustomData.ProductKey; + } + SetLabVMDiskFile @setLabVMDiskFileParams; + + } #end Windows VMs + + if (-not $NoSnapshot) { + + $snapshotName = $localized.BaselineSnapshotName -f $labDefaults.ModuleName; + WriteVerbose ($localized.CreatingBaselineSnapshot -f $snapshotName); + Checkpoint-VM -Name $displayName -SnapshotName $snapshotName; + } + + if ($node.WarningMessage) { + + if ($node.WarningMessage -is [System.String]) { + + WriteWarning ($localized.NodeCustomMessageWarning -f $NodeName, $node.WarningMessage); + } + else { + + WriteWarning ($localized.IncorrectPropertyTypeError -f 'WarningMessage', '[System.String]') + } + } + + Write-Output -InputObject (Get-VM -Name $displayName); + + } #end process + +} + diff --git a/Private/NewLabVMSnapshot.ps1 b/Private/NewLabVMSnapshot.ps1 new file mode 100644 index 00000000..3ea4ec63 --- /dev/null +++ b/Private/NewLabVMSnapshot.ps1 @@ -0,0 +1,23 @@ +function NewLabVMSnapshot { + +<# + .SYNOPSIS + Creates a snapshot of all virtual machines with the specified snapshot name. +#> + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipeline)] [ValidateNotNullOrEmpty()] + [System.String[]] $Name, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.String] $SnapshotName + ) + process { + foreach ($vmName in $Name) { + WriteVerbose -Message ($localized.SnapshottingVirtualMachine -f $vmName, $SnapshotName); + Checkpoint-VM -VMName $vmName -SnapshotName $SnapshotName; + } #end foreach VM + } #end process + +} + diff --git a/Private/NewUnattendXml.ps1 b/Private/NewUnattendXml.ps1 new file mode 100644 index 00000000..a0340249 --- /dev/null +++ b/Private/NewUnattendXml.ps1 @@ -0,0 +1,215 @@ +function NewUnattendXml { + +<# + .SYNOPSIS + Creates a Windows unattended installation file. + .DESCRIPTION + Creates an unattended Windows 8/2012 installation file that will configure + an operating system deployed from a WIM file, deploy the operating system + and ensure that Powershell's desired state configuration (DSC) is configured + to pull its configuration from the specified pull server. +#> + [CmdletBinding()] + [OutputType([System.Xml.XmlDocument])] + param ( + # Local Administrator Password + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.Management.Automation.PSCredential] + [System.Management.Automation.CredentialAttribute()] + $Credential, + + # Computer name + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $ComputerName, + + # Product Key + [Parameter(ValueFromPipelineByPropertyName)] [ValidatePattern('^[A-Z0-9]{5,5}-[A-Z0-9]{5,5}-[A-Z0-9]{5,5}-[A-Z0-9]{5,5}-[A-Z0-9]{5,5}$')] + [System.String] $ProductKey, + + # Input Locale + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $InputLocale = 'en-US', + + # System Locale + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $SystemLocale = 'en-US', + + # User Locale + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $UserLocale = 'en-US', + + # UI Language + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $UILanguage = 'en-US', + + # Timezone + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Timezone, ##TODO: Validate timezones? + + # Registered Owner + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.String] $RegisteredOwner = 'Virtual Engine', + + # Registered Organization + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.String] $RegisteredOrganization = 'Virtual Engine', + + # TODO: Execute synchronous commands during OOBE pass as they only currently run during the Specialize pass + ## Array of hashtables with Description, Order and Path keys + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable[]] $ExecuteCommand + ) + begin { + $templateUnattendXml = [System.Xml.XmlDocument] @' + + + + + + + + + en-US + en-US + en-US + en-US + + + en-US + en-US + en-US + en-US + + + + + en-US + en-US + en-US + en-US + + + en-US + en-US + en-US + en-US + + + + true + true + Work + 3 + true + true + + false + GMT Standard Time + + + + false</PlainText> + </AdministratorPassword> + </UserAccounts> + <RegisteredOrganization>Virtual Engine</RegisteredOrganization> + <RegisteredOwner>Virtual Engine</RegisteredOwner> + <BluetoothTaskbarIconEnabled>true</BluetoothTaskbarIconEnabled> + <DoNotCleanTaskBar>false</DoNotCleanTaskBar> + </component> + <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <OOBE> + <HideEULAPage>true</HideEULAPage> + <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> + <NetworkLocation>Work</NetworkLocation> + <ProtectYourPC>3</ProtectYourPC> + <SkipUserOOBE>true</SkipUserOOBE> + <SkipMachineOOBE>true</SkipMachineOOBE> + </OOBE> + <ShowWindowsLive>false</ShowWindowsLive> + <TimeZone>GMT Standard Time</TimeZone> + <UserAccounts> + <AdministratorPassword> + <Value></Value> + <PlainText>false</PlainText> + </AdministratorPassword> + </UserAccounts> + <RegisteredOrganization>Virtual Engine</RegisteredOrganization> + <RegisteredOwner>Virtual Engine</RegisteredOwner> + <BluetoothTaskbarIconEnabled>true</BluetoothTaskbarIconEnabled> + <DoNotCleanTaskBar>false</DoNotCleanTaskBar> + </component> + </settings> +</unattend> +'@ + [xml] $unattendXml = $templateUnattendXml; + } + process { + + foreach ($setting in $unattendXml.Unattend.Settings) { + + foreach($component in $setting.Component) { + + if ($setting.'Pass' -eq 'specialize' -and $component.'Name' -eq 'Microsoft-Windows-Deployment') { + + if (($null -ne $ExecuteCommand) -or ($ExecuteCommand.Length -gt 0)) { + + $commandOrder = 1; + foreach ($synchronousCommand in $ExecuteCommand) { + + $runSynchronousElement = $component.AppendChild($unattendXml.CreateElement('RunSynchronous','urn:schemas-microsoft-com:unattend')); + $syncCommandElement = $runSynchronousElement.AppendChild($unattendXml.CreateElement('RunSynchronousCommand','urn:schemas-microsoft-com:unattend')); + [ref] $null = $syncCommandElement.SetAttribute('action','http://schemas.microsoft.com/WMIConfig/2002/State','add'); + $syncCommandDescriptionElement = $syncCommandElement.AppendChild($unattendXml.CreateElement('Description','urn:schemas-microsoft-com:unattend')); + [ref] $null = $syncCommandDescriptionElement.AppendChild($unattendXml.CreateTextNode($synchronousCommand['Description'])); + $syncCommandOrderElement = $syncCommandElement.AppendChild($unattendXml.CreateElement('Order','urn:schemas-microsoft-com:unattend')); + [ref] $null = $syncCommandOrderElement.AppendChild($unattendXml.CreateTextNode($commandOrder)); + $syncCommandPathElement = $syncCommandElement.AppendChild($unattendXml.CreateElement('Path','urn:schemas-microsoft-com:unattend')); + [ref] $null = $syncCommandPathElement.AppendChild($unattendXml.CreateTextNode($synchronousCommand['Path'])); + $commandOrder++; + } + } + } + + if (($setting.'Pass' -eq 'specialize') -and ($component.'Name' -eq 'Microsoft-Windows-Shell-Setup')) { + + if ($ComputerName) { + + $computerNameElement = $component.AppendChild($unattendXml.CreateElement('ComputerName','urn:schemas-microsoft-com:unattend')); + [ref] $null = $computerNameElement.AppendChild($unattendXml.CreateTextNode($ComputerName)); + } + if ($ProductKey) { + + $productKeyElement = $component.AppendChild($unattendXml.CreateElement('ProductKey','urn:schemas-microsoft-com:unattend')); + [ref] $null = $productKeyElement.AppendChild($unattendXml.CreateTextNode($ProductKey.ToUpper())); + } + } + + if ((($setting.'Pass' -eq 'specialize') -or ($setting.'Pass' -eq 'oobeSystem')) -and ($component.'Name' -eq 'Microsoft-Windows-International-Core')) { + + $component.InputLocale = $InputLocale; + $component.SystemLocale = $SystemLocale; + $component.UILanguage = $UILanguage; + $component.UserLocale = $UserLocale; + } + + if (($setting.'Pass' -eq 'oobeSystem') -and ($component.'Name' -eq 'Microsoft-Windows-Shell-Setup')) { + + $component.TimeZone = $Timezone; + $concatenatedPassword = '{0}AdministratorPassword' -f $Credential.GetNetworkCredential().Password; + $component.UserAccounts.AdministratorPassword.Value = [System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($concatenatedPassword)); + $component.RegisteredOrganization = $RegisteredOrganization; + $component.RegisteredOwner = $RegisteredOwner; + } + + } #end foreach setting.Component + + } #end foreach unattendXml.Unattend.Settings + + Write-Output -InputObject $unattendXml; + + } #end process + +} + diff --git a/Private/RemoveConfigurationData.ps1 b/Private/RemoveConfigurationData.ps1 new file mode 100644 index 00000000..aa2109a5 --- /dev/null +++ b/Private/RemoveConfigurationData.ps1 @@ -0,0 +1,25 @@ +function RemoveConfigurationData { + +<# + .SYNOPSIS + Removes custom lab configuration data file. +#> + [CmdletBinding(SupportsShouldProcess)] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + param ( + [Parameter(Mandatory)] + [ValidateSet('Host','VM','Media','CustomMedia')] + [System.String] $Configuration + ) + process { + + $configurationPath = ResolveConfigurationDataPath -Configuration $Configuration; + if (Test-Path -Path $configurationPath) { + WriteVerbose ($localized.ResettingConfigurationDefaults -f $Configuration); + Remove-Item -Path $configurationPath -Force; + } + + } #end process + +} + diff --git a/Private/RemoveLabSwitch.ps1 b/Private/RemoveLabSwitch.ps1 new file mode 100644 index 00000000..32345132 --- /dev/null +++ b/Private/RemoveLabSwitch.ps1 @@ -0,0 +1,33 @@ +function RemoveLabSwitch { + +<# + .SYNOPSIS + Removes a virtual network switch configuration. + .DESCRIPTION + Deletes a virtual network switch configuration using the xVMSwitch DSC resource. +#> + [CmdletBinding(SupportsShouldProcess)] + param ( + ## Switch Id/Name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Name, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + $networkSwitch = ResolveLabSwitch @PSBoundParameters; + if (($null -eq $networkSwitch.IsExisting) -or ($networkSwitch.IsExisting -eq $false)) { + if ($PSCmdlet.ShouldProcess($Name)) { + $networkSwitch['Ensure'] = 'Absent'; + ImportDscResource -ModuleName xHyper-V -ResourceName MSFT_xVMSwitch -Prefix VMSwitch; + [ref] $null = InvokeDscResource -ResourceName VMSwitch -Parameters $networkSwitch; + } + } + } #end process + +} + diff --git a/Private/RemoveLabVM.ps1 b/Private/RemoveLabVM.ps1 new file mode 100644 index 00000000..a86516e5 --- /dev/null +++ b/Private/RemoveLabVM.ps1 @@ -0,0 +1,71 @@ +function RemoveLabVM { + +<# + .SYNOPSIS + Deletes a lab virtual machine. +#> + [CmdletBinding(SupportsShouldProcess)] + param ( + ## Specifies the lab virtual machine/node name. + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Include removal of virtual switch(es). By default virtual switches are not removed. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $RemoveSwitch + ) + process { + + $node = ResolveLabVMProperties -NodeName $Name -ConfigurationData $ConfigurationData -NoEnumerateWildcardNode -ErrorAction Stop; + if (-not $node.NodeName) { + throw ($localized.CannotLocateNodeError -f $Name); + } + $Name = $node.NodeDisplayName; + + # Revert to oldest snapshot prior to VM removal to speed things up + Get-VMSnapshot -VMName $Name -ErrorAction SilentlyContinue | + Sort-Object -Property CreationTime | + Select-Object -First 1 | + Restore-VMSnapshot -Confirm:$false; + + RemoveLabVMSnapshot -Name $Name; + + WriteVerbose ($localized.RemovingNodeConfiguration -f 'VM', $Name); + $removeLabVirtualMachineParams = @{ + Name = $Name; + SwitchName = $node.SwitchName; + Media = $node.Media; + StartupMemory = $node.StartupMemory; + MinimumMemory = $node.MinimumMemory; + MaximumMemory = $node.MaximumMemory; + MACAddress = $node.MACAddress; + ProcessorCount = $node.ProcessorCount; + ConfigurationData = $ConfigurationData; + } + RemoveLabVirtualMachine @removeLabVirtualMachineParams; + + WriteVerbose ($localized.RemovingNodeConfiguration -f 'VHDX', "$Name.vhdx"); + $removeLabVMDiskParams = @{ + Name = $node.NodeDisplayName; + Media = $node.Media; + ConfigurationData = $ConfigurationData; + } + RemoveLabVMDisk @removeLabVMDiskParams -ErrorAction Stop; + + if ($RemoveSwitch) { + + WriteVerbose ($localized.RemovingNodeConfiguration -f 'Virtual Switch', $node.SwitchName); + RemoveLabSwitch -Name $node.SwitchName -ConfigurationData $ConfigurationData; + } + + } #end process + +} + diff --git a/Private/RemoveLabVMDisk.ps1 b/Private/RemoveLabVMDisk.ps1 new file mode 100644 index 00000000..0f8c5e3e --- /dev/null +++ b/Private/RemoveLabVMDisk.ps1 @@ -0,0 +1,54 @@ +function RemoveLabVMDisk { + +<# + .SYNOPSIS + Removes lab VM disk file (VHDX) configuration. + .DESCRIPTION + Configures a VM disk configuration using the xVHD DSC resource. +#> + [CmdletBinding(SupportsShouldProcess)] + param ( + ## VM/node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Name, + + ## Media Id + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Media, + + ## Lab DSC configuration data + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + $hostDefaults = GetConfigurationData -Configuration Host; + if ($PSBoundParameters.ContainsKey('ConfigurationData')) { + $image = Get-LabImage -Id $Media -ConfigurationData $ConfigurationData -ErrorAction Stop; + } + else { + $image = Get-LabImage -Id $Media -ErrorAction Stop; + } + if ($image) { + ## If the parent image isn't there, the differencing VHD won't be either + $vhdPath = Join-Path -Path $hostDefaults.DifferencingVhdPath -ChildPath "$Name.vhdx"; + if (Test-Path -Path $vhdPath) { + ## Only attempt to remove the differencing disk if it's there (and xVHD will throw) + if ($PSCmdlet.ShouldProcess($vhdPath)) { + $vhd = @{ + Name = $Name; + Path = $hostDefaults.DifferencingVhdPath; + ParentPath = $image.ImagePath; + Generation = $image.Generation; + Ensure = 'Absent'; + } + ImportDscResource -ModuleName xHyper-V -ResourceName MSFT_xVHD -Prefix VHD; + [ref] $null = InvokeDscResource -ResourceName VHD -Parameters $vhd; + } + } + } + } #end process + +} + diff --git a/Private/RemoveLabVMSnapshot.ps1 b/Private/RemoveLabVMSnapshot.ps1 new file mode 100644 index 00000000..2983e0d6 --- /dev/null +++ b/Private/RemoveLabVMSnapshot.ps1 @@ -0,0 +1,33 @@ +function RemoveLabVMSnapshot { + +<# + .SYNOPSIS + Removes a VM snapshot. +#> + [CmdletBinding(SupportsShouldProcess)] + param ( + [Parameter(Mandatory, ValueFromPipeline)] [ValidateNotNullOrEmpty()] + [System.String[]] $Name, + + [Parameter(ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.String] $SnapshotName = '*' + ) + process { + <## TODO: Add the ability to force/wait for the snapshots to be removed. When removing snapshots it take a minute + or two before the files are actually removed. This causes issues when performing a lab reset #> + foreach ($vmName in $Name) { + + # Sort by descending CreationTime to ensure we will not have to commit changes from one snapshot to another + Get-VMSnapshot -VMName $vmName -ErrorAction SilentlyContinue | + Where-Object Name -like $SnapshotName | + Sort-Object -Property CreationTime -Descending | + ForEach-Object { + WriteVerbose -Message ($localized.RemovingSnapshot -f $vmName, $_.Name); + Remove-VMSnapshot -VMName $_.VMName -Name $_.Name -Confirm:$false; + } + + } #end foreach VM + } #end process + +} + diff --git a/Private/RemoveLabVirtualMachine.ps1 b/Private/RemoveLabVirtualMachine.ps1 new file mode 100644 index 00000000..ea7bd08c --- /dev/null +++ b/Private/RemoveLabVirtualMachine.ps1 @@ -0,0 +1,58 @@ +function RemoveLabVirtualMachine { + +<# + .SYNOPSIS + Removes the current configuration a virtual machine. + .DESCRIPTION + Invokes/sets a virtual machine configuration using the xVMHyperV DSC resource. +#> + [CmdletBinding(SupportsShouldProcess)] + param ( + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] + [System.String] $Name, + + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] + [System.String[]] $SwitchName, + + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] + [System.String] $Media, + + [Parameter(Mandatory)] + [System.UInt64] $StartupMemory, + + [Parameter(Mandatory)] + [System.UInt64] $MinimumMemory, + + [Parameter(Mandatory)] + [System.UInt64] $MaximumMemory, + + [Parameter(Mandatory)] + [System.Int32] $ProcessorCount, + + [Parameter()] [AllowNull()] + [System.String[]] $MACAddress, + + [Parameter()] + [System.Boolean] $SecureBoot, + + [Parameter()] + [System.Boolean] $GuestIntegrationServices, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + if ($PSCmdlet.ShouldProcess($Name)) { + ## Resolve the xVMHyperV resource parameters + $vmHyperVParams = GetVirtualMachineProperties @PSBoundParameters; + $vmHyperVParams['Ensure'] = 'Absent'; + ImportDscResource -ModuleName xHyper-V -ResourceName MSFT_xVMHyperV -Prefix VM; + InvokeDscResource -ResourceName VM -Parameters $vmHyperVParams -ErrorAction SilentlyContinue; + } + } #end process + +} + diff --git a/Private/RenameModuleCacheVersion.ps1 b/Private/RenameModuleCacheVersion.ps1 new file mode 100644 index 00000000..a4823228 --- /dev/null +++ b/Private/RenameModuleCacheVersion.ps1 @@ -0,0 +1,54 @@ +function RenameModuleCacheVersion { + +<# + .SYNOPSIS + Renames a cached module zip file with its version number. +#> + [CmdletBinding(DefaultParameterSetName = 'PSGallery')] + [OutputType([System.IO.FileInfo])] + param ( + ## PowerShell module/DSC resource module name + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## Destination directory path to download the PowerShell module/DSC resource module to + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Path, + + ## GitHub module repository owner + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'GitHub')] + [ValidateNotNullOrEmpty()] + [System.String] $Owner, + + ## GitHub module branch + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'GitHub')] + [ValidateNotNullOrEmpty()] + [System.String] $Branch + ) + process { + + if ($PSCmdlet.ParameterSetName -eq 'GitHub') { + $moduleManifest = GetModuleCacheManifest -Path $Path -Provider 'GitHub'; + $versionedModuleFilename = '{0}-v{1}_{2}_{3}.zip' -f $Name, $moduleManifest.ModuleVersion, $Owner, $Branch; + } + else { + $moduleManifest = GetModuleCacheManifest -Path $Path; + $versionedModuleFilename = '{0}-v{1}.zip' -f $Name, $moduleManifest.ModuleVersion; + } + + $versionedModulePath = Join-Path -Path (Split-Path -Path $Path -Parent) -ChildPath $versionedModuleFilename; + + if (Test-Path -Path $versionedModulePath -PathType Leaf) { + ## Remove existing version module + Remove-Item -Path $versionedModulePath -Force -Confirm:$false; + } + + Rename-Item -Path $Path -NewName $versionedModuleFilename; + return (Get-Item -Path $versionedModulePath); + + } #end process + +} + diff --git a/Private/ResetLabVMDisk.ps1 b/Private/ResetLabVMDisk.ps1 new file mode 100644 index 00000000..f49d025b --- /dev/null +++ b/Private/ResetLabVMDisk.ps1 @@ -0,0 +1,30 @@ +function ResetLabVMDisk { + +<# + .SYNOPSIS + Removes and resets lab VM disk file (VHDX) configuration. +#> + [CmdletBinding()] + param ( + ## VM/node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Name, + + ## Media Id + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Media, + + ## Lab DSC configuration data + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + RemoveLabVMSnapshot -Name $Name; + RemoveLabVMDisk @PSBoundParameters; + SetLabVMDisk @PSBoundParameters; + } #end process + +} + diff --git a/Private/ResolveConfigurationDataPath.ps1 b/Private/ResolveConfigurationDataPath.ps1 new file mode 100644 index 00000000..f17d0614 --- /dev/null +++ b/Private/ResolveConfigurationDataPath.ps1 @@ -0,0 +1,57 @@ +function ResolveConfigurationDataPath { + +<# + .SYNOPSIS + Resolves the lab configuration data path. + .NOTES + When -IncludeDefaultPath is specified, if the configuration data file is not found, the default + module configuration path is returned. +#> + [CmdletBinding()] + [OutputType([System.Management.Automation.PSCustomObject])] + param ( + [Parameter(Mandatory)] + [ValidateSet('Host','VM','Media','CustomMedia')] + [System.String] $Configuration, + + [Parameter()] + [System.Management.Automation.SwitchParameter] $IncludeDefaultPath + ) + process { + + switch ($Configuration) { + + 'Host' { + + $configPath = $labDefaults.HostConfigFilename; + } + 'VM' { + + $configPath = $labDefaults.VMConfigFilename; + } + 'Media' { + + $configPath = $labDefaults.MediaConfigFilename; + } + 'CustomMedia' { + + $configPath = $labDefaults.CustomMediaConfigFilename; + } + } + $configPath = Join-Path -Path $labDefaults.ConfigurationData -ChildPath $configPath; + $resolvedPath = Join-Path -Path "$env:ALLUSERSPROFILE\$($labDefaults.ModuleName)" -ChildPath $configPath; + if ($IncludeDefaultPath) { + + if (-not (Test-Path -Path $resolvedPath)) { + + $resolvedPath = Join-Path -Path $labDefaults.ModuleRoot -ChildPath $configPath; + } + } + $resolvedPath = ResolvePathEx -Path $resolvedPath; + Write-Debug -Message ('Resolved ''{0}'' configuration file to ''{1}''.' -f $Configuration, $resolvedPath); + return $resolvedPath; + + } #end process + +} + diff --git a/Private/ResolveCustomBootStrap.ps1 b/Private/ResolveCustomBootStrap.ps1 new file mode 100644 index 00000000..72cdb247 --- /dev/null +++ b/Private/ResolveCustomBootStrap.ps1 @@ -0,0 +1,67 @@ +function ResolveCustomBootStrap { + +<# + .SYNOPSIS + Resolves the media and node custom bootstrap, using the specified CustomBootstrapOrder +#> + [CmdletBinding()] + [OutputType([System.String])] + param ( + ## Custom bootstrap order + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateSet('ConfigurationFirst','ConfigurationOnly','Disabled','MediaFirst','MediaOnly')] + [System.String] $CustomBootstrapOrder, + + ## Node/configuration custom bootstrap script + [Parameter(ValueFromPipelineByPropertyName)] + [AllowNull()] + [System.String] $ConfigurationCustomBootStrap, + + ## Media custom bootstrap script + [Parameter(ValueFromPipelineByPropertyName)] + [AllowNull()] + [System.String[]] $MediaCustomBootStrap + ) + begin { + + if ([System.String]::IsNullOrWhiteSpace($ConfigurationCustomBootStrap)) { + + $ConfigurationCustomBootStrap = ""; + } + ## Convert the string[] into a multi-line string + if ($MediaCustomBootstrap) { + + $mediaBootstrap = [System.String]::Join("`r`n", $MediaCustomBootStrap); + } + else { + + $mediaBootstrap = ""; + } + } #end begin + process { + + switch ($CustomBootstrapOrder) { + + 'ConfigurationFirst' { + $bootStrap = "{0}`r`n{1}" -f $ConfigurationCustomBootStrap, $mediaBootstrap; + } + 'ConfigurationOnly' { + $bootStrap = $ConfigurationCustomBootStrap; + } + 'MediaFirst' { + $bootStrap = "{0}`r`n{1}" -f $mediaBootstrap, $ConfigurationCustomBootStrap; + } + 'MediaOnly' { + $bootStrap = $mediaBootstrap; + } + Default { + #Disabled + } + } #end switch + + return $bootStrap; + + } #end process + +} + diff --git a/Private/ResolveDismPath.ps1 b/Private/ResolveDismPath.ps1 new file mode 100644 index 00000000..13492799 --- /dev/null +++ b/Private/ResolveDismPath.ps1 @@ -0,0 +1,52 @@ +function ResolveDismPath { + +<# + .SYNOPSIS + Resolves the specified path to a path to DISM dll. +#> + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [System.String] $Path + ) + process { + + if (-not (Test-Path -Path $Path)) { + + ## Path doesn't exist + throw ($localized.InvalidPathError -f 'Directory', $DismPath); + } + else { + + $dismItem = Get-Item -Path $Path; + $dismDllName = 'Microsoft.Dism.Powershell.dll'; + + if ($dismItem.Name -ne $dismDllName) { + + if ($dismItem -is [System.IO.DirectoryInfo]) { + + $dismItemPath = Join-Path -Path $DismPath -ChildPath $dismDllName; + + if (-not (Test-Path -Path $dismItemPath)) { + + throw ($localized.CannotLocateDismDllError -f $Path); + } + else { + + $dismItem = Get-Item -Path $dismItemPath; + } + } + else { + + throw ($localized.InvalidPathError -f 'File', $DismPath); + } + + } + } + + return $dismItem.FullName; + + } #end process + +} + diff --git a/Private/ResolveGitHubModuleUri.ps1 b/Private/ResolveGitHubModuleUri.ps1 new file mode 100644 index 00000000..2c319eb1 --- /dev/null +++ b/Private/ResolveGitHubModuleUri.ps1 @@ -0,0 +1,33 @@ +function ResolveGitHubModuleUri { + +<# + .SYNOPSIS + Resolves the correct GitHub URI for the specified Owner, Repository and Branch. +#> + [CmdletBinding()] + [OutputType([System.Uri])] + param ( + ## GitHub repository owner + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Owner, + + ## GitHub repository name + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Repository, + + ## GitHub repository branch + [Parameter(ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.String] $Branch = 'master', + + ## Catch all to be able to pass parameter via $PSBoundParameters + [Parameter(ValueFromRemainingArguments)] $RemainingArguments + ) + process { + + $uri = 'https://github.com/{0}/{1}/archive/{2}.zip' -f $Owner, $Repository, $Branch; + return New-Object -TypeName System.Uri -ArgumentList $uri; + + } #end process + +} + diff --git a/Private/ResolveLabMedia.ps1 b/Private/ResolveLabMedia.ps1 new file mode 100644 index 00000000..c3a28c49 --- /dev/null +++ b/Private/ResolveLabMedia.ps1 @@ -0,0 +1,67 @@ +function ResolveLabMedia { + +<# + .SYNOPSIS + Resolves the specified media using the registered media and configuration data. + .DESCRIPTION + Resolves the specified lab media from the registered media, but permitting the defaults to be overridden by configuration data. + + This also permits specifying of media within Configuration Data and not having to be registered on the lab host. +#> + [CmdletBinding()] + param ( + ## Media ID + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Id, + + ## Lab DSC configuration data + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + + ## Avoid any $media variable scoping issues + $media = $null; + + ## If we have configuration data specific instance, return that + if ($PSBoundParameters.ContainsKey('ConfigurationData')) { + + $customMedia = $ConfigurationData.NonNodeData.$($labDefaults.ModuleName).Media.Where({ $_.Id -eq $Id }); + if ($customMedia) { + + $newLabMediaParams = @{}; + foreach ($key in $customMedia.Keys) { + + $newLabMediaParams[$key] = $customMedia.$key; + } + $media = NewLabMedia @newLabMediaParams; + } + } + + ## If we have custom media, return that + if (-not $media) { + + $media = GetConfigurationData -Configuration CustomMedia; + $media = $media | Where-Object { $_.Id -eq $Id }; + } + + ## If we still don't have a media image, return the built-in object + if (-not $media) { + + $media = Get-LabMedia -Id $Id; + } + + ## We don't have any defined, custom or built-in media + if (-not $media) { + + throw ($localized.CannotLocateMediaError -f $Id); + } + + return $media; + + } #end process + +} + diff --git a/Private/ResolveLabModule.ps1 b/Private/ResolveLabModule.ps1 new file mode 100644 index 00000000..1381034b --- /dev/null +++ b/Private/ResolveLabModule.ps1 @@ -0,0 +1,81 @@ +function ResolveLabModule { + +<# + .SYNOPSIS + Returns the Node\DSCResource or Node\Module definitions from the + NonNodeData\Lability\DSCResource or NonNodeData\Lability\Module node. + .DESCRIPTION + Resolves lab modules/DSC resources names defined at the Node\DSCResource or + Node\Module node, and returns a collection of hashtables where the names + match the definition in the NonNodeData\Lability\DSCResource or + \NonNodeData\Lability\Module nodes. + + If resources are defined at the \NonNodeData\Lability\DSCResource or + NonNodeData\Lability\Module nodes, but there are no VM references, then all + the associated resources are returned. + .NOTES + If no NonNodeData\Lability\DscResource collection is defined, all locally + installed DSC resource modules are returned. +#> + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( + ## Lab VM/Node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $NodeName, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Module type to enumerate + [Parameter(Mandatory)] + [ValidateSet('Module','DscResource')] + [System.String] $ModuleType + ) + process { + + $resolveLabVMPropertiesParams = @{ + NodeName = $NodeName; + ConfigurationData = $ConfigurationData; + } + $nodeProperties = ResolveLabVMProperties @resolveLabVMPropertiesParams; + + $resolveModuleParams = @{ + ConfigurationData = $ConfigurationData; + ModuleType = $ModuleType; + } + if ($nodeProperties.ContainsKey($ModuleType)) { + $resolveModuleParams['Name'] = $nodeProperties[$ModuleType]; + } + + $modules = ResolveModule @resolveModuleParams; + + ## This is a temporary measure as this is a change in behaviour + if (($ModuleType -eq 'DscResource') -and ($null -eq $modules)) { + <# + There is no DSCResource = @() node defined. Therefore, we need + to copy all the existing DSC resources on from the host by + returning a load of FileSystem provider resources.. + #> + WriteWarning -Message ($localized.DscResourcesNotDefinedWarning); + + $modules = GetDscResourceModule -Path "$env:ProgramFiles\WindowsPowershell\Modules" | + ForEach-Object { + ## Create a new hashtable + Write-Output -InputObject @{ + Name = $_.ModuleName; + Version = $_.ModuleVersion; + Provider = 'FileSystem'; + Path = $_.Path; + } + }; + } + + return $modules; + } + +} + diff --git a/Private/ResolveLabResource.ps1 b/Private/ResolveLabResource.ps1 new file mode 100644 index 00000000..40aab5e2 --- /dev/null +++ b/Private/ResolveLabResource.ps1 @@ -0,0 +1,34 @@ +function ResolveLabResource { + +<# + .SYNOPSIS + Resolves a lab resource by its ID +#> + param ( + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Lab resource ID + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ResourceId + ) + process { + + $resource = $ConfigurationData.NonNodeData.($labDefaults.ModuleName).Resource | Where-Object Id -eq $ResourceId; + if ($resource) { + + return $resource; + } + else { + + throw ($localized.CannotResolveResourceIdError -f $resourceId); + } + + } #end process + +} + diff --git a/Private/ResolveLabSwitch.ps1 b/Private/ResolveLabSwitch.ps1 new file mode 100644 index 00000000..00582321 --- /dev/null +++ b/Private/ResolveLabSwitch.ps1 @@ -0,0 +1,51 @@ +function ResolveLabSwitch { + +<# + .SYNOPSIS + Resolves the specified switch using configuration data. +#> + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( + ## Switch Id/Name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Name, + + ## PowerShell DSC configuration document (.psd1) containing lab metadata. + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + $networkSwitch = $ConfigurationData.NonNodeData.$($labDefaults.ModuleName).Network.Where({ $_.Name -eq $Name }); + if ($networkSwitch) { + $networkHashtable = @{}; + foreach ($key in $networkSwitch.Keys) { + [ref] $null = $networkHashtable.Add($key, $networkSwitch.$Key); + } + $networkSwitch = NewLabSwitch @networkHashtable; + } + elseif (Get-VMSwitch -Name $Name -ErrorAction SilentlyContinue) { + ## Use an existing virtual switch with a matching name if one exists + WriteWarning -Message ($localized.UsingExistingSwitchWarning -f $Name); + $existingSwitch = Get-VMSwitch -Name $Name; + $networkSwitch = @{ + Name = $existingSwitch.Name; + Type = $existingSwitch.SwitchType; + AllowManagementOS = $existingSwitch.AllowManagementOS; + IsExisting = $true; + } + if ($existingSwitch.NetAdapterInterfaceDescription) { + $networkSwitch['NetAdapterName'] = (Get-NetAdapter -InterfaceDescription $existingSwitch.NetAdapterInterfaceDescription).Name; + } + } + else { + ## Create an internal switch + $networkSwitch = @{ Name = $Name; Type = 'Internal'; } + } + return $networkSwitch; + } #end process + +} + diff --git a/Private/ResolveLabVMDiskPath.ps1 b/Private/ResolveLabVMDiskPath.ps1 new file mode 100644 index 00000000..7616b779 --- /dev/null +++ b/Private/ResolveLabVMDiskPath.ps1 @@ -0,0 +1,23 @@ +function ResolveLabVMDiskPath { + +<# + .SYNOPSIS + Resolves the specified VM name to it's target VHDX path. +#> + param ( + ## VM/node name. + [Parameter(Mandatory, ValueFromPipeline)] [ValidateNotNullOrEmpty()] + [System.String] $Name, + + [Parameter()] [ValidateSet('VHD','VHDX')] + [System.String] $Generation = 'VHDX' + ) + process { + $hostDefaults = GetConfigurationData -Configuration Host; + $vhdName = '{0}.{1}' -f $Name, $Generation.ToLower(); + $vhdPath = Join-Path -Path $hostDefaults.DifferencingVhdPath -ChildPath $vhdName; + return $vhdPath; + } #end process + +} + diff --git a/Private/ResolveLabVMProperties.ps1 b/Private/ResolveLabVMProperties.ps1 new file mode 100644 index 00000000..e6175a6e --- /dev/null +++ b/Private/ResolveLabVMProperties.ps1 @@ -0,0 +1,106 @@ +function ResolveLabVMProperties { + +<# + .SYNOPSIS + Resolves a node's properites. + .DESCRIPTION + Resolves a lab virtual machine properties from the lab defaults, Node\* node + and Node\NodeName node. + + Properties defined on the wildcard node override the lab defaults. + Properties defined at the node override the wildcard node settings. +#> + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( + ## Lab VM/Node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $NodeName, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Do not enumerate the AllNodes.'*' node + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $NoEnumerateWildcardNode + ) + process { + + $node = @{ }; + $moduleName = $labDefaults.ModuleName; + + ## Set the node's display name, if defined. + if ($ConfigurationData.NonNodeData.$moduleName.EnvironmentPrefix) { + + $node["$($moduleName)_EnvironmentPrefix"] = $ConfigurationData.NonNodeData.$moduleName.EnvironmentPrefix; + } + if ($ConfigurationData.NonNodeData.$moduleName.EnvironmentSuffix) { + + $node["$($moduleName)_EnvironmentSuffix"] = $ConfigurationData.NonNodeData.$moduleName.EnvironmentSuffix; + } + + if (-not $NoEnumerateWildcardNode) { + + ## Retrieve the AllNodes.* properties + $ConfigurationData.AllNodes.Where({ $_.NodeName -eq '*' }) | ForEach-Object { + foreach ($key in $_.Keys) { + + $node[$key] = $_.$key; + } + } + } + + ## Retrieve the AllNodes.$NodeName properties + $ConfigurationData.AllNodes.Where({ $_.NodeName -eq $NodeName }) | ForEach-Object { + + foreach ($key in $_.Keys) { + + $node[$key] = $_.$key; + } + } + + ## Check VM defaults + $labDefaultProperties = GetConfigurationData -Configuration VM; + $properties = Get-Member -InputObject $labDefaultProperties -MemberType NoteProperty; + foreach ($propertyName in $properties.Name) { + + ## Int32 values of 0 get coerced into $false! + if (($node.$propertyName -isnot [System.Int32]) -and (-not $node.ContainsKey($propertyName))) { + + $node[$propertyName] = $labDefaultProperties.$propertyName; + } + } + + ## Set the node's friendly/display name + $nodeDisplayName = $node.NodeName; + $environmentPrefix = '{0}_EnvironmentPrefix' -f $moduleName; + $environmentSuffix = '{0}_EnvironmentSuffix' -f $moduleName; + if (-not [System.String]::IsNullOrEmpty($node[$environmentPrefix])) { + + $nodeDisplayName = '{0}{1}' -f $node[$environmentPrefix], $nodeDisplayName; + } + if (-not [System.String]::IsNullOrEmpty($node[$environmentSuffix])) { + + $nodeDisplayName = '{0}{1}' -f $nodeDisplayName, $node[$environmentSuffix]; + } + $node["$($moduleName)_NodeDisplayName"] = $nodeDisplayName; + + ## Rename/overwrite existing parameter values where $moduleName-specific parameters exist + foreach ($key in @($node.Keys)) { + + if ($key.StartsWith("$($moduleName)_")) { + + $node[($key.Replace("$($moduleName)_",''))] = $node.$key; + $node.Remove($key); + } + } + + return $node; + + } #end process + +} + diff --git a/Private/ResolveModule.ps1 b/Private/ResolveModule.ps1 new file mode 100644 index 00000000..a80467e8 --- /dev/null +++ b/Private/ResolveModule.ps1 @@ -0,0 +1,51 @@ +function ResolveModule { + +<# + .SYNOPSIS + Resolves a lab module definition by its name from Lability configuration data. +#> + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + [Parameter(Mandatory)] [ValidateSet('Module','DscResource')] + [System.String] $ModuleType, + + ## Lab module name/ID + [Parameter(ValueFromPipelineByPropertyName)] + [System.String[]] $Name, + + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $ThrowIfNotFound + ) + process { + + $modules = $ConfigurationData.NonNodeData.($labDefaults.ModuleName).$ModuleType; + + if (($PSBoundParameters.ContainsKey('Name')) -and ($Name -notcontains '*')) { + + ## Check we have them all first.. + foreach ($moduleName in $Name) { + if ($modules.Name -notcontains $moduleName) { + if ($ThrowIfNotFound) { + throw ($localized.CannotResolveModuleNameError -f $ModuleType, $moduleName); + } + else { + WriteWarning -Message ($localized.CannotResolveModuleNameError -f $ModuleType, $moduleName); + } + } + } + + $modules = $modules | Where-Object { $_.Name -in $Name }; + } + + return $modules; + } + +} + diff --git a/Private/ResolvePSGalleryModuleUri.ps1 b/Private/ResolvePSGalleryModuleUri.ps1 new file mode 100644 index 00000000..d687a51e --- /dev/null +++ b/Private/ResolvePSGalleryModuleUri.ps1 @@ -0,0 +1,46 @@ +function ResolvePSGalleryModuleUri { + + <# + .SYNOPSIS + Returns the direct download Uri for a PowerShell module hosted + on the PowerShell Gallery. +#> + [CmdletBinding()] + [OutputType([System.String])] + param ( + ## PowerShell DSC resource module name + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## The minimum version of the DSC module required + [Parameter(ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.Version] $MinimumVersion, + + ## The exact version of the DSC module required + [Parameter(ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.Version] $RequiredVersion, + + ## Direct download Uri + [Parameter(ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.String] $Uri, + + ## Catch all, for splatting $PSBoundParameters + [Parameter(ValueFromRemainingArguments)] + $RemainingArguments + ) + process { + if ($PSBoundParameters.ContainsKey('Uri')) { + return $Uri; + } + elseif ($PSBoundParameters.ContainsKey('RequiredVersion')) { + ## Download the specific version + return ('http://www.powershellgallery.com/api/v2/package/{0}/{1}' -f $Name, $RequiredVersion); + } + else { + ## Download the latest version + return ('http://www.powershellgallery.com/api/v2/package/{0}' -f $Name); + } + } #end process + +} + diff --git a/Private/ResolvePathEx.ps1 b/Private/ResolvePathEx.ps1 new file mode 100644 index 00000000..3bc50a25 --- /dev/null +++ b/Private/ResolvePathEx.ps1 @@ -0,0 +1,32 @@ +function ResolvePathEx { + +<# + .SYNOPSIS + Resolves the wildcard characters in a path, and displays the path contents, ignoring non-existent paths. + .DESCRIPTION + The Resolve-Path cmdlet interprets the wildcard characters in a path and displays the items and containers at + the location specified by the path, such as the files and folders or registry keys and subkeys. +#> + [CmdletBinding()] + [OutputType([System.String])] + param ( + [Parameter(Mandatory)] + [System.String] $Path + ) + process { + + try { + $expandedPath = [System.Environment]::ExpandEnvironmentVariables($Path); + $resolvedPath = Resolve-Path -Path $expandedPath -ErrorAction Stop; + $Path = $resolvedPath.ProviderPath; + } + catch [System.Management.Automation.ItemNotFoundException] { + $Path = [System.Environment]::ExpandEnvironmentVariables($_.TargetObject); + $Error.Remove($Error[-1]); + } + return $Path; + + } #end process + +} + diff --git a/Private/ResolveProgramFilesFolder.ps1 b/Private/ResolveProgramFilesFolder.ps1 new file mode 100644 index 00000000..2777692a --- /dev/null +++ b/Private/ResolveProgramFilesFolder.ps1 @@ -0,0 +1,52 @@ +function ResolveProgramFilesFolder { + +<# + .SYNOPSIS + Resolves known localized %ProgramFiles% directories. + .LINK + https://en.wikipedia.org/wiki/Program_Files +#> + [CmdletBinding(DefaultParameterSetName = 'Path')] + [OutputType([System.IO.DirectoryInfo])] + param ( + ## Root path to check + [Parameter(Mandatory, ParameterSetName = 'Path')] + [ValidateNotNullOrEmpty()] + [System.String] $Path, + + ## Drive letter + [Parameter(Mandatory, ParameterSetName = 'Drive')] + [ValidateLength(1,1)] + [System.String] $Drive + ) + begin { + + if ($PSCmdlet.ParameterSetName -eq 'Drive') { + $Path = '{0}:\' -f $Drive; + } + + } + process { + $knownFolderNames = @( + "Program Files", + "Programmes", + "Archivos de programa", + "Programme", + "Programfájlok", + "Programmi", + "Programmer", + "Program", + "Programfiler", + "Arquivos de Programas", + "Programas" + "Αρχεία Εφαρμογών" + ) + + Get-ChildItem -Path $Path -Directory | + Where-Object Name -in $knownFolderNames | + Select-Object -First 1; + + } #end process + +} + diff --git a/Private/SetBootStrap.ps1 b/Private/SetBootStrap.ps1 new file mode 100644 index 00000000..cbce3b93 --- /dev/null +++ b/Private/SetBootStrap.ps1 @@ -0,0 +1,36 @@ +function SetBootStrap { + +<# + .SYNOPSIS + Writes the lab BootStrap.ps1 file to the target directory. +#> + [CmdletBinding()] + param ( + ## Destination Bootstrap directory path. + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Path, + + ## Custom bootstrap script + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $CustomBootStrap, + + ## Is a CoreCLR VM. The PowerShell switches are different in the CoreCLR, i.e. Nano Server + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $CoreCLR + ) + process { + + [ref] $null = NewDirectory -Path $Path; + $bootStrapPath = Join-Path -Path $Path -ChildPath 'BootStrap.ps1'; + $bootStrap = (NewBootStrap -CoreCLR:$CoreCLR).ToString(); + if ($CustomBootStrap) { + + $bootStrap = $bootStrap -replace '<#CustomBootStrapInjectionPoint#>', $CustomBootStrap; + } + Set-Content -Path $bootStrapPath -Value $bootStrap -Encoding UTF8 -Force; + + } #end process + +} + diff --git a/Private/SetConfigurationData.ps1 b/Private/SetConfigurationData.ps1 new file mode 100644 index 00000000..93efdeb4 --- /dev/null +++ b/Private/SetConfigurationData.ps1 @@ -0,0 +1,27 @@ +function SetConfigurationData { + +<# + .SYNOPSIS + Saves lab configuration data. +#> + [CmdletBinding(SupportsShouldProcess)] + [OutputType([System.Management.Automation.PSCustomObject])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + param ( + [Parameter(Mandatory)] + [ValidateSet('Host','VM','Media','CustomMedia')] + [System.String] $Configuration, + + [Parameter(Mandatory, ValueFromPipeline)] + [System.Object] $InputObject + ) + process { + + $configurationPath = ResolveConfigurationDataPath -Configuration $Configuration; + [ref] $null = NewDirectory -Path (Split-Path -Path $configurationPath -Parent) -Verbose:$false; + Set-Content -Path $configurationPath -Value (ConvertTo-Json -InputObject $InputObject -Depth 5) -Force -Confirm:$false; + + } #end process + +} + diff --git a/Private/SetDiskImageBootVolume.ps1 b/Private/SetDiskImageBootVolume.ps1 new file mode 100644 index 00000000..6e3b5b0a --- /dev/null +++ b/Private/SetDiskImageBootVolume.ps1 @@ -0,0 +1,38 @@ +function SetDiskImageBootVolume { + +<# + .SYNOPSIS + Sets the boot volume of a mounted disk image. +#> + [CmdletBinding()] + param ( + ## Mounted VHD(X) Operating System disk image + [Parameter(Mandatory)] + [ValidateNotNull()] + [System.Object] $Vhd, # Microsoft.Vhd.PowerShell.VirtualHardDisk + + ## Disk image partition scheme + [Parameter(Mandatory)] + [ValidateSet('MBR','GPT')] + [System.String] $PartitionStyle + ) + process { + + switch ($PartitionStyle) { + + 'MBR' { + + SetDiskImageBootVolumeMbr -Vhd $Vhd; + break; + } + 'GPT' { + + SetDiskImageBootVolumeGpt -Vhd $Vhd; + break; + } + } #end switch + + } #end process + +} + diff --git a/Private/SetDiskImageBootVolumeGpt.ps1 b/Private/SetDiskImageBootVolumeGpt.ps1 new file mode 100644 index 00000000..d72790a6 --- /dev/null +++ b/Private/SetDiskImageBootVolumeGpt.ps1 @@ -0,0 +1,36 @@ +function SetDiskImageBootVolumeGpt { + +<# + .SYNOPSIS + Configure/repair MBR boot volume +#> + [CmdletBinding()] + param ( + ## Mounted VHD(X) Operating System disk image + [Parameter(Mandatory)] + [ValidateNotNull()] + [System.Object] $Vhd # Microsoft.Vhd.PowerShell.VirtualHardDisk + ) + process { + + $bcdBootExe = 'bcdboot.exe'; + $imageName = [System.IO.Path]::GetFileNameWithoutExtension($Vhd.Path); + + $systemPartitionDriveLetter = GetDiskImageDriveLetter -DiskImage $Vhd -PartitionType 'System'; + $osPartitionDriveLetter = GetDiskImageDriveLetter -DiskImage $Vhd -PartitionType 'Basic'; + WriteVerbose ($localized.RepairingBootVolume -f $osPartitionDriveLetter); + $bcdBootArgs = @( + ('{0}:\Windows' -f $osPartitionDriveLetter), # Path to source Windows boot files + ('/s {0}:\' -f $systemPartitionDriveLetter), # Specifies the volume letter of the drive to create the \BOOT folder on. + '/v' # Enabled verbose logging. + '/f UEFI' # Specifies the firmware type of the target system partition + ) + InvokeExecutable -Path $bcdBootExe -Arguments $bcdBootArgs -LogName ('{0}-BootEdit.log' -f $imageName); + ## Clean up and remove drive access path + Remove-PSDrive -Name $osPartitionDriveLetter -PSProvider FileSystem -ErrorAction Ignore; + [ref] $null = Get-PSDrive; + + } #end process + +} + diff --git a/Private/SetDiskImageBootVolumeMbr.ps1 b/Private/SetDiskImageBootVolumeMbr.ps1 new file mode 100644 index 00000000..77e1c65e --- /dev/null +++ b/Private/SetDiskImageBootVolumeMbr.ps1 @@ -0,0 +1,51 @@ +function SetDiskImageBootVolumeMbr { + +<# + .SYNOPSIS + Configure/repair MBR boot volume +#> + [CmdletBinding()] + param ( + ## Mounted VHD(X) Operating System disk image + [Parameter(Mandatory)] + [ValidateNotNull()] + [System.Object] $Vhd # Microsoft.Vhd.PowerShell.VirtualHardDisk + ) + process { + + $bcdBootExe = 'bcdboot.exe'; + $bcdEditExe = 'bcdedit.exe'; + $imageName = [System.IO.Path]::GetFileNameWithoutExtension($Vhd.Path); + + $osPartitionDriveLetter = GetDiskImageDriveLetter -DiskImage $Vhd -PartitionType 'IFS'; + WriteVerbose ($localized.RepairingBootVolume -f $osPartitionDriveLetter); + $bcdBootArgs = @( + ('{0}:\Windows' -f $osPartitionDriveLetter), # Path to source Windows boot files + ('/s {0}:\' -f $osPartitionDriveLetter), # Volume to create the \BOOT folder on. + '/v' # Enable verbose logging. + '/f BIOS' # Firmware type of the target system partition + ) + InvokeExecutable -Path $bcdBootExe -Arguments $bcdBootArgs -LogName ('{0}-BootEdit.log' -f $imageName); + + $bootmgrDeviceArgs = @( + ('/store {0}:\boot\bcd' -f $osPartitionDriveLetter), + '/set {bootmgr} device locate' + ); + InvokeExecutable -Path $bcdEditExe -Arguments $bootmgrDeviceArgs -LogName ('{0}-BootmgrDevice.log' -f $imageName); + + $defaultDeviceArgs = @( + ('/store {0}:\boot\bcd' -f $osPartitionDriveLetter), + '/set {default} device locate' + ); + InvokeExecutable -Path $bcdEditExe -Arguments $defaultDeviceArgs -LogName ('{0}-DefaultDevice.log' -f $imageName); + + $defaultOsDeviceArgs = @( + ('/store {0}:\boot\bcd' -f $osPartitionDriveLetter), + '/set {default} osdevice locate' + ); + InvokeExecutable -Path $bcdEditExe -Arguments $defaultOsDeviceArgs -LogName ('{0}-DefaultOsDevice.log' -f $imageName); + + } #end process + +} + diff --git a/Private/SetDscResource.ps1 b/Private/SetDscResource.ps1 new file mode 100644 index 00000000..2735e8da --- /dev/null +++ b/Private/SetDscResource.ps1 @@ -0,0 +1,40 @@ +function SetDscResource { + +<# + .SYNOPSIS + Runs the ResourceName DSC resource ensuring it's in the desired state. + .DESCRIPTION + The SetDscResource cmdlet invokes the target $ResourceName\Set-TargetResource function using the supplied + $Parameters hastable. +#> + [CmdletBinding()] + param ( + ## Name of the DSC resource to invoke + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $ResourceName, + + ## The DSC resource's Set-TargetResource parameter hashtable + [Parameter(Mandatory)] + [System.Collections.Hashtable] $Parameters + ) + process { + + $setTargetResourceCommand = 'Set-{0}TargetResource' -f $ResourceName; + Write-Debug ($localized.InvokingCommand -f $setTargetResourceCommand); + $Parameters.Keys | ForEach-Object { + Write-Debug -Message ($localized.CommandParameter -f $_, $Parameters.$_); + } + + try { + $setDscResourceResult = & $setTargetResourceCommand @Parameters; + } + catch { + WriteWarning -Message ($localized.DscResourceFailedError -f $setTargetResourceCommand, $_); + } + + return $setDscResourceResult; + + } #end process + +} + diff --git a/Private/SetLabSwitch.ps1 b/Private/SetLabSwitch.ps1 new file mode 100644 index 00000000..d4f9d436 --- /dev/null +++ b/Private/SetLabSwitch.ps1 @@ -0,0 +1,30 @@ +function SetLabSwitch { + +<# + .SYNOPSIS + Sets/invokes a virtual network switch configuration. + .DESCRIPTION + Sets/invokes a virtual network switch configuration using the xVMSwitch DSC resource. +#> + [CmdletBinding()] + param ( + ## Switch Id/Name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Name, + + ## PowerShell DSC configuration document (.psd1) containing lab metadata. + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + $networkSwitch = ResolveLabSwitch @PSBoundParameters; + if (($null -eq $networkSwitch.IsExisting) -or ($networkSwitch.IsExisting -eq $false)) { + ImportDscResource -ModuleName xHyper-V -ResourceName MSFT_xVMSwitch -Prefix VMSwitch; + [ref] $null = InvokeDscResource -ResourceName VMSwitch -Parameters $networkSwitch; + } + } #end process + +} + diff --git a/Private/SetLabVMDisk.ps1 b/Private/SetLabVMDisk.ps1 new file mode 100644 index 00000000..3b29ba33 --- /dev/null +++ b/Private/SetLabVMDisk.ps1 @@ -0,0 +1,44 @@ +function SetLabVMDisk { + +<# + .SYNOPSIS + Sets a lab VM disk file (VHDX) configuration. + .DESCRIPTION + Configures a VM disk configuration using the xVHD DSC resource. +#> + [CmdletBinding()] + param ( + ## VM/Node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Name, + + ## Media Id + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Media, + + ## Lab DSC configuration data + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + $hostDefaults = GetConfigurationData -Configuration Host; + if ($PSBoundParameters.ContainsKey('ConfigurationData')) { + $image = Get-LabImage -Id $Media -ConfigurationData $ConfigurationData -ErrorAction Stop; + } + else { + $image = Get-LabImage -Id $Media -ErrorAction Stop; + } + $vhd = @{ + Name = $Name; + Path = $hostDefaults.DifferencingVhdPath; + ParentPath = $image.ImagePath; + Generation = $image.Generation; + } + ImportDscResource -ModuleName xHyper-V -ResourceName MSFT_xVHD -Prefix VHD; + [ref] $null = InvokeDscResource -ResourceName VHD -Parameters $vhd; + } #end process + +} + diff --git a/Private/SetLabVMDiskFile.ps1 b/Private/SetLabVMDiskFile.ps1 new file mode 100644 index 00000000..9d78d6b0 --- /dev/null +++ b/Private/SetLabVMDiskFile.ps1 @@ -0,0 +1,76 @@ +function SetLabVMDiskFile { + +<# + .SYNOPSIS + Copies Lability files to a node's VHD(X) file. + .DESCRIPTION + Copies the Lability bootstrap file, SetupComplete.cmd, unattend.xml, + mof files, certificates and PowerShell/DSC resource modules to a + VHD(X) file. +#> + [CmdletBinding()] + param ( + ## Lab VM/Node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $NodeName, + + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Local administrator password of the VM + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.Management.Automation.PSCredential] + [System.Management.Automation.CredentialAttribute()] + $Credential, + + ## Lab VM/Node DSC .mof and .meta.mof configuration files + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Path, + + ## Custom bootstrap script + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $CustomBootstrap, + + ## CoreCLR + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $CoreCLR, + + ## Media-defined product key + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $ProductKey + ) + process { + + ## Temporarily disable Windows Explorer popup disk initialization and format notifications + ## http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/29/use-powershell-to-initialize-raw-disks-and-partition-and-format-volumes.aspx + Stop-Service -Name 'ShellHWDetection' -Force -ErrorAction Ignore; + + $node = ResolveLabVMProperties -NodeName $NodeName -ConfigurationData $ConfigurationData -ErrorAction Stop; + $vhdPath = ResolveLabVMDiskPath -Name $node.NodeDisplayName; + + WriteVerbose -Message ($localized.MountingDiskImage -f $VhdPath); + $vhd = Mount-Vhd -Path $vhdPath -Passthru; + [ref] $null = Get-PSDrive; + $vhdDriveLetter = Get-Partition -DiskNumber $vhd.DiskNumber | + Where-Object DriveLetter | + Select-Object -Last 1 -ExpandProperty DriveLetter; + Start-Service -Name 'ShellHWDetection'; + + SetLabVMDiskFileResource @PSBoundParameters -VhdDriveLetter $vhdDriveLetter; + SetLabVMDiskFileBootstrap @PSBoundParameters -VhdDriveLetter $vhdDriveLetter; + SetLabVMDiskFileUnattendXml @PSBoundParameters -VhdDriveLetter $vhdDriveLetter; + SetLabVMDiskFileMof @PSBoundParameters -VhdDriveLetter $vhdDriveLetter; + SetLabVMDiskFileCertificate @PSBoundParameters -VhdDriveLetter $vhdDriveLetter; + SetLabVMDiskFileModule @PSBoundParameters -VhdDriveLetter $vhdDriveLetter; + + WriteVerbose -Message ($localized.DismountingDiskImage -f $VhdPath); + Dismount-Vhd -Path $VhdPath; + + } #end process + +} + diff --git a/Private/SetLabVMDiskFileBootstrap.ps1 b/Private/SetLabVMDiskFileBootstrap.ps1 new file mode 100644 index 00000000..6e6c98a6 --- /dev/null +++ b/Private/SetLabVMDiskFileBootstrap.ps1 @@ -0,0 +1,47 @@ +function SetLabVMDiskFileBootstrap { + +<# + .SYNOPSIS + Copies a the Lability bootstrap file to a VHD(X) file. +#> + + [CmdletBinding()] + param ( + ## Mounted VHD path + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $VhdDriveLetter, + + ## Custom bootstrap script + [Parameter(ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.String] $CustomBootstrap, + + ## CoreCLR + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $CoreCLR, + + ## Catch all to enable splatting @PSBoundParameters + [Parameter(ValueFromRemainingArguments)] + $RemainingArguments + ) + process { + + $bootStrapPath = '{0}:\BootStrap' -f $VhdDriveLetter; + WriteVerbose -Message ($localized.AddingBootStrapFile -f $bootStrapPath); + if ($CustomBootStrap) { + + SetBootStrap -Path $bootStrapPath -CustomBootStrap $CustomBootStrap -CoreCLR:$CoreCLR; + } + else { + + SetBootStrap -Path $bootStrapPath -CoreCLR:$CoreCLR; + } + + $setupCompleteCmdPath = '{0}:\Windows\Setup\Scripts' -f $vhdDriveLetter; + WriteVerbose -Message ($localized.AddingSetupCompleteCmdFile -f $setupCompleteCmdPath); + SetSetupCompleteCmd -Path $setupCompleteCmdPath -CoreCLR:$CoreCLR; + + } #end process + +} + diff --git a/Private/SetLabVMDiskFileCertificate.ps1 b/Private/SetLabVMDiskFileCertificate.ps1 new file mode 100644 index 00000000..7d45d46a --- /dev/null +++ b/Private/SetLabVMDiskFileCertificate.ps1 @@ -0,0 +1,52 @@ +function SetLabVMDiskFileCertificate { + +<# + .SYNOPSIS + Copies a node's certificate(s) to a VHD(X) file. +#> + [CmdletBinding()] + param ( + ## Lab VM/Node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $NodeName, + + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Mounted VHD path + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $VhdDriveLetter, + + ## Catch all to enable splatting @PSBoundParameters + [Parameter(ValueFromRemainingArguments)] + $RemainingArguments + ) + process { + + $node = ResolveLabVMProperties -NodeName $NodeName -ConfigurationData $ConfigurationData -ErrorAction Stop; + $bootStrapPath = '{0}:\BootStrap' -f $VhdDriveLetter; + + if (-not [System.String]::IsNullOrWhitespace($node.ClientCertificatePath)) { + + $destinationCertificatePath = Join-Path -Path $bootStrapPath -ChildPath 'LabClient.pfx'; + $expandedClientCertificatePath = [System.Environment]::ExpandEnvironmentVariables($node.ClientCertificatePath); + WriteVerbose -Message ($localized.AddingCertificate -f 'Client', $destinationCertificatePath); + Copy-Item -Path $expandedClientCertificatePath -Destination $destinationCertificatePath -Force; + } + + if (-not [System.String]::IsNullOrWhitespace($node.RootCertificatePath)) { + + $destinationCertificatePath = Join-Path -Path $bootStrapPath -ChildPath 'LabRoot.cer'; + $expandedRootCertificatePath = [System.Environment]::ExpandEnvironmentVariables($node.RootCertificatePath); + WriteVerbose -Message ($localized.AddingCertificate -f 'Root', $destinationCertificatePath); + Copy-Item -Path $expandedRootCertificatePath -Destination $destinationCertificatePath -Force; + } + + } #end process + +} + diff --git a/Private/SetLabVMDiskFileModule.ps1 b/Private/SetLabVMDiskFileModule.ps1 new file mode 100644 index 00000000..6dd92e0f --- /dev/null +++ b/Private/SetLabVMDiskFileModule.ps1 @@ -0,0 +1,69 @@ +function SetLabVMDiskFileModule { + +<# + .SYNOPSIS + Copies a node's PowerShell and DSC resource modules to a VHD(X) file. +#> + + [CmdletBinding()] + param ( + ## Lab VM/Node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $NodeName, + + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Mounted VHD path + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $VhdDriveLetter, + + ## Catch all to enable splatting @PSBoundParameters + [Parameter(ValueFromRemainingArguments)] + $RemainingArguments + ) + process { + + ## Resolve the localized %ProgramFiles% directory + $programFilesPath = '{0}\WindowsPowershell\Modules' -f (ResolveProgramFilesFolder -Drive $VhdDriveLetter).FullName + + ## Add the DSC resource modules + $resolveLabDscModuleParams =@{ + ConfigurationData = $ConfigurationData; + NodeName = $NodeName; + ModuleType = 'DscResource'; + } + $setLabVMDiskDscModuleParams = @{ + Module = ResolveLabModule @resolveLabDscModuleParams; + DestinationPath = $programFilesPath; + } + if ($null -ne $setLabVMDiskDscModuleParams['Module']) { + + WriteVerbose -Message ($localized.AddingDSCResourceModules -f $programFilesPath); + SetLabVMDiskModule @setLabVMDiskDscModuleParams; + } + + ## Add the PowerShell resource modules + $resolveLabPowerShellModuleParams =@{ + ConfigurationData = $ConfigurationData; + NodeName = $NodeName; + ModuleType = 'Module'; + } + $setLabVMDiskPowerShellModuleParams = @{ + Module = ResolveLabModule @resolveLabPowerShellModuleParams; + DestinationPath = $programFilesPath; + } + if ($null -ne $setLabVMDiskPowerShellModuleParams['Module']) { + + WriteVerbose -Message ($localized.AddingPowerShellModules -f $programFilesPath); + SetLabVMDiskModule @setLabVMDiskPowerShellModuleParams; + } + + } #end process + +} + diff --git a/Private/SetLabVMDiskFileMof.ps1 b/Private/SetLabVMDiskFileMof.ps1 new file mode 100644 index 00000000..7ab1ef1c --- /dev/null +++ b/Private/SetLabVMDiskFileMof.ps1 @@ -0,0 +1,53 @@ +function SetLabVMDiskFileMof { + +<# + .SYNOPSIS + Copies a node's mof files to a VHD(X) file. +#> + [CmdletBinding()] + param ( + ## Lab VM/Node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $NodeName, + + ## Lab VM/Node DSC .mof and .meta.mof configuration files + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Path, + + ## Mounted VHD path + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $VhdDriveLetter, + + ## Catch all to enable splatting @PSBoundParameters + [Parameter(ValueFromRemainingArguments)] + $RemainingArguments + ) + process { + + $bootStrapPath = '{0}:\BootStrap' -f $VhdDriveLetter; + $mofPath = Join-Path -Path $Path -ChildPath ('{0}.mof' -f $NodeName); + + if (-not (Test-Path -Path $mofPath)) { + + WriteWarning -Message ($localized.CannotLocateMofFileError -f $mofPath); + } + else { + + $destinationMofPath = Join-Path -Path $bootStrapPath -ChildPath 'localhost.mof'; + WriteVerbose -Message ($localized.AddingDscConfiguration -f $destinationMofPath); + Copy-Item -Path $mofPath -Destination $destinationMofPath -Force -ErrorAction Stop; + } + + $metaMofPath = Join-Path -Path $Path -ChildPath ('{0}.meta.mof' -f $NodeName); + if (Test-Path -Path $metaMofPath -PathType Leaf) { + + $destinationMetaMofPath = Join-Path -Path $bootStrapPath -ChildPath 'localhost.meta.mof'; + WriteVerbose -Message ($localized.AddingDscConfiguration -f $destinationMetaMofPath); + Copy-Item -Path $metaMofPath -Destination $destinationMetaMofPath -Force; + } + + } #end process + +} + diff --git a/Private/SetLabVMDiskFileResource.ps1 b/Private/SetLabVMDiskFileResource.ps1 new file mode 100644 index 00000000..e07621f8 --- /dev/null +++ b/Private/SetLabVMDiskFileResource.ps1 @@ -0,0 +1,43 @@ +function SetLabVMDiskFileResource { + +<# + .SYNOPSIS + Copies a node's defined resources to VHD(X) file. +#> + [CmdletBinding()] + param ( + ## Lab VM/Node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $NodeName, + + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Mounted VHD path + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $VhdDriveLetter, + + ## Catch all to enable splatting @PSBoundParameters + [Parameter(ValueFromRemainingArguments)] + $RemainingArguments + ) + process { + + $hostDefaults = GetConfigurationData -Configuration Host; + $resourceDestinationPath = '{0}:\{1}' -f $vhdDriveLetter, $hostDefaults.ResourceShareName; + $expandLabResourceParams = @{ + ConfigurationData = $ConfigurationData; + Name = $NodeName; + DestinationPath = $resourceDestinationPath; + } + WriteVerbose -Message ($localized.AddingVMResource -f 'VM'); + ExpandLabResource @expandLabResourceParams; + + } #end process + +} + diff --git a/Private/SetLabVMDiskFileUnattendXml.ps1 b/Private/SetLabVMDiskFileUnattendXml.ps1 new file mode 100644 index 00000000..ed19c464 --- /dev/null +++ b/Private/SetLabVMDiskFileUnattendXml.ps1 @@ -0,0 +1,74 @@ +function SetLabVMDiskFileUnattendXml { + +<# + .SYNOPSIS + Copies a node's unattent.xml to a VHD(X) file. +#> + [CmdletBinding()] + param ( + ## Lab VM/Node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $NodeName, + + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Mounted VHD path + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $VhdDriveLetter, + + ## Local administrator password of the VM + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.Management.Automation.PSCredential] + [System.Management.Automation.CredentialAttribute()] + $Credential, + + ## Media-defined product key + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $ProductKey, + + ## Catch all to enable splatting @PSBoundParameters + [Parameter(ValueFromRemainingArguments)] + $RemainingArguments + ) + process { + + $node = ResolveLabVMProperties -NodeName $NodeName -ConfigurationData $ConfigurationData -ErrorAction Stop; + + ## Create Unattend.xml + $newUnattendXmlParams = @{ + ComputerName = $node.NodeName; + Credential = $Credential; + InputLocale = $node.InputLocale; + SystemLocale = $node.SystemLocale; + UserLocale = $node.UserLocale; + UILanguage = 'en-US'; + Timezone = $node.Timezone; + RegisteredOwner = $node.RegisteredOwner; + RegisteredOrganization = $node.RegisteredOrganization; + } + WriteVerbose -Message $localized.SettingAdministratorPassword; + + ## Node defined Product Key takes preference over key defined in the media definition + if ($node.CustomData.ProductKey) { + + $newUnattendXmlParams['ProductKey'] = $node.CustomData.ProductKey; + } + elseif ($PSBoundParameters.ContainsKey('ProductKey')) { + + $newUnattendXmlParams['ProductKey'] = $ProductKey; + } + + ## TODO: We probably need to be localise the \Windows\ (%ProgramFiles% has been done) directory? + $unattendXmlPath = '{0}:\Windows\System32\Sysprep\Unattend.xml' -f $VhdDriveLetter; + WriteVerbose -Message ($localized.AddingUnattendXmlFile -f $unattendXmlPath); + [ref] $null = SetUnattendXml @newUnattendXmlParams -Path $unattendXmlPath; + + } #end process + +} + diff --git a/Private/SetLabVMDiskModule.ps1 b/Private/SetLabVMDiskModule.ps1 new file mode 100644 index 00000000..8a05d57a --- /dev/null +++ b/Private/SetLabVMDiskModule.ps1 @@ -0,0 +1,37 @@ +function SetLabVMDiskModule { + +<# + .SYNOPSIS + Downloads (if required) PowerShell/DSC modules and expands + them to the destination path specified. +#> + [CmdletBinding()] + param ( + ## Lability PowerShell modules/DSC resource hashtable + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.Collections.Hashtable[]] $Module, + + ## The target VHDX modules path + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $DestinationPath, + + ## Force a download of the module(s) even if they already exist in the cache. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force, + + ## Removes existing target module directory (if present) + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Clean + ) + process { + + ## Invokes the module download if not cached, and returns the source + [ref] $null = InvokeModuleCacheDownload -Module $Module -Force:$Force + ## Expand the modules into the VHDX file + [ref] $null = ExpandModuleCache -Module $Module -DestinationPath $DestinationPath -Clean:$Clean; + + } #end process + +} + diff --git a/Private/SetLabVirtualMachine.ps1 b/Private/SetLabVirtualMachine.ps1 new file mode 100644 index 00000000..75e87185 --- /dev/null +++ b/Private/SetLabVirtualMachine.ps1 @@ -0,0 +1,54 @@ +function SetLabVirtualMachine { + +<# + .SYNOPSIS + Invokes the current configuration a virtual machine. + .DESCRIPTION + Invokes/sets a virtual machine configuration using the xVMHyperV DSC resource. +#> + param ( + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] + [System.String] $Name, + + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] + [System.String[]] $SwitchName, + + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] + [System.String] $Media, + + [Parameter(Mandatory)] + [System.UInt64] $StartupMemory, + + [Parameter(Mandatory)] + [System.UInt64] $MinimumMemory, + + [Parameter(Mandatory)] + [System.UInt64] $MaximumMemory, + + [Parameter(Mandatory)] + [System.Int32] $ProcessorCount, + + [Parameter()] [AllowNull()] + [System.String[]] $MACAddress, + + [Parameter()] + [System.Boolean] $SecureBoot, + + [Parameter()] + [System.Boolean] $GuestIntegrationServices, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + ## Resolve the xVMHyperV resource parameters + $vmHyperVParams = GetVirtualMachineProperties @PSBoundParameters; + ImportDscResource -ModuleName xHyper-V -ResourceName MSFT_xVMHyperV -Prefix VM; + InvokeDscResource -ResourceName VM -Parameters $vmHyperVParams # -ErrorAction SilentlyContinue; + } #end process + +} + diff --git a/Private/SetResourceChecksum.ps1 b/Private/SetResourceChecksum.ps1 new file mode 100644 index 00000000..233f8f08 --- /dev/null +++ b/Private/SetResourceChecksum.ps1 @@ -0,0 +1,25 @@ +function SetResourceChecksum { + +<# + .SYNOPSIS + Creates a resource's checksum file. +#> + param ( + ## Path of file to create the checksum of + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $Path + ) + process { + + $checksumPath = '{0}.checksum' -f $Path; + ## As it can take a long time to calculate the checksum, write it out to disk for future reference + WriteVerbose ($localized.CalculatingResourceChecksum -f $checksumPath); + $fileHash = Get-FileHash -Path $Path -Algorithm MD5 -ErrorAction Stop | Select-Object -ExpandProperty Hash; + WriteVerbose ($localized.WritingResourceChecksum -f $fileHash, $checksumPath); + $fileHash | Set-Content -Path $checksumPath -Force; + } + + +} + diff --git a/Private/SetResourceDownload.ps1 b/Private/SetResourceDownload.ps1 new file mode 100644 index 00000000..0924d4c2 --- /dev/null +++ b/Private/SetResourceDownload.ps1 @@ -0,0 +1,54 @@ +function SetResourceDownload { + +<# + .SYNOPSIS + Downloads a (web) resource and creates a MD5 checksum. +#> + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Uri, + + [Parameter(ValueFromPipelineByPropertyName)] + [AllowNull()] + [System.String] $Checksum, + + [Parameter(ValueFromPipelineByPropertyName)] + [System.UInt32] $BufferSize = 64KB, + + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $NoChecksum + ##TODO: Support Headers and UserAgent + ) + begin { + + $parentDestinationPath = Split-Path -Path $DestinationPath -Parent; + [ref] $null = NewDirectory -Path $parentDestinationPath; + + } + process { + + if (-not $PSBoundParameters.ContainsKey('BufferSize')) { + $systemUri = New-Object -TypeName System.Uri -ArgumentList @($uri); + if ($systemUri.IsFile) { + $BufferSize = 1MB; + } + } + + WriteVerbose ($localized.DownloadingResource -f $Uri, $DestinationPath); + InvokeWebClientDownload -DestinationPath $DestinationPath -Uri $Uri -BufferSize $BufferSize; + + if ($NoChecksum -eq $false) { + ## Create the checksum file for future reference + [ref] $null = SetResourceChecksum -Path $DestinationPath; + } + + } #end process + +} + diff --git a/Private/SetSetupCompleteCmd.ps1 b/Private/SetSetupCompleteCmd.ps1 new file mode 100644 index 00000000..b3177720 --- /dev/null +++ b/Private/SetSetupCompleteCmd.ps1 @@ -0,0 +1,41 @@ +function SetSetupCompleteCmd { + +<# + .SYNOPSIS + Creates a lab BootStrap script block. +#> + [CmdletBinding()] + [OutputType([System.Management.Automation.ScriptBlock])] + param ( + ## Destination SetupComplete.cmd directory path. + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $Path, + + ## Is a CoreCLR VM. The bootstrapping via Powershell.exe in the CoreCLR doesn't work in its current format, i.e. with Nano Server + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $CoreCLR + ) + process { + + [ref] $null = NewDirectory -Path $Path; + $setupCompletePath = Join-Path -Path $Path -ChildPath 'SetupComplete.cmd'; + if ($CoreCLR) { + + WriteVerbose -Message $localized.UsingCoreCLRSetupComplete; + $setupCompleteCmd = @" +schtasks /create /tn "BootStrap" /tr "cmd.exe /c """Powershell.exe -Command %SYSTEMDRIVE%\BootStrap\BootStrap.ps1""" > %SYSTEMDRIVE%\BootStrap\BootStrap.log" /sc "Once" /sd "01/01/2099" /st "00:00" /ru "System" +schtasks /run /tn "BootStrap" +"@ + } + else { + + WriteVerbose -Message $localized.UsingDefaultSetupComplete; + $setupCompleteCmd = 'Powershell.exe -NoProfile -ExecutionPolicy Bypass -NonInteractive -File "%SYSTEMDRIVE%\BootStrap\BootStrap.ps1"'; + } + Set-Content -Path $setupCompletePath -Value $setupCompleteCmd -Encoding Ascii -Force; + + } #end process + +} + diff --git a/Private/SetUnattendXml.ps1 b/Private/SetUnattendXml.ps1 new file mode 100644 index 00000000..b7708b22 --- /dev/null +++ b/Private/SetUnattendXml.ps1 @@ -0,0 +1,75 @@ +function SetUnattendXml { + +<# + .SYNOPSIS + Creates a Windows unattended installation file and saves to disk. +#> + [CmdletBinding()] + [OutputType([System.Xml.XmlDocument])] + param ( + # Filename/path to save the unattend file as + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $Path, + + # Local Administrator Password + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.Management.Automation.PSCredential] + [System.Management.Automation.CredentialAttribute()] + $Credential, + + # Computer name + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $ComputerName, + + # Product Key + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^[A-Z0-9]{5,5}-[A-Z0-9]{5,5}-[A-Z0-9]{5,5}-[A-Z0-9]{5,5}-[A-Z0-9]{5,5}$')] + [System.String] $ProductKey, + + # Input Locale + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $InputLocale = 'en-US', + + # System Locale + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $SystemLocale = 'en-US', + + # User Locale + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $UserLocale = 'en-US', + + # UI Language + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $UILanguage = 'en-US', + + # Timezone + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Timezone, ##TODO: Validate timezones? + + # Registered Owner + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.String] $RegisteredOwner = 'Virtual Engine', + + # Registered Organization + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.String] $RegisteredOrganization = 'Virtual Engine', + + # TODO: Execute synchronous commands during OOBE pass as they only currently run during the Specialize pass + ## Array of hashtables with Description, Order and Path keys + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable[]] $ExecuteCommand + ) + process { + + [ref] $null = $PSBoundParameters.Remove('Path'); + $unattendXml = NewUnattendXml @PSBoundParameters; + $resolvedPath = ResolvePathEx -Path $Path; + return $unattendXml.Save($resolvedPath); + + } #end process + +} + diff --git a/Private/TestComputerName.ps1 b/Private/TestComputerName.ps1 new file mode 100644 index 00000000..e94bd977 --- /dev/null +++ b/Private/TestComputerName.ps1 @@ -0,0 +1,23 @@ +function TestComputerName { + +<# + .SYNOPSIS + Validates a computer name is valid. +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + ## Source directory path + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $ComputerName + ) + process { + + $invalidMatch = '[~!@#\$%\^&\*\(\)=\+_\[\]{}\\\|;:.''",<>\/\?\s]'; + return ($ComputerName -inotmatch $invalidMatch); + + } + +} + diff --git a/Private/TestDscModule.ps1 b/Private/TestDscModule.ps1 new file mode 100644 index 00000000..7e326468 --- /dev/null +++ b/Private/TestDscModule.ps1 @@ -0,0 +1,25 @@ +function TestDscModule { + +<# + .SYNOPSIS + Tests whether the ResourceName of the specified ModuleName can be located on the system. +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + [Parameter(Mandatory)] + [System.String] $ModuleName, + + [Parameter()] + [System.String] $ResourceName, + + [Parameter()] [ValidateNotNullOrEmpty()] + [System.String] $MinimumVersion + ) + process { + if (GetDscModule @PSBoundParameters -ErrorAction SilentlyContinue) { return $true; } + else { return $false; } + } + +} + diff --git a/Private/TestDscResource.ps1 b/Private/TestDscResource.ps1 new file mode 100644 index 00000000..bb5bd640 --- /dev/null +++ b/Private/TestDscResource.ps1 @@ -0,0 +1,48 @@ +function TestDscResource { + +<# + .SYNOPSIS + Tests the ResourceName DSC resource to determine if it's in the desired state. + .DESCRIPTION + The TestDscResource cmdlet invokes the target $ResourceName\Test-TargetResource function using the supplied + $Parameters hastable. +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + ## Name of the DSC resource to test + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $ResourceName, + + ## The DSC resource's Test-TargetResource parameter hashtable + [Parameter(Mandatory)] + [System.Collections.Hashtable] $Parameters + ) + process { + + $testTargetResourceCommand = 'Test-{0}TargetResource' -f $ResourceName; + Write-Debug ($localized.InvokingCommand -f $testTargetResourceCommand); + $Parameters.Keys | ForEach-Object { + Write-Debug -Message ($localized.CommandParameter -f $_, $Parameters.$_); + } + + try { + $testDscResourceResult = & $testTargetResourceCommand @Parameters; + } + catch { + ## No point writing warnings as failures will occur, i.e. "VHD not found" + ## when a VM does not yet exist. + WriteWarning -Message ($localized.DscResourceFailedError -f $testTargetResourceCommand, $_); + $testDscResourceResult = $false; + } + + if (-not $testDscResourceResult) { + WriteVerbose ($localized.TestFailed -f $testTargetResourceCommand); + } + + return $testDscResourceResult; + + } #end process + +} + diff --git a/Private/TestDscResourceModule.ps1 b/Private/TestDscResourceModule.ps1 new file mode 100644 index 00000000..15d57c8a --- /dev/null +++ b/Private/TestDscResourceModule.ps1 @@ -0,0 +1,50 @@ +function TestDscResourceModule { + +<# + .SYNOPSIS + Tests whether the specified PowerShell module directory is a DSC resource. + .DESCRIPTION + The TestDscResourceModule determines whether the specified path is a PowerShell DSC resource module. This is + used to only copy DSC resources to a VM's VHD(X) file - not ALL modules! + .NOTES + THIS METHOD IS DEPRECATED IN FAVOUR OF THE NEW MODULE CACHE FUNCTIONALITY +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Path, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $ModuleName + ) + process { + + ## This module contains a \DSCResources folder, but we don't want to enumerate this! + if ($Path -notmatch "\\$($labDefaults.ModuleName)$") { + + Write-Debug -Message ('Testing for MOF-based DSC Resource ''{0}'' directory.' -f "$Path\DSCResources"); + if (Test-Path -Path "$Path\DSCResources" -PathType Container) { + ## We have a WMF 4.0/MOF DSC resource module + Write-Debug -Message ('Found MOF-based DSC resource ''{0}''.' -f $Path); + return $true; + } + + Write-Debug -Message ('Testing for Class-based DSC resource definition ''{0}''.' -f "$Path\$ModuleName.psm1"); + if (Test-Path -Path "$Path\$ModuleName.psm1") { + $psm1Content = Get-Content -Path "$Path\$ModuleName.psm1"; + ## If there's a .psm1 file, check if it's a class-based DSC resource + if ($psm1Content -imatch '^(\s*)\[DscResource\(\)\](\s*)$') { + ## File has a [DscResource()] declaration + Write-Debug -Message ('Found Class-based DSC resource ''{0}''.' -f $Path); + return $true; + } + } + } #end if this module + + return $false; + + } #end process + +} + diff --git a/Private/TestLabConfigurationMof.ps1 b/Private/TestLabConfigurationMof.ps1 new file mode 100644 index 00000000..89d6e4fc --- /dev/null +++ b/Private/TestLabConfigurationMof.ps1 @@ -0,0 +1,50 @@ +function TestLabConfigurationMof { + +<# + .SYNOPSIS + Checks for node MOF and meta MOF configuration files. +#> + [CmdletBinding()] + param ( + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Lab vm/node name + [Parameter(ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## Path to .MOF files created from the DSC configuration + [Parameter(ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.String] $Path = (GetLabHostDSCConfigurationPath), + + ## Ignores missing MOF file + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $SkipMofCheck + ) + process { + $Path = Resolve-Path -Path $Path -ErrorAction Stop; + $node = $ConfigurationData.AllNodes | Where-Object { $_.NodeName -eq $Name }; + + $mofPath = Join-Path -Path $Path -ChildPath ('{0}.mof' -f $node.NodeName); + WriteVerbose ($localized.CheckingForNodeFile -f $mofPath); + if (-not (Test-Path -Path $mofPath -PathType Leaf)) { + if ($SkipMofCheck) { + WriteWarning ($localized.CannotLocateMofFileError -f $mofPath) + } + else { + throw ($localized.CannotLocateMofFileError -f $mofPath); + } + } + + $metaMofPath = Join-Path -Path $Path -ChildPath ('{0}.meta.mof' -f $node.NodeName); + WriteVerbose ($localized.CheckingForNodeFile -f $metaMofPath); + if (-not (Test-Path -Path $metaMofPath -PathType Leaf)) { + WriteWarning ($localized.CannotLocateLCMFileWarning -f $metaMofPath); + } + } #end process + +} + diff --git a/Private/TestLabResourceIsLocal.ps1 b/Private/TestLabResourceIsLocal.ps1 new file mode 100644 index 00000000..093990d8 --- /dev/null +++ b/Private/TestLabResourceIsLocal.ps1 @@ -0,0 +1,68 @@ +function TestLabResourceIsLocal { + +<# + .SYNOPSIS + Test whether a lab resource is available locally +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + ## PowerShell DSC configuration document (.psd1) containing lab metadata. + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Lab resource Id to test. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ResourceId, + + ## Node's target resource folder + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $LocalResourcePath + ) + process { + + $resource = ResolveLabResource -ConfigurationData $ConfigurationData -ResourceId $ResourceId; + + if (($resource.Expand) -and ($resource.Expand -eq $true)) { + + ## Check the ResourceId folder is present + $resourcePath = Join-Path -Path $LocalResourcePath -ChildPath $resourceId; + $resourceExtension = [System.IO.Path]::GetExtension($resource.Filename); + + switch ($resourceExtension) { + '.iso' { + $isPresent = Test-Path -Path $resourcePath -PathType Container; + } + '.zip' { + $isPresent = Test-Path -Path $resourcePath -PathType Container; + } + default { + throw ($localized.ExpandNotSupportedError -f $resourceExtension); + } + } + } + else { + + $resourcePath = Join-Path -Path $LocalResourcePath -ChildPath $resource.Filename; + $isPresent = Test-Path -Path $resourcePath -PathType Leaf; + } + + if ($isPresent) { + + WriteVerbose -Message ($localized.ResourceFound -f $resourcePath); + return $true; + } + else { + + WriteVerbose -Message ($localized.ResourceNotFound -f $resourcePath); + return $false; + } + + } #end process + +} + diff --git a/Private/TestLabSwitch.ps1 b/Private/TestLabSwitch.ps1 new file mode 100644 index 00000000..b08fe404 --- /dev/null +++ b/Private/TestLabSwitch.ps1 @@ -0,0 +1,33 @@ +function TestLabSwitch { + +<# + .SYNOPSIS + Tests the current configuration a virtual network switch. + .DESCRIPTION + Tests a virtual network switch configuration using the xVMSwitch DSC resource. +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + ## Switch Id/Name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Name, + + ## PowerShell DSC configuration document (.psd1) containing lab metadata. + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + $networkSwitch = ResolveLabSwitch @PSBoundParameters; + if (($null -ne $networkSwitch.IsExisting) -and ($networkSwitch.IsExisting -eq $true)) { + ## The existing virtual switch may be of a type not supported by the DSC resource. + return $true; + } + ImportDscResource -ModuleName xHyper-V -ResourceName MSFT_xVMSwitch -Prefix VMSwitch; + return TestDscResource -ResourceName VMSwitch -Parameters $networkSwitch; + } #end process + +} + diff --git a/Private/TestLabVMDisk.ps1 b/Private/TestLabVMDisk.ps1 new file mode 100644 index 00000000..20e47bc1 --- /dev/null +++ b/Private/TestLabVMDisk.ps1 @@ -0,0 +1,47 @@ +function TestLabVMDisk { + +<# + .SYNOPSIS + Checks whether the lab virtual machine disk (VHDX) is present. +#> + [CmdletBinding()] + param ( + ## VM/node name + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $Name, + + ## Media Id + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Media, + + ## Lab DSC configuration data + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + $hostDefaults = GetConfigurationData -Configuration Host; + if ($PSBoundParameters.ContainsKey('ConfigurationData')) { + $image = Get-LabImage -Id $Media -ConfigurationData $ConfigurationData; + } + else { + $image = Get-LabImage -Id $Media; + } + $vhd = @{ + Name = $Name; + Path = $hostDefaults.DifferencingVhdPath; + ParentPath = $image.ImagePath; + Generation = $image.Generation; + } + if (-not $image) { + ## This only occurs when a parent image is not available (#104). + $vhd['MaximumSize'] = 136365211648; #127GB + $vhd['Generation'] = 'VHDX'; + } + ImportDscResource -ModuleName xHyper-V -ResourceName MSFT_xVHD -Prefix VHD; + TestDscResource -ResourceName VHD -Parameters $vhd; + } #end process + +} + diff --git a/Private/TestLabVirtualMachine.ps1 b/Private/TestLabVirtualMachine.ps1 new file mode 100644 index 00000000..13a59150 --- /dev/null +++ b/Private/TestLabVirtualMachine.ps1 @@ -0,0 +1,59 @@ +function TestLabVirtualMachine { + +<# + .SYNOPSIS + Tests the current configuration a virtual machine. + .DESCRIPTION + Tests the current configuration a virtual machine using the xVMHyperV DSC resource. +#> + param ( + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] + [System.String] $Name, + + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] + [System.String[]] $SwitchName, + + [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] + [System.String] $Media, + + [Parameter(Mandatory)] + [System.UInt64] $StartupMemory, + + [Parameter(Mandatory)] + [System.UInt64] $MinimumMemory, + + [Parameter(Mandatory)] + [System.UInt64] $MaximumMemory, + + [Parameter(Mandatory)] + [System.Int32] $ProcessorCount, + + [Parameter()] [AllowNull()] + [System.String[]] $MACAddress, + + [Parameter()] + [System.Boolean] $SecureBoot, + + [Parameter()] + [System.Boolean] $GuestIntegrationServices, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + $vmHyperVParams = GetVirtualMachineProperties @PSBoundParameters; + ImportDscResource -ModuleName xHyper-V -ResourceName MSFT_xVMHyperV -Prefix VM; + try { + ## xVMHyperV\Test-TargetResource throws if the VHD doesn't exist? + return (TestDscResource -ResourceName VM -Parameters $vmHyperVParams -ErrorAction SilentlyContinue); + } + catch { + return $false; + } + } #end process + +} + diff --git a/Private/TestModule.ps1 b/Private/TestModule.ps1 new file mode 100644 index 00000000..1be8eb82 --- /dev/null +++ b/Private/TestModule.ps1 @@ -0,0 +1,54 @@ +function TestModule { + +<# + .SYNOPSIS + Tests whether an exising PowerShell module meets the minimum or required version +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## The minimum version of the module required + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'MinimumVersion')] + [ValidateNotNullOrEmpty()] + [System.Version] $MinimumVersion, + + ## The exact version of the module required + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'RequiredVersion')] + [ValidateNotNullOrEmpty()] + [System.Version] $RequiredVersion, + + ## Catch all to be able to pass parameters via $PSBoundParameters + [Parameter(ValueFromRemainingArguments)] + $RemainingArguments + ) + process { + + $module = GetModule -Name $Name; + if ($module) { + + $testModuleVersionParams = @{ + ModulePath = $module.Path; + } + + if ($MinimumVersion) { + $testModuleVersionParams['MinimumVersion'] = $MinimumVersion; + } + + if ($RequiredVersion) { + $testModuleVersionParams['RequiredVersion'] = $RequiredVersion; + } + + return (TestModuleVersion @testModuleVersionParams); + } + else { + return $false; + } + + } #end process + +} + diff --git a/Private/TestModuleCache.ps1 b/Private/TestModuleCache.ps1 new file mode 100644 index 00000000..a5aee3bc --- /dev/null +++ b/Private/TestModuleCache.ps1 @@ -0,0 +1,77 @@ +function TestModuleCache { + +<# + .SYNOPSIS + Tests whether the requested PowerShell module is cached. +#> + [CmdletBinding(DefaultParameterSetName = 'Name')] + [OutputType([System.Boolean])] + param ( + ## PowerShell module/DSC resource module name + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Name, + + ## The minimum version of the module required + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [ValidateNotNullOrEmpty()] + [System.Version] $MinimumVersion, + + ## The exact version of the module required + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.Version] $RequiredVersion, + + ## GitHub repository owner + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Owner, + + ## GitHub repository branch + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Branch, + + ## Source Filesystem module path + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateNotNullOrEmpty()] + [System.String] $Path, + + ## Provider used to download the module + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Name')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameMinimum')] + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'NameRequired')] + [ValidateSet('PSGallery','GitHub','FileSystem')] + [System.String] $Provider, + + ## Lability PowerShell module info hashtable + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Module')] + [ValidateNotNullOrEmpty()] + [System.Collections.Hashtable] $Module, + + ## Catch all to be able to pass parameter via $PSBoundParameters + [Parameter(ValueFromRemainingArguments)] $RemainingArguments + ) + begin { + + ## Remove -RemainingArguments to stop it being passed on. + [ref] $null = $PSBoundParameters.Remove('RemainingArguments'); + + } + process { + + $moduleFileInfo = GetModuleCache @PSBoundParameters; + return ($null -ne $moduleFileInfo); + + } #end process + +} + diff --git a/Private/TestModuleVersion.ps1 b/Private/TestModuleVersion.ps1 new file mode 100644 index 00000000..579e888d --- /dev/null +++ b/Private/TestModuleVersion.ps1 @@ -0,0 +1,51 @@ +function TestModuleVersion { + +<# + .SYNOPSIS + Tests whether an exising PowerShell module meets the minimum or required version +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + ## Path to the module's manifest file + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ModulePath, + + ## The minimum version of the module required + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'MinimumVersion')] [ValidateNotNullOrEmpty()] + [ValidateNotNullOrEmpty()] + [System.Version] $MinimumVersion, + + ## The exact version of the module required + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'RequiredVersion')] + [ValidateNotNullOrEmpty()] + [System.Version] $RequiredVersion, + + ## Catch all to be able to pass parameters via $PSBoundParameters + [Parameter(ValueFromRemainingArguments)] $RemainingArguments + ) + process { + + try { + WriteVerbose -Message ($localized.QueryingModuleVersion -f [System.IO.Path]::GetFileNameWithoutExtension($ModulePath)); + #$moduleManifest = Test-ModuleManifest -Path $ModulePath -Verbose:$false; + $moduleManifest = ConvertToConfigurationData -ConfigurationData $ModulePath; + WriteVerbose -Message ($localized.ExistingModuleVersion -f $moduleManifest.ModuleVersion); + } + catch { + Write-Error "Oops $ModulePath" + } + + if ($PSCmdlet.ParameterSetName -eq 'MinimumVersion') { + return (($moduleManifest.ModuleVersion -as [System.Version]) -ge $MinimumVersion); + } + + elseif ($PSCmdlet.ParameterSetName -eq 'RequiredVersion') { + return (($moduleManifest.ModuleVersion -as [System.Version]) -eq $RequiredVersion); + } + + } #end process + +} + diff --git a/Private/TestResourceDownload.ps1 b/Private/TestResourceDownload.ps1 new file mode 100644 index 00000000..083bb3c7 --- /dev/null +++ b/Private/TestResourceDownload.ps1 @@ -0,0 +1,47 @@ +function TestResourceDownload { + +<# + .SYNOPSIS + Tests if a web resource has been downloaded and whether the MD5 checksum is correct. + .NOTES + Based upon https://github.com/iainbrighton/cRemoteFile/blob/master/DSCResources/VE_RemoteFile/VE_RemoteFile.ps1 +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Uri, + + [Parameter(ValueFromPipelineByPropertyName)] + [AllowNull()] + [System.String] $Checksum, + + [Parameter(ValueFromPipelineByPropertyName)] + [System.UInt32] $BufferSize = 64KB + ##TODO: Support Headers and UserAgent + ) + process { + + $resource = GetResourceDownload @PSBoundParameters; + if ([System.String]::IsNullOrEmpty($Checksum) -and (Test-Path -Path $DestinationPath -PathType Leaf)) { + WriteVerbose ($localized.ResourceChecksumNotSpecified -f $DestinationPath); + return $true; + } + elseif ($Checksum -eq $resource.Checksum) { + WriteVerbose ($localized.ResourceChecksumMatch -f $DestinationPath, $Checksum); + return $true; + } + else { + WriteVerbose ($localized.ResourceChecksumMismatch -f $DestinationPath, $Checksum); + return $false; + } + + } #end process + +} + diff --git a/Private/Tests/AddDiskImageHotfix.Functional.Tests.ps1 b/Private/Tests/AddDiskImageHotfix.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/AddDiskImageHotfix.Tests.ps1 b/Private/Tests/AddDiskImageHotfix.Tests.ps1 new file mode 100644 index 00000000..09bc90c2 --- /dev/null +++ b/Private/Tests/AddDiskImageHotfix.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'AddDiskImageHotfix Tests' { + + Context 'Parameters for AddDiskImageHotfix'{ + + It 'Has a Parameter called Id' { + $Function.Parameters.Keys.Contains('Id') | Should Be 'True' + } + It 'Id Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Id.Attributes.Mandatory | Should be 'True' + } + It 'Id Parameter is of String Type' { + $Function.Parameters.Id.ParameterType.FullName | Should be 'System.String' + } + It 'Id Parameter is member of ParameterSets' { + [String]$Function.Parameters.Id.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Id Parameter Position is defined correctly' { + [String]$Function.Parameters.Id.Attributes.Position | Should be '0' + } + It 'Does Id Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Id Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Id Parameter use advanced parameter Validation? ' { + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Id '{ + $function.Definition.Contains('.PARAMETER Id') | Should Be 'True' + } + It 'Has a Parameter called Vhd' { + $Function.Parameters.Keys.Contains('Vhd') | Should Be 'True' + } + It 'Vhd Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Vhd.Attributes.Mandatory | Should be 'True' + } + It 'Vhd Parameter is of Object Type' { + $Function.Parameters.Vhd.ParameterType.FullName | Should be 'System.Object' + } + It 'Vhd Parameter is member of ParameterSets' { + [String]$Function.Parameters.Vhd.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Vhd Parameter Position is defined correctly' { + [String]$Function.Parameters.Vhd.Attributes.Position | Should be '1' + } + It 'Does Vhd Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Vhd Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Vhd Parameter use advanced parameter Validation? ' { + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Vhd '{ + $function.Definition.Contains('.PARAMETER Vhd') | Should Be 'True' + } + It 'Has a Parameter called PartitionStyle' { + $Function.Parameters.Keys.Contains('PartitionStyle') | Should Be 'True' + } + It 'PartitionStyle Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.PartitionStyle.Attributes.Mandatory | Should be 'True' + } + It 'PartitionStyle Parameter is of String Type' { + $Function.Parameters.PartitionStyle.ParameterType.FullName | Should be 'System.String' + } + It 'PartitionStyle Parameter is member of ParameterSets' { + [String]$Function.Parameters.PartitionStyle.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'PartitionStyle Parameter Position is defined correctly' { + [String]$Function.Parameters.PartitionStyle.Attributes.Position | Should be '2' + } + It 'Does PartitionStyle Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.PartitionStyle.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does PartitionStyle Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.PartitionStyle.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does PartitionStyle Parameter use advanced parameter Validation? ' { + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for PartitionStyle '{ + $function.Definition.Contains('.PARAMETER PartitionStyle') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '3' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/AddDiskImagePackage.Functional.Tests.ps1 b/Private/Tests/AddDiskImagePackage.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/AddDiskImagePackage.Tests.ps1 b/Private/Tests/AddDiskImagePackage.Tests.ps1 new file mode 100644 index 00000000..e4401e8a --- /dev/null +++ b/Private/Tests/AddDiskImagePackage.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'AddDiskImagePackage Tests' { + + Context 'Parameters for AddDiskImagePackage'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '1' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '2' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/AddWindowsOptionalFeature.Functional.Tests.ps1 b/Private/Tests/AddWindowsOptionalFeature.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/AddWindowsOptionalFeature.Tests.ps1 b/Private/Tests/AddWindowsOptionalFeature.Tests.ps1 new file mode 100644 index 00000000..74961efa --- /dev/null +++ b/Private/Tests/AddWindowsOptionalFeature.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'AddWindowsOptionalFeature Tests' { + + Context 'Parameters for AddWindowsOptionalFeature'{ + + It 'Has a Parameter called ImagePath' { + $Function.Parameters.Keys.Contains('ImagePath') | Should Be 'True' + } + It 'ImagePath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ImagePath.Attributes.Mandatory | Should be 'True' + } + It 'ImagePath Parameter is of String Type' { + $Function.Parameters.ImagePath.ParameterType.FullName | Should be 'System.String' + } + It 'ImagePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ImagePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ImagePath Parameter Position is defined correctly' { + [String]$Function.Parameters.ImagePath.Attributes.Position | Should be '0' + } + It 'Does ImagePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ImagePath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ImagePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ImagePath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ImagePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ImagePath '{ + $function.Definition.Contains('.PARAMETER ImagePath') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '1' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called WindowsOptionalFeature' { + $Function.Parameters.Keys.Contains('WindowsOptionalFeature') | Should Be 'True' + } + It 'WindowsOptionalFeature Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.WindowsOptionalFeature.Attributes.Mandatory | Should be 'True' + } + It 'WindowsOptionalFeature Parameter is of String[] Type' { + $Function.Parameters.WindowsOptionalFeature.ParameterType.FullName | Should be 'System.String[]' + } + It 'WindowsOptionalFeature Parameter is member of ParameterSets' { + [String]$Function.Parameters.WindowsOptionalFeature.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'WindowsOptionalFeature Parameter Position is defined correctly' { + [String]$Function.Parameters.WindowsOptionalFeature.Attributes.Position | Should be '2' + } + It 'Does WindowsOptionalFeature Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.WindowsOptionalFeature.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does WindowsOptionalFeature Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.WindowsOptionalFeature.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does WindowsOptionalFeature Parameter use advanced parameter Validation? ' { + $Function.Parameters.WindowsOptionalFeature.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.WindowsOptionalFeature.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.WindowsOptionalFeature.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.WindowsOptionalFeature.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.WindowsOptionalFeature.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for WindowsOptionalFeature '{ + $function.Definition.Contains('.PARAMETER WindowsOptionalFeature') | Should Be 'True' + } + It 'Has a Parameter called LogPath' { + $Function.Parameters.Keys.Contains('LogPath') | Should Be 'True' + } + It 'LogPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.LogPath.Attributes.Mandatory | Should be 'False' + } + It 'LogPath Parameter is of String Type' { + $Function.Parameters.LogPath.ParameterType.FullName | Should be 'System.String' + } + It 'LogPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.LogPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'LogPath Parameter Position is defined correctly' { + [String]$Function.Parameters.LogPath.Attributes.Position | Should be '3' + } + It 'Does LogPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.LogPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does LogPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.LogPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does LogPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.LogPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.LogPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.LogPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.LogPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.LogPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for LogPath '{ + $function.Definition.Contains('.PARAMETER LogPath') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/AddWindowsPackage.Functional.Tests.ps1 b/Private/Tests/AddWindowsPackage.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/AddWindowsPackage.Tests.ps1 b/Private/Tests/AddWindowsPackage.Tests.ps1 new file mode 100644 index 00000000..8625dd20 --- /dev/null +++ b/Private/Tests/AddWindowsPackage.Tests.ps1 @@ -0,0 +1,190 @@ +Describe 'AddWindowsPackage Tests' { + + Context 'Parameters for AddWindowsPackage'{ + + It 'Has a Parameter called Package' { + $Function.Parameters.Keys.Contains('Package') | Should Be 'True' + } + It 'Package Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Package.Attributes.Mandatory | Should be 'True' + } + It 'Package Parameter is of String[] Type' { + $Function.Parameters.Package.ParameterType.FullName | Should be 'System.String[]' + } + It 'Package Parameter is member of ParameterSets' { + [String]$Function.Parameters.Package.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Package Parameter Position is defined correctly' { + [String]$Function.Parameters.Package.Attributes.Position | Should be '0' + } + It 'Does Package Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Package.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Package Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Package.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Package Parameter use advanced parameter Validation? ' { + $Function.Parameters.Package.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Package.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Package.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Package.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Package.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Package '{ + $function.Definition.Contains('.PARAMETER Package') | Should Be 'True' + } + It 'Has a Parameter called PackagePath' { + $Function.Parameters.Keys.Contains('PackagePath') | Should Be 'True' + } + It 'PackagePath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.PackagePath.Attributes.Mandatory | Should be 'True' + } + It 'PackagePath Parameter is of String Type' { + $Function.Parameters.PackagePath.ParameterType.FullName | Should be 'System.String' + } + It 'PackagePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.PackagePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'PackagePath Parameter Position is defined correctly' { + [String]$Function.Parameters.PackagePath.Attributes.Position | Should be '1' + } + It 'Does PackagePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.PackagePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does PackagePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.PackagePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does PackagePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.PackagePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.PackagePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.PackagePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.PackagePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.PackagePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for PackagePath '{ + $function.Definition.Contains('.PARAMETER PackagePath') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '2' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called PackageLocale' { + $Function.Parameters.Keys.Contains('PackageLocale') | Should Be 'True' + } + It 'PackageLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.PackageLocale.Attributes.Mandatory | Should be 'False' + } + It 'PackageLocale Parameter is of String Type' { + $Function.Parameters.PackageLocale.ParameterType.FullName | Should be 'System.String' + } + It 'PackageLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.PackageLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'PackageLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.PackageLocale.Attributes.Position | Should be '3' + } + It 'Does PackageLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.PackageLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does PackageLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.PackageLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does PackageLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.PackageLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.PackageLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.PackageLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.PackageLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.PackageLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for PackageLocale '{ + $function.Definition.Contains('.PARAMETER PackageLocale') | Should Be 'True' + } + It 'Has a Parameter called LogPath' { + $Function.Parameters.Keys.Contains('LogPath') | Should Be 'True' + } + It 'LogPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.LogPath.Attributes.Mandatory | Should be 'False' + } + It 'LogPath Parameter is of String Type' { + $Function.Parameters.LogPath.ParameterType.FullName | Should be 'System.String' + } + It 'LogPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.LogPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'LogPath Parameter Position is defined correctly' { + [String]$Function.Parameters.LogPath.Attributes.Position | Should be '4' + } + It 'Does LogPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.LogPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does LogPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.LogPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does LogPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.LogPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.LogPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.LogPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.LogPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.LogPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for LogPath '{ + $function.Definition.Contains('.PARAMETER LogPath') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/CloseGitHubZipArchive.Functional.Tests.ps1 b/Private/Tests/CloseGitHubZipArchive.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/CloseGitHubZipArchive.Tests.ps1 b/Private/Tests/CloseGitHubZipArchive.Tests.ps1 new file mode 100644 index 00000000..201739d1 --- /dev/null +++ b/Private/Tests/CloseGitHubZipArchive.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'CloseGitHubZipArchive Tests' { + + Context 'Parameters for CloseGitHubZipArchive'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/CloseZipArchive.Functional.Tests.ps1 b/Private/Tests/CloseZipArchive.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/CloseZipArchive.Tests.ps1 b/Private/Tests/CloseZipArchive.Tests.ps1 new file mode 100644 index 00000000..4d44e60d --- /dev/null +++ b/Private/Tests/CloseZipArchive.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'CloseZipArchive Tests' { + + Context 'Parameters for CloseZipArchive'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ConvertPSObjectToHashtable.Functional.Tests.ps1 b/Private/Tests/ConvertPSObjectToHashtable.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ConvertPSObjectToHashtable.Tests.ps1 b/Private/Tests/ConvertPSObjectToHashtable.Tests.ps1 new file mode 100644 index 00000000..e7235d66 --- /dev/null +++ b/Private/Tests/ConvertPSObjectToHashtable.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'ConvertPSObjectToHashtable Tests' { + + Context 'Parameters for ConvertPSObjectToHashtable'{ + + It 'Has a Parameter called InputObject' { + $Function.Parameters.Keys.Contains('InputObject') | Should Be 'True' + } + It 'InputObject Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.InputObject.Attributes.Mandatory | Should be 'True' + } + It 'InputObject Parameter is of PSObject[] Type' { + $Function.Parameters.InputObject.ParameterType.FullName | Should be 'System.Management.Automation.PSObject[]' + } + It 'InputObject Parameter is member of ParameterSets' { + [String]$Function.Parameters.InputObject.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'InputObject Parameter Position is defined correctly' { + [String]$Function.Parameters.InputObject.Attributes.Position | Should be '0' + } + It 'Does InputObject Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.InputObject.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does InputObject Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.InputObject.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does InputObject Parameter use advanced parameter Validation? ' { + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for InputObject '{ + $function.Definition.Contains('.PARAMETER InputObject') | Should Be 'True' + } + It 'Has a Parameter called IgnoreNullValues' { + $Function.Parameters.Keys.Contains('IgnoreNullValues') | Should Be 'True' + } + It 'IgnoreNullValues Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.IgnoreNullValues.Attributes.Mandatory | Should be 'False' + } + It 'IgnoreNullValues Parameter is of SwitchParameter Type' { + $Function.Parameters.IgnoreNullValues.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'IgnoreNullValues Parameter is member of ParameterSets' { + [String]$Function.Parameters.IgnoreNullValues.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'IgnoreNullValues Parameter Position is defined correctly' { + [String]$Function.Parameters.IgnoreNullValues.Attributes.Position | Should be '-2147483648' + } + It 'Does IgnoreNullValues Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.IgnoreNullValues.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does IgnoreNullValues Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.IgnoreNullValues.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does IgnoreNullValues Parameter use advanced parameter Validation? ' { + $Function.Parameters.IgnoreNullValues.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.IgnoreNullValues.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.IgnoreNullValues.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.IgnoreNullValues.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.IgnoreNullValues.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for IgnoreNullValues '{ + $function.Definition.Contains('.PARAMETER IgnoreNullValues') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ConvertToConfigurationData.Functional.Tests.ps1 b/Private/Tests/ConvertToConfigurationData.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ConvertToConfigurationData.Tests.ps1 b/Private/Tests/ConvertToConfigurationData.Tests.ps1 new file mode 100644 index 00000000..0b881241 --- /dev/null +++ b/Private/Tests/ConvertToConfigurationData.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'ConvertToConfigurationData Tests' { + + Context 'Parameters for ConvertToConfigurationData'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of String Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.String' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/CopyDirectory.Functional.Tests.ps1 b/Private/Tests/CopyDirectory.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/CopyDirectory.Tests.ps1 b/Private/Tests/CopyDirectory.Tests.ps1 new file mode 100644 index 00000000..16e92863 --- /dev/null +++ b/Private/Tests/CopyDirectory.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'CopyDirectory Tests' { + + Context 'Parameters for CopyDirectory'{ + + It 'Has a Parameter called SourcePath' { + $Function.Parameters.Keys.Contains('SourcePath') | Should Be 'True' + } + It 'SourcePath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.SourcePath.Attributes.Mandatory | Should be 'True' + } + It 'SourcePath Parameter is of DirectoryInfo Type' { + $Function.Parameters.SourcePath.ParameterType.FullName | Should be 'System.IO.DirectoryInfo' + } + It 'SourcePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.SourcePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SourcePath Parameter Position is defined correctly' { + [String]$Function.Parameters.SourcePath.Attributes.Position | Should be '0' + } + It 'Does SourcePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SourcePath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does SourcePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SourcePath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does SourcePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.SourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.SourcePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SourcePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SourcePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SourcePath '{ + $function.Definition.Contains('.PARAMETER SourcePath') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of DirectoryInfo Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.IO.DirectoryInfo' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '1' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ExpandDscModule.Functional.Tests.ps1 b/Private/Tests/ExpandDscModule.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ExpandDscModule.Tests.ps1 b/Private/Tests/ExpandDscModule.Tests.ps1 new file mode 100644 index 00000000..37127f68 --- /dev/null +++ b/Private/Tests/ExpandDscModule.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'ExpandDscModule Tests' { + + Context 'Parameters for ExpandDscModule'{ + + It 'Has a Parameter called ModuleName' { + $Function.Parameters.Keys.Contains('ModuleName') | Should Be 'True' + } + It 'ModuleName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ModuleName.Attributes.Mandatory | Should be 'True' + } + It 'ModuleName Parameter is of String Type' { + $Function.Parameters.ModuleName.ParameterType.FullName | Should be 'System.String' + } + It 'ModuleName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ModuleName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ModuleName Parameter Position is defined correctly' { + [String]$Function.Parameters.ModuleName.Attributes.Position | Should be '0' + } + It 'Does ModuleName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ModuleName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ModuleName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ModuleName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ModuleName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ModuleName '{ + $function.Definition.Contains('.PARAMETER ModuleName') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '1' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '2' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ExpandGitHubZipArchive.Functional.Tests.ps1 b/Private/Tests/ExpandGitHubZipArchive.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ExpandGitHubZipArchive.Tests.ps1 b/Private/Tests/ExpandGitHubZipArchive.Tests.ps1 new file mode 100644 index 00000000..96da92a5 --- /dev/null +++ b/Private/Tests/ExpandGitHubZipArchive.Tests.ps1 @@ -0,0 +1,190 @@ +Describe 'ExpandGitHubZipArchive Tests' { + + Context 'Parameters for ExpandGitHubZipArchive'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String[] Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String[]' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '1' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Repository' { + $Function.Parameters.Keys.Contains('Repository') | Should Be 'True' + } + It 'Repository Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Repository.Attributes.Mandatory | Should be 'True' + } + It 'Repository Parameter is of String Type' { + $Function.Parameters.Repository.ParameterType.FullName | Should be 'System.String' + } + It 'Repository Parameter is member of ParameterSets' { + [String]$Function.Parameters.Repository.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Repository Parameter Position is defined correctly' { + [String]$Function.Parameters.Repository.Attributes.Position | Should be '-2147483648' + } + It 'Does Repository Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Repository.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Repository Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Repository.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Repository Parameter use advanced parameter Validation? ' { + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Repository '{ + $function.Definition.Contains('.PARAMETER Repository') | Should Be 'True' + } + It 'Has a Parameter called OverrideRepository' { + $Function.Parameters.Keys.Contains('OverrideRepository') | Should Be 'True' + } + It 'OverrideRepository Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.OverrideRepository.Attributes.Mandatory | Should be 'False' + } + It 'OverrideRepository Parameter is of String Type' { + $Function.Parameters.OverrideRepository.ParameterType.FullName | Should be 'System.String' + } + It 'OverrideRepository Parameter is member of ParameterSets' { + [String]$Function.Parameters.OverrideRepository.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'OverrideRepository Parameter Position is defined correctly' { + [String]$Function.Parameters.OverrideRepository.Attributes.Position | Should be '-2147483648' + } + It 'Does OverrideRepository Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.OverrideRepository.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does OverrideRepository Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.OverrideRepository.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does OverrideRepository Parameter use advanced parameter Validation? ' { + $Function.Parameters.OverrideRepository.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.OverrideRepository.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.OverrideRepository.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.OverrideRepository.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.OverrideRepository.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for OverrideRepository '{ + $function.Definition.Contains('.PARAMETER OverrideRepository') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ExpandGitHubZipArchiveItem.Functional.Tests.ps1 b/Private/Tests/ExpandGitHubZipArchiveItem.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ExpandGitHubZipArchiveItem.Tests.ps1 b/Private/Tests/ExpandGitHubZipArchiveItem.Tests.ps1 new file mode 100644 index 00000000..83c5d59d --- /dev/null +++ b/Private/Tests/ExpandGitHubZipArchiveItem.Tests.ps1 @@ -0,0 +1,32 @@ +Describe 'ExpandGitHubZipArchiveItem Tests' { + + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ExpandIso.Functional.Tests.ps1 b/Private/Tests/ExpandIso.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ExpandIso.Tests.ps1 b/Private/Tests/ExpandIso.Tests.ps1 new file mode 100644 index 00000000..218e9575 --- /dev/null +++ b/Private/Tests/ExpandIso.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'ExpandIso Tests' { + + Context 'Parameters for ExpandIso'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '1' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ExpandLabResource.Functional.Tests.ps1 b/Private/Tests/ExpandLabResource.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ExpandLabResource.Tests.ps1 b/Private/Tests/ExpandLabResource.Tests.ps1 new file mode 100644 index 00000000..352840b2 --- /dev/null +++ b/Private/Tests/ExpandLabResource.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'ExpandLabResource Tests' { + + Context 'Parameters for ExpandLabResource'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '1' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '2' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called ResourcePath' { + $Function.Parameters.Keys.Contains('ResourcePath') | Should Be 'True' + } + It 'ResourcePath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ResourcePath.Attributes.Mandatory | Should be 'False' + } + It 'ResourcePath Parameter is of String Type' { + $Function.Parameters.ResourcePath.ParameterType.FullName | Should be 'System.String' + } + It 'ResourcePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourcePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourcePath Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourcePath.Attributes.Position | Should be '3' + } + It 'Does ResourcePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourcePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourcePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourcePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ResourcePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourcePath '{ + $function.Definition.Contains('.PARAMETER ResourcePath') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ExpandModuleCache.Functional.Tests.ps1 b/Private/Tests/ExpandModuleCache.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ExpandModuleCache.Tests.ps1 b/Private/Tests/ExpandModuleCache.Tests.ps1 new file mode 100644 index 00000000..361e5b0c --- /dev/null +++ b/Private/Tests/ExpandModuleCache.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'ExpandModuleCache Tests' { + + Context 'Parameters for ExpandModuleCache'{ + + It 'Has a Parameter called Module' { + $Function.Parameters.Keys.Contains('Module') | Should Be 'True' + } + It 'Module Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Module.Attributes.Mandatory | Should be 'True' + } + It 'Module Parameter is of Hashtable[] Type' { + $Function.Parameters.Module.ParameterType.FullName | Should be 'System.Collections.Hashtable[]' + } + It 'Module Parameter is member of ParameterSets' { + [String]$Function.Parameters.Module.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Module Parameter Position is defined correctly' { + [String]$Function.Parameters.Module.Attributes.Position | Should be '0' + } + It 'Does Module Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Module.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Module Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Module.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Module Parameter use advanced parameter Validation? ' { + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Module '{ + $function.Definition.Contains('.PARAMETER Module') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '1' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Clean' { + $Function.Parameters.Keys.Contains('Clean') | Should Be 'True' + } + It 'Clean Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Clean.Attributes.Mandatory | Should be 'False' + } + It 'Clean Parameter is of SwitchParameter Type' { + $Function.Parameters.Clean.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Clean Parameter is member of ParameterSets' { + [String]$Function.Parameters.Clean.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Clean Parameter Position is defined correctly' { + [String]$Function.Parameters.Clean.Attributes.Position | Should be '-2147483648' + } + It 'Does Clean Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Clean.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Clean Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Clean.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Clean Parameter use advanced parameter Validation? ' { + $Function.Parameters.Clean.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Clean.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Clean.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Clean.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Clean.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Clean '{ + $function.Definition.Contains('.PARAMETER Clean') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '2' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ExpandWindowsImage.Functional.Tests.ps1 b/Private/Tests/ExpandWindowsImage.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ExpandWindowsImage.Tests.ps1 b/Private/Tests/ExpandWindowsImage.Tests.ps1 new file mode 100644 index 00000000..13b7bd80 --- /dev/null +++ b/Private/Tests/ExpandWindowsImage.Tests.ps1 @@ -0,0 +1,376 @@ +Describe 'ExpandWindowsImage Tests' { + + Context 'Parameters for ExpandWindowsImage'{ + + It 'Has a Parameter called MediaPath' { + $Function.Parameters.Keys.Contains('MediaPath') | Should Be 'True' + } + It 'MediaPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MediaPath.Attributes.Mandatory | Should be 'True' + } + It 'MediaPath Parameter is of String Type' { + $Function.Parameters.MediaPath.ParameterType.FullName | Should be 'System.String' + } + It 'MediaPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.MediaPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MediaPath Parameter Position is defined correctly' { + [String]$Function.Parameters.MediaPath.Attributes.Position | Should be '-2147483648' + } + It 'Does MediaPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MediaPath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does MediaPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MediaPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MediaPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.MediaPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MediaPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MediaPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MediaPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MediaPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MediaPath '{ + $function.Definition.Contains('.PARAMETER MediaPath') | Should Be 'True' + } + It 'Has a Parameter called WimImageIndex' { + $Function.Parameters.Keys.Contains('WimImageIndex') | Should Be 'True' + } + It 'WimImageIndex Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.WimImageIndex.Attributes.Mandatory | Should be 'True' + } + It 'WimImageIndex Parameter is of Int32 Type' { + $Function.Parameters.WimImageIndex.ParameterType.FullName | Should be 'System.Int32' + } + It 'WimImageIndex Parameter is member of ParameterSets' { + [String]$Function.Parameters.WimImageIndex.ParameterSets.Keys | Should Be 'Index' + } + It 'WimImageIndex Parameter Position is defined correctly' { + [String]$Function.Parameters.WimImageIndex.Attributes.Position | Should be '-2147483648' + } + It 'Does WimImageIndex Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.WimImageIndex.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does WimImageIndex Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.WimImageIndex.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does WimImageIndex Parameter use advanced parameter Validation? ' { + $Function.Parameters.WimImageIndex.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.WimImageIndex.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.WimImageIndex.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.WimImageIndex.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.WimImageIndex.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for WimImageIndex '{ + $function.Definition.Contains('.PARAMETER WimImageIndex') | Should Be 'True' + } + It 'Has a Parameter called WimImageName' { + $Function.Parameters.Keys.Contains('WimImageName') | Should Be 'True' + } + It 'WimImageName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.WimImageName.Attributes.Mandatory | Should be 'True' + } + It 'WimImageName Parameter is of String Type' { + $Function.Parameters.WimImageName.ParameterType.FullName | Should be 'System.String' + } + It 'WimImageName Parameter is member of ParameterSets' { + [String]$Function.Parameters.WimImageName.ParameterSets.Keys | Should Be 'Name' + } + It 'WimImageName Parameter Position is defined correctly' { + [String]$Function.Parameters.WimImageName.Attributes.Position | Should be '-2147483648' + } + It 'Does WimImageName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.WimImageName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does WimImageName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.WimImageName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does WimImageName Parameter use advanced parameter Validation? ' { + $Function.Parameters.WimImageName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.WimImageName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.WimImageName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.WimImageName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.WimImageName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for WimImageName '{ + $function.Definition.Contains('.PARAMETER WimImageName') | Should Be 'True' + } + It 'Has a Parameter called Vhd' { + $Function.Parameters.Keys.Contains('Vhd') | Should Be 'True' + } + It 'Vhd Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Vhd.Attributes.Mandatory | Should be 'True' + } + It 'Vhd Parameter is of Object Type' { + $Function.Parameters.Vhd.ParameterType.FullName | Should be 'System.Object' + } + It 'Vhd Parameter is member of ParameterSets' { + [String]$Function.Parameters.Vhd.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Vhd Parameter Position is defined correctly' { + [String]$Function.Parameters.Vhd.Attributes.Position | Should be '-2147483648' + } + It 'Does Vhd Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Vhd Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Vhd Parameter use advanced parameter Validation? ' { + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Vhd '{ + $function.Definition.Contains('.PARAMETER Vhd') | Should Be 'True' + } + It 'Has a Parameter called PartitionStyle' { + $Function.Parameters.Keys.Contains('PartitionStyle') | Should Be 'True' + } + It 'PartitionStyle Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.PartitionStyle.Attributes.Mandatory | Should be 'True' + } + It 'PartitionStyle Parameter is of String Type' { + $Function.Parameters.PartitionStyle.ParameterType.FullName | Should be 'System.String' + } + It 'PartitionStyle Parameter is member of ParameterSets' { + [String]$Function.Parameters.PartitionStyle.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'PartitionStyle Parameter Position is defined correctly' { + [String]$Function.Parameters.PartitionStyle.Attributes.Position | Should be '-2147483648' + } + It 'Does PartitionStyle Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.PartitionStyle.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does PartitionStyle Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.PartitionStyle.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does PartitionStyle Parameter use advanced parameter Validation? ' { + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for PartitionStyle '{ + $function.Definition.Contains('.PARAMETER PartitionStyle') | Should Be 'True' + } + It 'Has a Parameter called WindowsOptionalFeature' { + $Function.Parameters.Keys.Contains('WindowsOptionalFeature') | Should Be 'True' + } + It 'WindowsOptionalFeature Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.WindowsOptionalFeature.Attributes.Mandatory | Should be 'False' + } + It 'WindowsOptionalFeature Parameter is of String[] Type' { + $Function.Parameters.WindowsOptionalFeature.ParameterType.FullName | Should be 'System.String[]' + } + It 'WindowsOptionalFeature Parameter is member of ParameterSets' { + [String]$Function.Parameters.WindowsOptionalFeature.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'WindowsOptionalFeature Parameter Position is defined correctly' { + [String]$Function.Parameters.WindowsOptionalFeature.Attributes.Position | Should be '-2147483648' + } + It 'Does WindowsOptionalFeature Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.WindowsOptionalFeature.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does WindowsOptionalFeature Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.WindowsOptionalFeature.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does WindowsOptionalFeature Parameter use advanced parameter Validation? ' { + $Function.Parameters.WindowsOptionalFeature.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.WindowsOptionalFeature.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.WindowsOptionalFeature.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.WindowsOptionalFeature.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.WindowsOptionalFeature.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for WindowsOptionalFeature '{ + $function.Definition.Contains('.PARAMETER WindowsOptionalFeature') | Should Be 'True' + } + It 'Has a Parameter called SourcePath' { + $Function.Parameters.Keys.Contains('SourcePath') | Should Be 'True' + } + It 'SourcePath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SourcePath.Attributes.Mandatory | Should be 'False' + } + It 'SourcePath Parameter is of String Type' { + $Function.Parameters.SourcePath.ParameterType.FullName | Should be 'System.String' + } + It 'SourcePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.SourcePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SourcePath Parameter Position is defined correctly' { + [String]$Function.Parameters.SourcePath.Attributes.Position | Should be '-2147483648' + } + It 'Does SourcePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SourcePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SourcePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SourcePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SourcePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.SourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.SourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SourcePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SourcePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SourcePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SourcePath '{ + $function.Definition.Contains('.PARAMETER SourcePath') | Should Be 'True' + } + It 'Has a Parameter called WimPath' { + $Function.Parameters.Keys.Contains('WimPath') | Should Be 'True' + } + It 'WimPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.WimPath.Attributes.Mandatory | Should be 'False' + } + It 'WimPath Parameter is of String Type' { + $Function.Parameters.WimPath.ParameterType.FullName | Should be 'System.String' + } + It 'WimPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.WimPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'WimPath Parameter Position is defined correctly' { + [String]$Function.Parameters.WimPath.Attributes.Position | Should be '-2147483648' + } + It 'Does WimPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.WimPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does WimPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.WimPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does WimPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.WimPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.WimPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.WimPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.WimPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.WimPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for WimPath '{ + $function.Definition.Contains('.PARAMETER WimPath') | Should Be 'True' + } + It 'Has a Parameter called Package' { + $Function.Parameters.Keys.Contains('Package') | Should Be 'True' + } + It 'Package Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Package.Attributes.Mandatory | Should be 'False' + } + It 'Package Parameter is of String[] Type' { + $Function.Parameters.Package.ParameterType.FullName | Should be 'System.String[]' + } + It 'Package Parameter is member of ParameterSets' { + [String]$Function.Parameters.Package.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Package Parameter Position is defined correctly' { + [String]$Function.Parameters.Package.Attributes.Position | Should be '-2147483648' + } + It 'Does Package Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Package.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Package Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Package.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Package Parameter use advanced parameter Validation? ' { + $Function.Parameters.Package.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Package.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Package.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Package.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Package.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Package '{ + $function.Definition.Contains('.PARAMETER Package') | Should Be 'True' + } + It 'Has a Parameter called PackagePath' { + $Function.Parameters.Keys.Contains('PackagePath') | Should Be 'True' + } + It 'PackagePath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.PackagePath.Attributes.Mandatory | Should be 'False' + } + It 'PackagePath Parameter is of String Type' { + $Function.Parameters.PackagePath.ParameterType.FullName | Should be 'System.String' + } + It 'PackagePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.PackagePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'PackagePath Parameter Position is defined correctly' { + [String]$Function.Parameters.PackagePath.Attributes.Position | Should be '-2147483648' + } + It 'Does PackagePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.PackagePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does PackagePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.PackagePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does PackagePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.PackagePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.PackagePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.PackagePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.PackagePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.PackagePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for PackagePath '{ + $function.Definition.Contains('.PARAMETER PackagePath') | Should Be 'True' + } + It 'Has a Parameter called PackageLocale' { + $Function.Parameters.Keys.Contains('PackageLocale') | Should Be 'True' + } + It 'PackageLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.PackageLocale.Attributes.Mandatory | Should be 'False' + } + It 'PackageLocale Parameter is of String Type' { + $Function.Parameters.PackageLocale.ParameterType.FullName | Should be 'System.String' + } + It 'PackageLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.PackageLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'PackageLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.PackageLocale.Attributes.Position | Should be '-2147483648' + } + It 'Does PackageLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.PackageLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does PackageLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.PackageLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does PackageLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.PackageLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.PackageLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.PackageLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.PackageLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.PackageLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for PackageLocale '{ + $function.Definition.Contains('.PARAMETER PackageLocale') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ExpandZipArchive.Functional.Tests.ps1 b/Private/Tests/ExpandZipArchive.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ExpandZipArchive.Tests.ps1 b/Private/Tests/ExpandZipArchive.Tests.ps1 new file mode 100644 index 00000000..c4c738c0 --- /dev/null +++ b/Private/Tests/ExpandZipArchive.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'ExpandZipArchive Tests' { + + Context 'Parameters for ExpandZipArchive'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String[] Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String[]' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '1' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called ExcludeNuSpecFiles' { + $Function.Parameters.Keys.Contains('ExcludeNuSpecFiles') | Should Be 'True' + } + It 'ExcludeNuSpecFiles Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ExcludeNuSpecFiles.Attributes.Mandatory | Should be 'False' + } + It 'ExcludeNuSpecFiles Parameter is of SwitchParameter Type' { + $Function.Parameters.ExcludeNuSpecFiles.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'ExcludeNuSpecFiles Parameter is member of ParameterSets' { + [String]$Function.Parameters.ExcludeNuSpecFiles.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ExcludeNuSpecFiles Parameter Position is defined correctly' { + [String]$Function.Parameters.ExcludeNuSpecFiles.Attributes.Position | Should be '-2147483648' + } + It 'Does ExcludeNuSpecFiles Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ExcludeNuSpecFiles.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ExcludeNuSpecFiles Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ExcludeNuSpecFiles.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ExcludeNuSpecFiles Parameter use advanced parameter Validation? ' { + $Function.Parameters.ExcludeNuSpecFiles.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ExcludeNuSpecFiles.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ExcludeNuSpecFiles.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ExcludeNuSpecFiles.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ExcludeNuSpecFiles.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ExcludeNuSpecFiles '{ + $function.Definition.Contains('.PARAMETER ExcludeNuSpecFiles') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ExpandZipArchiveItem.Functional.Tests.ps1 b/Private/Tests/ExpandZipArchiveItem.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ExpandZipArchiveItem.Tests.ps1 b/Private/Tests/ExpandZipArchiveItem.Tests.ps1 new file mode 100644 index 00000000..5b66dd3e --- /dev/null +++ b/Private/Tests/ExpandZipArchiveItem.Tests.ps1 @@ -0,0 +1,32 @@ +Describe 'ExpandZipArchiveItem Tests' { + + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetConfigurationData.Functional.Tests.ps1 b/Private/Tests/GetConfigurationData.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetConfigurationData.Tests.ps1 b/Private/Tests/GetConfigurationData.Tests.ps1 new file mode 100644 index 00000000..febc33d8 --- /dev/null +++ b/Private/Tests/GetConfigurationData.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'GetConfigurationData Tests' { + + Context 'Parameters for GetConfigurationData'{ + + It 'Has a Parameter called Configuration' { + $Function.Parameters.Keys.Contains('Configuration') | Should Be 'True' + } + It 'Configuration Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Configuration.Attributes.Mandatory | Should be 'True' + } + It 'Configuration Parameter is of String Type' { + $Function.Parameters.Configuration.ParameterType.FullName | Should be 'System.String' + } + It 'Configuration Parameter is member of ParameterSets' { + [String]$Function.Parameters.Configuration.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Configuration Parameter Position is defined correctly' { + [String]$Function.Parameters.Configuration.Attributes.Position | Should be '0' + } + It 'Does Configuration Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Configuration.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Configuration Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Configuration.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Configuration Parameter use advanced parameter Validation? ' { + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Configuration '{ + $function.Definition.Contains('.PARAMETER Configuration') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetDiskImageDriveLetter.Functional.Tests.ps1 b/Private/Tests/GetDiskImageDriveLetter.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetDiskImageDriveLetter.Tests.ps1 b/Private/Tests/GetDiskImageDriveLetter.Tests.ps1 new file mode 100644 index 00000000..22dafe24 --- /dev/null +++ b/Private/Tests/GetDiskImageDriveLetter.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'GetDiskImageDriveLetter Tests' { + + Context 'Parameters for GetDiskImageDriveLetter'{ + + It 'Has a Parameter called DiskImage' { + $Function.Parameters.Keys.Contains('DiskImage') | Should Be 'True' + } + It 'DiskImage Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DiskImage.Attributes.Mandatory | Should be 'True' + } + It 'DiskImage Parameter is of Object Type' { + $Function.Parameters.DiskImage.ParameterType.FullName | Should be 'System.Object' + } + It 'DiskImage Parameter is member of ParameterSets' { + [String]$Function.Parameters.DiskImage.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DiskImage Parameter Position is defined correctly' { + [String]$Function.Parameters.DiskImage.Attributes.Position | Should be '0' + } + It 'Does DiskImage Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DiskImage.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does DiskImage Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DiskImage.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does DiskImage Parameter use advanced parameter Validation? ' { + $Function.Parameters.DiskImage.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.DiskImage.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DiskImage.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DiskImage.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DiskImage.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DiskImage '{ + $function.Definition.Contains('.PARAMETER DiskImage') | Should Be 'True' + } + It 'Has a Parameter called PartitionType' { + $Function.Parameters.Keys.Contains('PartitionType') | Should Be 'True' + } + It 'PartitionType Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.PartitionType.Attributes.Mandatory | Should be 'True' + } + It 'PartitionType Parameter is of String Type' { + $Function.Parameters.PartitionType.ParameterType.FullName | Should be 'System.String' + } + It 'PartitionType Parameter is member of ParameterSets' { + [String]$Function.Parameters.PartitionType.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'PartitionType Parameter Position is defined correctly' { + [String]$Function.Parameters.PartitionType.Attributes.Position | Should be '1' + } + It 'Does PartitionType Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.PartitionType.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does PartitionType Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.PartitionType.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does PartitionType Parameter use advanced parameter Validation? ' { + $Function.Parameters.PartitionType.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.PartitionType.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.PartitionType.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.PartitionType.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.PartitionType.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for PartitionType '{ + $function.Definition.Contains('.PARAMETER PartitionType') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetDscModule.Functional.Tests.ps1 b/Private/Tests/GetDscModule.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetDscModule.Tests.ps1 b/Private/Tests/GetDscModule.Tests.ps1 new file mode 100644 index 00000000..2bb1a90e --- /dev/null +++ b/Private/Tests/GetDscModule.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'GetDscModule Tests' { + + Context 'Parameters for GetDscModule'{ + + It 'Has a Parameter called ModuleName' { + $Function.Parameters.Keys.Contains('ModuleName') | Should Be 'True' + } + It 'ModuleName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ModuleName.Attributes.Mandatory | Should be 'True' + } + It 'ModuleName Parameter is of String Type' { + $Function.Parameters.ModuleName.ParameterType.FullName | Should be 'System.String' + } + It 'ModuleName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ModuleName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ModuleName Parameter Position is defined correctly' { + [String]$Function.Parameters.ModuleName.Attributes.Position | Should be '0' + } + It 'Does ModuleName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ModuleName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ModuleName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ModuleName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ModuleName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ModuleName '{ + $function.Definition.Contains('.PARAMETER ModuleName') | Should Be 'True' + } + It 'Has a Parameter called ResourceName' { + $Function.Parameters.Keys.Contains('ResourceName') | Should Be 'True' + } + It 'ResourceName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ResourceName.Attributes.Mandatory | Should be 'False' + } + It 'ResourceName Parameter is of String Type' { + $Function.Parameters.ResourceName.ParameterType.FullName | Should be 'System.String' + } + It 'ResourceName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourceName Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceName.Attributes.Position | Should be '1' + } + It 'Does ResourceName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourceName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ResourceName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceName '{ + $function.Definition.Contains('.PARAMETER ResourceName') | Should Be 'True' + } + It 'Has a Parameter called MinimumVersion' { + $Function.Parameters.Keys.Contains('MinimumVersion') | Should Be 'True' + } + It 'MinimumVersion Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MinimumVersion.Attributes.Mandatory | Should be 'False' + } + It 'MinimumVersion Parameter is of String Type' { + $Function.Parameters.MinimumVersion.ParameterType.FullName | Should be 'System.String' + } + It 'MinimumVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumVersion.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MinimumVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumVersion.Attributes.Position | Should be '2' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MinimumVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumVersion '{ + $function.Definition.Contains('.PARAMETER MinimumVersion') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetDscResource.Functional.Tests.ps1 b/Private/Tests/GetDscResource.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetDscResource.Tests.ps1 b/Private/Tests/GetDscResource.Tests.ps1 new file mode 100644 index 00000000..949e34b8 --- /dev/null +++ b/Private/Tests/GetDscResource.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'GetDscResource Tests' { + + Context 'Parameters for GetDscResource'{ + + It 'Has a Parameter called ResourceName' { + $Function.Parameters.Keys.Contains('ResourceName') | Should Be 'True' + } + It 'ResourceName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ResourceName.Attributes.Mandatory | Should be 'True' + } + It 'ResourceName Parameter is of String Type' { + $Function.Parameters.ResourceName.ParameterType.FullName | Should be 'System.String' + } + It 'ResourceName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourceName Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceName.Attributes.Position | Should be '0' + } + It 'Does ResourceName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ResourceName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ResourceName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceName '{ + $function.Definition.Contains('.PARAMETER ResourceName') | Should Be 'True' + } + It 'Has a Parameter called Parameters' { + $Function.Parameters.Keys.Contains('Parameters') | Should Be 'True' + } + It 'Parameters Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Parameters.Attributes.Mandatory | Should be 'True' + } + It 'Parameters Parameter is of Hashtable Type' { + $Function.Parameters.Parameters.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'Parameters Parameter is member of ParameterSets' { + [String]$Function.Parameters.Parameters.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Parameters Parameter Position is defined correctly' { + [String]$Function.Parameters.Parameters.Attributes.Position | Should be '1' + } + It 'Does Parameters Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Parameters.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Parameters Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Parameters.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Parameters Parameter use advanced parameter Validation? ' { + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Parameters '{ + $function.Definition.Contains('.PARAMETER Parameters') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetDscResourceModule.Functional.Tests.ps1 b/Private/Tests/GetDscResourceModule.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetDscResourceModule.Tests.ps1 b/Private/Tests/GetDscResourceModule.Tests.ps1 new file mode 100644 index 00000000..f15dc2b4 --- /dev/null +++ b/Private/Tests/GetDscResourceModule.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'GetDscResourceModule Tests' { + + Context 'Parameters for GetDscResourceModule'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String[] Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String[]' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetFormattedMessage.Functional.Tests.ps1 b/Private/Tests/GetFormattedMessage.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetFormattedMessage.Tests.ps1 b/Private/Tests/GetFormattedMessage.Tests.ps1 new file mode 100644 index 00000000..a312e156 --- /dev/null +++ b/Private/Tests/GetFormattedMessage.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'GetFormattedMessage Tests' { + + Context 'Parameters for GetFormattedMessage'{ + + It 'Has a Parameter called Message' { + $Function.Parameters.Keys.Contains('Message') | Should Be 'True' + } + It 'Message Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Message.Attributes.Mandatory | Should be 'True' + } + It 'Message Parameter is of String Type' { + $Function.Parameters.Message.ParameterType.FullName | Should be 'System.String' + } + It 'Message Parameter is member of ParameterSets' { + [String]$Function.Parameters.Message.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Message Parameter Position is defined correctly' { + [String]$Function.Parameters.Message.Attributes.Position | Should be '0' + } + It 'Does Message Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Message.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Message Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Message.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Message Parameter use advanced parameter Validation? ' { + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Message '{ + $function.Definition.Contains('.PARAMETER Message') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetLabHostDSCConfigurationPath.Functional.Tests.ps1 b/Private/Tests/GetLabHostDSCConfigurationPath.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetLabHostDSCConfigurationPath.Tests.ps1 b/Private/Tests/GetLabHostDSCConfigurationPath.Tests.ps1 new file mode 100644 index 00000000..6efc3c81 --- /dev/null +++ b/Private/Tests/GetLabHostDSCConfigurationPath.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'GetLabHostDSCConfigurationPath Tests' { + + Context 'Parameters for GetLabHostDSCConfigurationPath'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetLabHostSetupConfiguration.Functional.Tests.ps1 b/Private/Tests/GetLabHostSetupConfiguration.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetLabHostSetupConfiguration.Tests.ps1 b/Private/Tests/GetLabHostSetupConfiguration.Tests.ps1 new file mode 100644 index 00000000..f3ffccaf --- /dev/null +++ b/Private/Tests/GetLabHostSetupConfiguration.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'GetLabHostSetupConfiguration Tests' { + + Context 'Parameters for GetLabHostSetupConfiguration'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetLabVMDisk.Functional.Tests.ps1 b/Private/Tests/GetLabVMDisk.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetLabVMDisk.Tests.ps1 b/Private/Tests/GetLabVMDisk.Tests.ps1 new file mode 100644 index 00000000..402e673d --- /dev/null +++ b/Private/Tests/GetLabVMDisk.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'GetLabVMDisk Tests' { + + Context 'Parameters for GetLabVMDisk'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'True' + } + It 'Media Parameter is of String Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.String' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '1' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '2' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetLabVMSnapshot.Functional.Tests.ps1 b/Private/Tests/GetLabVMSnapshot.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetLabVMSnapshot.Tests.ps1 b/Private/Tests/GetLabVMSnapshot.Tests.ps1 new file mode 100644 index 00000000..11746f08 --- /dev/null +++ b/Private/Tests/GetLabVMSnapshot.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'GetLabVMSnapshot Tests' { + + Context 'Parameters for GetLabVMSnapshot'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String[] Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String[]' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called SnapshotName' { + $Function.Parameters.Keys.Contains('SnapshotName') | Should Be 'True' + } + It 'SnapshotName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.SnapshotName.Attributes.Mandatory | Should be 'True' + } + It 'SnapshotName Parameter is of String Type' { + $Function.Parameters.SnapshotName.ParameterType.FullName | Should be 'System.String' + } + It 'SnapshotName Parameter is member of ParameterSets' { + [String]$Function.Parameters.SnapshotName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SnapshotName Parameter Position is defined correctly' { + [String]$Function.Parameters.SnapshotName.Attributes.Position | Should be '1' + } + It 'Does SnapshotName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SnapshotName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SnapshotName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SnapshotName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SnapshotName Parameter use advanced parameter Validation? ' { + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SnapshotName '{ + $function.Definition.Contains('.PARAMETER SnapshotName') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetModule.Functional.Tests.ps1 b/Private/Tests/GetModule.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetModule.Tests.ps1 b/Private/Tests/GetModule.Tests.ps1 new file mode 100644 index 00000000..099cb268 --- /dev/null +++ b/Private/Tests/GetModule.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'GetModule Tests' { + + Context 'Parameters for GetModule'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetModuleCache.Functional.Tests.ps1 b/Private/Tests/GetModuleCache.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetModuleCache.Tests.ps1 b/Private/Tests/GetModuleCache.Tests.ps1 new file mode 100644 index 00000000..23e55079 --- /dev/null +++ b/Private/Tests/GetModuleCache.Tests.ps1 @@ -0,0 +1,314 @@ +Describe 'GetModuleCache Tests' { + + Context 'Parameters for GetModuleCache'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True True True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True True True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called MinimumVersion' { + $Function.Parameters.Keys.Contains('MinimumVersion') | Should Be 'True' + } + It 'MinimumVersion Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MinimumVersion.Attributes.Mandatory | Should be 'True' + } + It 'MinimumVersion Parameter is of Version Type' { + $Function.Parameters.MinimumVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'MinimumVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumVersion.ParameterSets.Keys | Should Be 'NameMinimum' + } + It 'MinimumVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumVersion.Attributes.Position | Should be '-2147483648' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MinimumVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumVersion '{ + $function.Definition.Contains('.PARAMETER MinimumVersion') | Should Be 'True' + } + It 'Has a Parameter called RequiredVersion' { + $Function.Parameters.Keys.Contains('RequiredVersion') | Should Be 'True' + } + It 'RequiredVersion Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.RequiredVersion.Attributes.Mandatory | Should be 'True' + } + It 'RequiredVersion Parameter is of Version Type' { + $Function.Parameters.RequiredVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'RequiredVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.RequiredVersion.ParameterSets.Keys | Should Be 'NameRequired' + } + It 'RequiredVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.RequiredVersion.Attributes.Position | Should be '-2147483648' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RequiredVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RequiredVersion '{ + $function.Definition.Contains('.PARAMETER RequiredVersion') | Should Be 'True' + } + It 'Has a Parameter called Owner' { + $Function.Parameters.Keys.Contains('Owner') | Should Be 'True' + } + It 'Owner Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Owner.Attributes.Mandatory | Should be 'False False False' + } + It 'Owner Parameter is of String Type' { + $Function.Parameters.Owner.ParameterType.FullName | Should be 'System.String' + } + It 'Owner Parameter is member of ParameterSets' { + [String]$Function.Parameters.Owner.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Owner Parameter Position is defined correctly' { + [String]$Function.Parameters.Owner.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Owner Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Owner.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Owner Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Owner.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Owner Parameter use advanced parameter Validation? ' { + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Owner '{ + $function.Definition.Contains('.PARAMETER Owner') | Should Be 'True' + } + It 'Has a Parameter called Branch' { + $Function.Parameters.Keys.Contains('Branch') | Should Be 'True' + } + It 'Branch Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Branch.Attributes.Mandatory | Should be 'False False False' + } + It 'Branch Parameter is of String Type' { + $Function.Parameters.Branch.ParameterType.FullName | Should be 'System.String' + } + It 'Branch Parameter is member of ParameterSets' { + [String]$Function.Parameters.Branch.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Branch Parameter Position is defined correctly' { + [String]$Function.Parameters.Branch.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Branch Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Branch.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Branch Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Branch.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Branch Parameter use advanced parameter Validation? ' { + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Branch '{ + $function.Definition.Contains('.PARAMETER Branch') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'False False False' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called Provider' { + $Function.Parameters.Keys.Contains('Provider') | Should Be 'True' + } + It 'Provider Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Provider.Attributes.Mandatory | Should be 'False False False' + } + It 'Provider Parameter is of String Type' { + $Function.Parameters.Provider.ParameterType.FullName | Should be 'System.String' + } + It 'Provider Parameter is member of ParameterSets' { + [String]$Function.Parameters.Provider.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Provider Parameter Position is defined correctly' { + [String]$Function.Parameters.Provider.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Provider Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Provider.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Provider Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Provider.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Provider Parameter use advanced parameter Validation? ' { + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Provider '{ + $function.Definition.Contains('.PARAMETER Provider') | Should Be 'True' + } + It 'Has a Parameter called Module' { + $Function.Parameters.Keys.Contains('Module') | Should Be 'True' + } + It 'Module Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Module.Attributes.Mandatory | Should be 'True' + } + It 'Module Parameter is of Hashtable Type' { + $Function.Parameters.Module.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'Module Parameter is member of ParameterSets' { + [String]$Function.Parameters.Module.ParameterSets.Keys | Should Be 'Module' + } + It 'Module Parameter Position is defined correctly' { + [String]$Function.Parameters.Module.Attributes.Position | Should be '-2147483648' + } + It 'Does Module Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Module.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Module Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Module.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Module Parameter use advanced parameter Validation? ' { + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Module '{ + $function.Definition.Contains('.PARAMETER Module') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '-2147483648' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetModuleCacheManifest.Functional.Tests.ps1 b/Private/Tests/GetModuleCacheManifest.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetModuleCacheManifest.Tests.ps1 b/Private/Tests/GetModuleCacheManifest.Tests.ps1 new file mode 100644 index 00000000..0d0e84f0 --- /dev/null +++ b/Private/Tests/GetModuleCacheManifest.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'GetModuleCacheManifest Tests' { + + Context 'Parameters for GetModuleCacheManifest'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called Provider' { + $Function.Parameters.Keys.Contains('Provider') | Should Be 'True' + } + It 'Provider Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Provider.Attributes.Mandatory | Should be 'False' + } + It 'Provider Parameter is of String Type' { + $Function.Parameters.Provider.ParameterType.FullName | Should be 'System.String' + } + It 'Provider Parameter is member of ParameterSets' { + [String]$Function.Parameters.Provider.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Provider Parameter Position is defined correctly' { + [String]$Function.Parameters.Provider.Attributes.Position | Should be '1' + } + It 'Does Provider Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Provider.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Provider Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Provider.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Provider Parameter use advanced parameter Validation? ' { + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Provider '{ + $function.Definition.Contains('.PARAMETER Provider') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetResourceDownload.Functional.Tests.ps1 b/Private/Tests/GetResourceDownload.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetResourceDownload.Tests.ps1 b/Private/Tests/GetResourceDownload.Tests.ps1 new file mode 100644 index 00000000..1a10adfe --- /dev/null +++ b/Private/Tests/GetResourceDownload.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'GetResourceDownload Tests' { + + Context 'Parameters for GetResourceDownload'{ + + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '0' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Uri' { + $Function.Parameters.Keys.Contains('Uri') | Should Be 'True' + } + It 'Uri Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Uri.Attributes.Mandatory | Should be 'True' + } + It 'Uri Parameter is of String Type' { + $Function.Parameters.Uri.ParameterType.FullName | Should be 'System.String' + } + It 'Uri Parameter is member of ParameterSets' { + [String]$Function.Parameters.Uri.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Uri Parameter Position is defined correctly' { + [String]$Function.Parameters.Uri.Attributes.Position | Should be '1' + } + It 'Does Uri Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Uri Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Uri Parameter use advanced parameter Validation? ' { + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Uri '{ + $function.Definition.Contains('.PARAMETER Uri') | Should Be 'True' + } + It 'Has a Parameter called Checksum' { + $Function.Parameters.Keys.Contains('Checksum') | Should Be 'True' + } + It 'Checksum Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Checksum.Attributes.Mandatory | Should be 'False' + } + It 'Checksum Parameter is of String Type' { + $Function.Parameters.Checksum.ParameterType.FullName | Should be 'System.String' + } + It 'Checksum Parameter is member of ParameterSets' { + [String]$Function.Parameters.Checksum.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Checksum Parameter Position is defined correctly' { + [String]$Function.Parameters.Checksum.Attributes.Position | Should be '2' + } + It 'Does Checksum Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Checksum Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Checksum Parameter use advanced parameter Validation? ' { + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Checksum '{ + $function.Definition.Contains('.PARAMETER Checksum') | Should Be 'True' + } + It 'Has a Parameter called BufferSize' { + $Function.Parameters.Keys.Contains('BufferSize') | Should Be 'True' + } + It 'BufferSize Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.BufferSize.Attributes.Mandatory | Should be 'False' + } + It 'BufferSize Parameter is of UInt32 Type' { + $Function.Parameters.BufferSize.ParameterType.FullName | Should be 'System.UInt32' + } + It 'BufferSize Parameter is member of ParameterSets' { + [String]$Function.Parameters.BufferSize.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'BufferSize Parameter Position is defined correctly' { + [String]$Function.Parameters.BufferSize.Attributes.Position | Should be '3' + } + It 'Does BufferSize Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.BufferSize.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does BufferSize Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.BufferSize.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does BufferSize Parameter use advanced parameter Validation? ' { + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for BufferSize '{ + $function.Definition.Contains('.PARAMETER BufferSize') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetVirtualMachineProperties.Functional.Tests.ps1 b/Private/Tests/GetVirtualMachineProperties.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetVirtualMachineProperties.Tests.ps1 b/Private/Tests/GetVirtualMachineProperties.Tests.ps1 new file mode 100644 index 00000000..aa70491e --- /dev/null +++ b/Private/Tests/GetVirtualMachineProperties.Tests.ps1 @@ -0,0 +1,376 @@ +Describe 'GetVirtualMachineProperties Tests' { + + Context 'Parameters for GetVirtualMachineProperties'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called SwitchName' { + $Function.Parameters.Keys.Contains('SwitchName') | Should Be 'True' + } + It 'SwitchName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.SwitchName.Attributes.Mandatory | Should be 'True' + } + It 'SwitchName Parameter is of String[] Type' { + $Function.Parameters.SwitchName.ParameterType.FullName | Should be 'System.String[]' + } + It 'SwitchName Parameter is member of ParameterSets' { + [String]$Function.Parameters.SwitchName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SwitchName Parameter Position is defined correctly' { + [String]$Function.Parameters.SwitchName.Attributes.Position | Should be '1' + } + It 'Does SwitchName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SwitchName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does SwitchName Parameter use advanced parameter Validation? ' { + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SwitchName '{ + $function.Definition.Contains('.PARAMETER SwitchName') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'True' + } + It 'Media Parameter is of String Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.String' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '2' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called StartupMemory' { + $Function.Parameters.Keys.Contains('StartupMemory') | Should Be 'True' + } + It 'StartupMemory Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.StartupMemory.Attributes.Mandatory | Should be 'True' + } + It 'StartupMemory Parameter is of UInt64 Type' { + $Function.Parameters.StartupMemory.ParameterType.FullName | Should be 'System.UInt64' + } + It 'StartupMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.StartupMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'StartupMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.StartupMemory.Attributes.Position | Should be '3' + } + It 'Does StartupMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does StartupMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does StartupMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for StartupMemory '{ + $function.Definition.Contains('.PARAMETER StartupMemory') | Should Be 'True' + } + It 'Has a Parameter called MinimumMemory' { + $Function.Parameters.Keys.Contains('MinimumMemory') | Should Be 'True' + } + It 'MinimumMemory Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MinimumMemory.Attributes.Mandatory | Should be 'True' + } + It 'MinimumMemory Parameter is of UInt64 Type' { + $Function.Parameters.MinimumMemory.ParameterType.FullName | Should be 'System.UInt64' + } + It 'MinimumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MinimumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumMemory.Attributes.Position | Should be '4' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MinimumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumMemory '{ + $function.Definition.Contains('.PARAMETER MinimumMemory') | Should Be 'True' + } + It 'Has a Parameter called MaximumMemory' { + $Function.Parameters.Keys.Contains('MaximumMemory') | Should Be 'True' + } + It 'MaximumMemory Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MaximumMemory.Attributes.Mandatory | Should be 'True' + } + It 'MaximumMemory Parameter is of UInt64 Type' { + $Function.Parameters.MaximumMemory.ParameterType.FullName | Should be 'System.UInt64' + } + It 'MaximumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MaximumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MaximumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MaximumMemory.Attributes.Position | Should be '5' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MaximumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MaximumMemory '{ + $function.Definition.Contains('.PARAMETER MaximumMemory') | Should Be 'True' + } + It 'Has a Parameter called ProcessorCount' { + $Function.Parameters.Keys.Contains('ProcessorCount') | Should Be 'True' + } + It 'ProcessorCount Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ProcessorCount.Attributes.Mandatory | Should be 'True' + } + It 'ProcessorCount Parameter is of Int32 Type' { + $Function.Parameters.ProcessorCount.ParameterType.FullName | Should be 'System.Int32' + } + It 'ProcessorCount Parameter is member of ParameterSets' { + [String]$Function.Parameters.ProcessorCount.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ProcessorCount Parameter Position is defined correctly' { + [String]$Function.Parameters.ProcessorCount.Attributes.Position | Should be '6' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ProcessorCount Parameter use advanced parameter Validation? ' { + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ProcessorCount '{ + $function.Definition.Contains('.PARAMETER ProcessorCount') | Should Be 'True' + } + It 'Has a Parameter called MACAddress' { + $Function.Parameters.Keys.Contains('MACAddress') | Should Be 'True' + } + It 'MACAddress Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MACAddress.Attributes.Mandatory | Should be 'False' + } + It 'MACAddress Parameter is of String[] Type' { + $Function.Parameters.MACAddress.ParameterType.FullName | Should be 'System.String[]' + } + It 'MACAddress Parameter is member of ParameterSets' { + [String]$Function.Parameters.MACAddress.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MACAddress Parameter Position is defined correctly' { + [String]$Function.Parameters.MACAddress.Attributes.Position | Should be '7' + } + It 'Does MACAddress Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MACAddress.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MACAddress Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MACAddress.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MACAddress Parameter use advanced parameter Validation? ' { + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MACAddress '{ + $function.Definition.Contains('.PARAMETER MACAddress') | Should Be 'True' + } + It 'Has a Parameter called SecureBoot' { + $Function.Parameters.Keys.Contains('SecureBoot') | Should Be 'True' + } + It 'SecureBoot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SecureBoot.Attributes.Mandatory | Should be 'False' + } + It 'SecureBoot Parameter is of Boolean Type' { + $Function.Parameters.SecureBoot.ParameterType.FullName | Should be 'System.Boolean' + } + It 'SecureBoot Parameter is member of ParameterSets' { + [String]$Function.Parameters.SecureBoot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SecureBoot Parameter Position is defined correctly' { + [String]$Function.Parameters.SecureBoot.Attributes.Position | Should be '8' + } + It 'Does SecureBoot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SecureBoot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does SecureBoot Parameter use advanced parameter Validation? ' { + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SecureBoot '{ + $function.Definition.Contains('.PARAMETER SecureBoot') | Should Be 'True' + } + It 'Has a Parameter called GuestIntegrationServices' { + $Function.Parameters.Keys.Contains('GuestIntegrationServices') | Should Be 'True' + } + It 'GuestIntegrationServices Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Mandatory | Should be 'False' + } + It 'GuestIntegrationServices Parameter is of Boolean Type' { + $Function.Parameters.GuestIntegrationServices.ParameterType.FullName | Should be 'System.Boolean' + } + It 'GuestIntegrationServices Parameter is member of ParameterSets' { + [String]$Function.Parameters.GuestIntegrationServices.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'GuestIntegrationServices Parameter Position is defined correctly' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Position | Should be '9' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does GuestIntegrationServices Parameter use advanced parameter Validation? ' { + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for GuestIntegrationServices '{ + $function.Definition.Contains('.PARAMETER GuestIntegrationServices') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '10' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetWindowsImageIndex.Functional.Tests.ps1 b/Private/Tests/GetWindowsImageIndex.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetWindowsImageIndex.Tests.ps1 b/Private/Tests/GetWindowsImageIndex.Tests.ps1 new file mode 100644 index 00000000..12e0cddf --- /dev/null +++ b/Private/Tests/GetWindowsImageIndex.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'GetWindowsImageIndex Tests' { + + Context 'Parameters for GetWindowsImageIndex'{ + + It 'Has a Parameter called ImagePath' { + $Function.Parameters.Keys.Contains('ImagePath') | Should Be 'True' + } + It 'ImagePath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ImagePath.Attributes.Mandatory | Should be 'True' + } + It 'ImagePath Parameter is of String Type' { + $Function.Parameters.ImagePath.ParameterType.FullName | Should be 'System.String' + } + It 'ImagePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ImagePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ImagePath Parameter Position is defined correctly' { + [String]$Function.Parameters.ImagePath.Attributes.Position | Should be '0' + } + It 'Does ImagePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ImagePath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ImagePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ImagePath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ImagePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ImagePath '{ + $function.Definition.Contains('.PARAMETER ImagePath') | Should Be 'True' + } + It 'Has a Parameter called ImageName' { + $Function.Parameters.Keys.Contains('ImageName') | Should Be 'True' + } + It 'ImageName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ImageName.Attributes.Mandatory | Should be 'True' + } + It 'ImageName Parameter is of String Type' { + $Function.Parameters.ImageName.ParameterType.FullName | Should be 'System.String' + } + It 'ImageName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ImageName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ImageName Parameter Position is defined correctly' { + [String]$Function.Parameters.ImageName.Attributes.Position | Should be '1' + } + It 'Does ImageName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ImageName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ImageName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ImageName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ImageName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ImageName '{ + $function.Definition.Contains('.PARAMETER ImageName') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/GetWindowsImageName.Functional.Tests.ps1 b/Private/Tests/GetWindowsImageName.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/GetWindowsImageName.Tests.ps1 b/Private/Tests/GetWindowsImageName.Tests.ps1 new file mode 100644 index 00000000..63c2e97c --- /dev/null +++ b/Private/Tests/GetWindowsImageName.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'GetWindowsImageName Tests' { + + Context 'Parameters for GetWindowsImageName'{ + + It 'Has a Parameter called ImagePath' { + $Function.Parameters.Keys.Contains('ImagePath') | Should Be 'True' + } + It 'ImagePath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ImagePath.Attributes.Mandatory | Should be 'True' + } + It 'ImagePath Parameter is of String Type' { + $Function.Parameters.ImagePath.ParameterType.FullName | Should be 'System.String' + } + It 'ImagePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ImagePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ImagePath Parameter Position is defined correctly' { + [String]$Function.Parameters.ImagePath.Attributes.Position | Should be '0' + } + It 'Does ImagePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ImagePath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ImagePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ImagePath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ImagePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ImagePath '{ + $function.Definition.Contains('.PARAMETER ImagePath') | Should Be 'True' + } + It 'Has a Parameter called ImageIndex' { + $Function.Parameters.Keys.Contains('ImageIndex') | Should Be 'True' + } + It 'ImageIndex Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ImageIndex.Attributes.Mandatory | Should be 'True' + } + It 'ImageIndex Parameter is of Int32 Type' { + $Function.Parameters.ImageIndex.ParameterType.FullName | Should be 'System.Int32' + } + It 'ImageIndex Parameter is member of ParameterSets' { + [String]$Function.Parameters.ImageIndex.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ImageIndex Parameter Position is defined correctly' { + [String]$Function.Parameters.ImageIndex.Attributes.Position | Should be '1' + } + It 'Does ImageIndex Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ImageIndex.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ImageIndex Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ImageIndex.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ImageIndex Parameter use advanced parameter Validation? ' { + $Function.Parameters.ImageIndex.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ImageIndex.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ImageIndex.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ImageIndex.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ImageIndex.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ImageIndex '{ + $function.Definition.Contains('.PARAMETER ImageIndex') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ImportDismModule.Functional.Tests.ps1 b/Private/Tests/ImportDismModule.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ImportDismModule.Tests.ps1 b/Private/Tests/ImportDismModule.Tests.ps1 new file mode 100644 index 00000000..05301296 --- /dev/null +++ b/Private/Tests/ImportDismModule.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'ImportDismModule Tests' { + + Context 'Parameters for ImportDismModule'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ImportDscResource.Functional.Tests.ps1 b/Private/Tests/ImportDscResource.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ImportDscResource.Tests.ps1 b/Private/Tests/ImportDscResource.Tests.ps1 new file mode 100644 index 00000000..ab869854 --- /dev/null +++ b/Private/Tests/ImportDscResource.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'ImportDscResource Tests' { + + Context 'Parameters for ImportDscResource'{ + + It 'Has a Parameter called ModuleName' { + $Function.Parameters.Keys.Contains('ModuleName') | Should Be 'True' + } + It 'ModuleName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ModuleName.Attributes.Mandatory | Should be 'True' + } + It 'ModuleName Parameter is of String Type' { + $Function.Parameters.ModuleName.ParameterType.FullName | Should be 'System.String' + } + It 'ModuleName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ModuleName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ModuleName Parameter Position is defined correctly' { + [String]$Function.Parameters.ModuleName.Attributes.Position | Should be '0' + } + It 'Does ModuleName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ModuleName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ModuleName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ModuleName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ModuleName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ModuleName '{ + $function.Definition.Contains('.PARAMETER ModuleName') | Should Be 'True' + } + It 'Has a Parameter called ResourceName' { + $Function.Parameters.Keys.Contains('ResourceName') | Should Be 'True' + } + It 'ResourceName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ResourceName.Attributes.Mandatory | Should be 'True' + } + It 'ResourceName Parameter is of String Type' { + $Function.Parameters.ResourceName.ParameterType.FullName | Should be 'System.String' + } + It 'ResourceName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourceName Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceName.Attributes.Position | Should be '1' + } + It 'Does ResourceName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourceName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ResourceName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceName '{ + $function.Definition.Contains('.PARAMETER ResourceName') | Should Be 'True' + } + It 'Has a Parameter called Prefix' { + $Function.Parameters.Keys.Contains('Prefix') | Should Be 'True' + } + It 'Prefix Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Prefix.Attributes.Mandatory | Should be 'False' + } + It 'Prefix Parameter is of String Type' { + $Function.Parameters.Prefix.ParameterType.FullName | Should be 'System.String' + } + It 'Prefix Parameter is member of ParameterSets' { + [String]$Function.Parameters.Prefix.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Prefix Parameter Position is defined correctly' { + [String]$Function.Parameters.Prefix.Attributes.Position | Should be '2' + } + It 'Does Prefix Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Prefix.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Prefix Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Prefix.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Prefix Parameter use advanced parameter Validation? ' { + $Function.Parameters.Prefix.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Prefix.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Prefix.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Prefix.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Prefix.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Prefix '{ + $function.Definition.Contains('.PARAMETER Prefix') | Should Be 'True' + } + It 'Has a Parameter called UseDefault' { + $Function.Parameters.Keys.Contains('UseDefault') | Should Be 'True' + } + It 'UseDefault Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.UseDefault.Attributes.Mandatory | Should be 'False' + } + It 'UseDefault Parameter is of SwitchParameter Type' { + $Function.Parameters.UseDefault.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'UseDefault Parameter is member of ParameterSets' { + [String]$Function.Parameters.UseDefault.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'UseDefault Parameter Position is defined correctly' { + [String]$Function.Parameters.UseDefault.Attributes.Position | Should be '-2147483648' + } + It 'Does UseDefault Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.UseDefault.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does UseDefault Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.UseDefault.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does UseDefault Parameter use advanced parameter Validation? ' { + $Function.Parameters.UseDefault.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.UseDefault.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.UseDefault.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.UseDefault.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.UseDefault.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for UseDefault '{ + $function.Definition.Contains('.PARAMETER UseDefault') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/InvokeDscResource.Functional.Tests.ps1 b/Private/Tests/InvokeDscResource.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/InvokeDscResource.Tests.ps1 b/Private/Tests/InvokeDscResource.Tests.ps1 new file mode 100644 index 00000000..37a57b66 --- /dev/null +++ b/Private/Tests/InvokeDscResource.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'InvokeDscResource Tests' { + + Context 'Parameters for InvokeDscResource'{ + + It 'Has a Parameter called ResourceName' { + $Function.Parameters.Keys.Contains('ResourceName') | Should Be 'True' + } + It 'ResourceName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ResourceName.Attributes.Mandatory | Should be 'True' + } + It 'ResourceName Parameter is of String Type' { + $Function.Parameters.ResourceName.ParameterType.FullName | Should be 'System.String' + } + It 'ResourceName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourceName Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceName.Attributes.Position | Should be '0' + } + It 'Does ResourceName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourceName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ResourceName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceName '{ + $function.Definition.Contains('.PARAMETER ResourceName') | Should Be 'True' + } + It 'Has a Parameter called Parameters' { + $Function.Parameters.Keys.Contains('Parameters') | Should Be 'True' + } + It 'Parameters Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Parameters.Attributes.Mandatory | Should be 'True' + } + It 'Parameters Parameter is of Hashtable Type' { + $Function.Parameters.Parameters.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'Parameters Parameter is member of ParameterSets' { + [String]$Function.Parameters.Parameters.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Parameters Parameter Position is defined correctly' { + [String]$Function.Parameters.Parameters.Attributes.Position | Should be '1' + } + It 'Does Parameters Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Parameters.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Parameters Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Parameters.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Parameters Parameter use advanced parameter Validation? ' { + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Parameters '{ + $function.Definition.Contains('.PARAMETER Parameters') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/InvokeExecutable.Functional.Tests.ps1 b/Private/Tests/InvokeExecutable.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/InvokeExecutable.Tests.ps1 b/Private/Tests/InvokeExecutable.Tests.ps1 new file mode 100644 index 00000000..82fefe91 --- /dev/null +++ b/Private/Tests/InvokeExecutable.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'InvokeExecutable Tests' { + + Context 'Parameters for InvokeExecutable'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called Arguments' { + $Function.Parameters.Keys.Contains('Arguments') | Should Be 'True' + } + It 'Arguments Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Arguments.Attributes.Mandatory | Should be 'True' + } + It 'Arguments Parameter is of Array Type' { + $Function.Parameters.Arguments.ParameterType.FullName | Should be 'System.Array' + } + It 'Arguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.Arguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Arguments Parameter Position is defined correctly' { + [String]$Function.Parameters.Arguments.Attributes.Position | Should be '1' + } + It 'Does Arguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Arguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Arguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Arguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Arguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.Arguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Arguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Arguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Arguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Arguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Arguments '{ + $function.Definition.Contains('.PARAMETER Arguments') | Should Be 'True' + } + It 'Has a Parameter called LogName' { + $Function.Parameters.Keys.Contains('LogName') | Should Be 'True' + } + It 'LogName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.LogName.Attributes.Mandatory | Should be 'False' + } + It 'LogName Parameter is of String Type' { + $Function.Parameters.LogName.ParameterType.FullName | Should be 'System.String' + } + It 'LogName Parameter is member of ParameterSets' { + [String]$Function.Parameters.LogName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'LogName Parameter Position is defined correctly' { + [String]$Function.Parameters.LogName.Attributes.Position | Should be '2' + } + It 'Does LogName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.LogName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does LogName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.LogName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does LogName Parameter use advanced parameter Validation? ' { + $Function.Parameters.LogName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.LogName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.LogName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.LogName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.LogName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for LogName '{ + $function.Definition.Contains('.PARAMETER LogName') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/InvokeLabMediaHotfixDownload.Functional.Tests.ps1 b/Private/Tests/InvokeLabMediaHotfixDownload.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/InvokeLabMediaHotfixDownload.Tests.ps1 b/Private/Tests/InvokeLabMediaHotfixDownload.Tests.ps1 new file mode 100644 index 00000000..0619e45a --- /dev/null +++ b/Private/Tests/InvokeLabMediaHotfixDownload.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'InvokeLabMediaHotfixDownload Tests' { + + Context 'Parameters for InvokeLabMediaHotfixDownload'{ + + It 'Has a Parameter called Id' { + $Function.Parameters.Keys.Contains('Id') | Should Be 'True' + } + It 'Id Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Id.Attributes.Mandatory | Should be 'True' + } + It 'Id Parameter is of String Type' { + $Function.Parameters.Id.ParameterType.FullName | Should be 'System.String' + } + It 'Id Parameter is member of ParameterSets' { + [String]$Function.Parameters.Id.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Id Parameter Position is defined correctly' { + [String]$Function.Parameters.Id.Attributes.Position | Should be '0' + } + It 'Does Id Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Id Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Id Parameter use advanced parameter Validation? ' { + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Id '{ + $function.Definition.Contains('.PARAMETER Id') | Should Be 'True' + } + It 'Has a Parameter called Uri' { + $Function.Parameters.Keys.Contains('Uri') | Should Be 'True' + } + It 'Uri Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Uri.Attributes.Mandatory | Should be 'True' + } + It 'Uri Parameter is of String Type' { + $Function.Parameters.Uri.ParameterType.FullName | Should be 'System.String' + } + It 'Uri Parameter is member of ParameterSets' { + [String]$Function.Parameters.Uri.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Uri Parameter Position is defined correctly' { + [String]$Function.Parameters.Uri.Attributes.Position | Should be '1' + } + It 'Does Uri Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Uri Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Uri Parameter use advanced parameter Validation? ' { + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Uri '{ + $function.Definition.Contains('.PARAMETER Uri') | Should Be 'True' + } + It 'Has a Parameter called Checksum' { + $Function.Parameters.Keys.Contains('Checksum') | Should Be 'True' + } + It 'Checksum Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Checksum.Attributes.Mandatory | Should be 'False' + } + It 'Checksum Parameter is of String Type' { + $Function.Parameters.Checksum.ParameterType.FullName | Should be 'System.String' + } + It 'Checksum Parameter is member of ParameterSets' { + [String]$Function.Parameters.Checksum.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Checksum Parameter Position is defined correctly' { + [String]$Function.Parameters.Checksum.Attributes.Position | Should be '2' + } + It 'Does Checksum Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Checksum Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Checksum Parameter use advanced parameter Validation? ' { + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Checksum '{ + $function.Definition.Contains('.PARAMETER Checksum') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/InvokeLabMediaImageDownload.Functional.Tests.ps1 b/Private/Tests/InvokeLabMediaImageDownload.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/InvokeLabMediaImageDownload.Tests.ps1 b/Private/Tests/InvokeLabMediaImageDownload.Tests.ps1 new file mode 100644 index 00000000..aa342edc --- /dev/null +++ b/Private/Tests/InvokeLabMediaImageDownload.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'InvokeLabMediaImageDownload Tests' { + + Context 'Parameters for InvokeLabMediaImageDownload'{ + + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'True' + } + It 'Media Parameter is of Object Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.Object' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '0' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/InvokeModuleCacheDownload.Functional.Tests.ps1 b/Private/Tests/InvokeModuleCacheDownload.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/InvokeModuleCacheDownload.Tests.ps1 b/Private/Tests/InvokeModuleCacheDownload.Tests.ps1 new file mode 100644 index 00000000..390c16b4 --- /dev/null +++ b/Private/Tests/InvokeModuleCacheDownload.Tests.ps1 @@ -0,0 +1,407 @@ +Describe 'InvokeModuleCacheDownload Tests' { + + Context 'Parameters for InvokeModuleCacheDownload'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True True True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True True True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called MinimumVersion' { + $Function.Parameters.Keys.Contains('MinimumVersion') | Should Be 'True' + } + It 'MinimumVersion Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MinimumVersion.Attributes.Mandatory | Should be 'True' + } + It 'MinimumVersion Parameter is of Version Type' { + $Function.Parameters.MinimumVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'MinimumVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumVersion.ParameterSets.Keys | Should Be 'NameMinimum' + } + It 'MinimumVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumVersion.Attributes.Position | Should be '-2147483648' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MinimumVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumVersion '{ + $function.Definition.Contains('.PARAMETER MinimumVersion') | Should Be 'True' + } + It 'Has a Parameter called RequiredVersion' { + $Function.Parameters.Keys.Contains('RequiredVersion') | Should Be 'True' + } + It 'RequiredVersion Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.RequiredVersion.Attributes.Mandatory | Should be 'True' + } + It 'RequiredVersion Parameter is of Version Type' { + $Function.Parameters.RequiredVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'RequiredVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.RequiredVersion.ParameterSets.Keys | Should Be 'NameRequired' + } + It 'RequiredVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.RequiredVersion.Attributes.Position | Should be '-2147483648' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RequiredVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RequiredVersion '{ + $function.Definition.Contains('.PARAMETER RequiredVersion') | Should Be 'True' + } + It 'Has a Parameter called Owner' { + $Function.Parameters.Keys.Contains('Owner') | Should Be 'True' + } + It 'Owner Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Owner.Attributes.Mandatory | Should be 'False False False' + } + It 'Owner Parameter is of String Type' { + $Function.Parameters.Owner.ParameterType.FullName | Should be 'System.String' + } + It 'Owner Parameter is member of ParameterSets' { + [String]$Function.Parameters.Owner.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Owner Parameter Position is defined correctly' { + [String]$Function.Parameters.Owner.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Owner Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Owner.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Owner Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Owner.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Owner Parameter use advanced parameter Validation? ' { + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Owner '{ + $function.Definition.Contains('.PARAMETER Owner') | Should Be 'True' + } + It 'Has a Parameter called Repository' { + $Function.Parameters.Keys.Contains('Repository') | Should Be 'True' + } + It 'Repository Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Repository.Attributes.Mandatory | Should be 'False False False' + } + It 'Repository Parameter is of String Type' { + $Function.Parameters.Repository.ParameterType.FullName | Should be 'System.String' + } + It 'Repository Parameter is member of ParameterSets' { + [String]$Function.Parameters.Repository.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Repository Parameter Position is defined correctly' { + [String]$Function.Parameters.Repository.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Repository Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Repository.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Repository Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Repository.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Repository Parameter use advanced parameter Validation? ' { + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Repository '{ + $function.Definition.Contains('.PARAMETER Repository') | Should Be 'True' + } + It 'Has a Parameter called Branch' { + $Function.Parameters.Keys.Contains('Branch') | Should Be 'True' + } + It 'Branch Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Branch.Attributes.Mandatory | Should be 'False False False' + } + It 'Branch Parameter is of String Type' { + $Function.Parameters.Branch.ParameterType.FullName | Should be 'System.String' + } + It 'Branch Parameter is member of ParameterSets' { + [String]$Function.Parameters.Branch.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Branch Parameter Position is defined correctly' { + [String]$Function.Parameters.Branch.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Branch Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Branch.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Branch Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Branch.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Branch Parameter use advanced parameter Validation? ' { + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Branch '{ + $function.Definition.Contains('.PARAMETER Branch') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'False False False' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called Provider' { + $Function.Parameters.Keys.Contains('Provider') | Should Be 'True' + } + It 'Provider Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Provider.Attributes.Mandatory | Should be 'False False False' + } + It 'Provider Parameter is of String Type' { + $Function.Parameters.Provider.ParameterType.FullName | Should be 'System.String' + } + It 'Provider Parameter is member of ParameterSets' { + [String]$Function.Parameters.Provider.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Provider Parameter Position is defined correctly' { + [String]$Function.Parameters.Provider.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Provider Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Provider.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Provider Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Provider.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Provider Parameter use advanced parameter Validation? ' { + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Provider '{ + $function.Definition.Contains('.PARAMETER Provider') | Should Be 'True' + } + It 'Has a Parameter called Module' { + $Function.Parameters.Keys.Contains('Module') | Should Be 'True' + } + It 'Module Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Module.Attributes.Mandatory | Should be 'True' + } + It 'Module Parameter is of Hashtable[] Type' { + $Function.Parameters.Module.ParameterType.FullName | Should be 'System.Collections.Hashtable[]' + } + It 'Module Parameter is member of ParameterSets' { + [String]$Function.Parameters.Module.ParameterSets.Keys | Should Be 'Module' + } + It 'Module Parameter Position is defined correctly' { + [String]$Function.Parameters.Module.Attributes.Position | Should be '-2147483648' + } + It 'Does Module Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Module.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Module Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Module.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Module Parameter use advanced parameter Validation? ' { + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Module '{ + $function.Definition.Contains('.PARAMETER Module') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'False' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '-2147483648' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '-2147483648' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/InvokeModuleDownloadFromGitHub.Functional.Tests.ps1 b/Private/Tests/InvokeModuleDownloadFromGitHub.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/InvokeModuleDownloadFromGitHub.Tests.ps1 b/Private/Tests/InvokeModuleDownloadFromGitHub.Tests.ps1 new file mode 100644 index 00000000..ac982af8 --- /dev/null +++ b/Private/Tests/InvokeModuleDownloadFromGitHub.Tests.ps1 @@ -0,0 +1,283 @@ +Describe 'InvokeModuleDownloadFromGitHub Tests' { + + Context 'Parameters for InvokeModuleDownloadFromGitHub'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'False' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '1' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Owner' { + $Function.Parameters.Keys.Contains('Owner') | Should Be 'True' + } + It 'Owner Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Owner.Attributes.Mandatory | Should be 'False' + } + It 'Owner Parameter is of String Type' { + $Function.Parameters.Owner.ParameterType.FullName | Should be 'System.String' + } + It 'Owner Parameter is member of ParameterSets' { + [String]$Function.Parameters.Owner.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Owner Parameter Position is defined correctly' { + [String]$Function.Parameters.Owner.Attributes.Position | Should be '2' + } + It 'Does Owner Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Owner.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Owner Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Owner.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Owner Parameter use advanced parameter Validation? ' { + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Owner '{ + $function.Definition.Contains('.PARAMETER Owner') | Should Be 'True' + } + It 'Has a Parameter called Repository' { + $Function.Parameters.Keys.Contains('Repository') | Should Be 'True' + } + It 'Repository Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Repository.Attributes.Mandatory | Should be 'False' + } + It 'Repository Parameter is of String Type' { + $Function.Parameters.Repository.ParameterType.FullName | Should be 'System.String' + } + It 'Repository Parameter is member of ParameterSets' { + [String]$Function.Parameters.Repository.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Repository Parameter Position is defined correctly' { + [String]$Function.Parameters.Repository.Attributes.Position | Should be '3' + } + It 'Does Repository Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Repository.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Repository Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Repository.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Repository Parameter use advanced parameter Validation? ' { + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Repository '{ + $function.Definition.Contains('.PARAMETER Repository') | Should Be 'True' + } + It 'Has a Parameter called Branch' { + $Function.Parameters.Keys.Contains('Branch') | Should Be 'True' + } + It 'Branch Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Branch.Attributes.Mandatory | Should be 'False' + } + It 'Branch Parameter is of String Type' { + $Function.Parameters.Branch.ParameterType.FullName | Should be 'System.String' + } + It 'Branch Parameter is member of ParameterSets' { + [String]$Function.Parameters.Branch.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Branch Parameter Position is defined correctly' { + [String]$Function.Parameters.Branch.Attributes.Position | Should be '4' + } + It 'Does Branch Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Branch.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Branch Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Branch.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Branch Parameter use advanced parameter Validation? ' { + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Branch '{ + $function.Definition.Contains('.PARAMETER Branch') | Should Be 'True' + } + It 'Has a Parameter called OverrideRepositoryName' { + $Function.Parameters.Keys.Contains('OverrideRepositoryName') | Should Be 'True' + } + It 'OverrideRepositoryName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.OverrideRepositoryName.Attributes.Mandatory | Should be 'False' + } + It 'OverrideRepositoryName Parameter is of String Type' { + $Function.Parameters.OverrideRepositoryName.ParameterType.FullName | Should be 'System.String' + } + It 'OverrideRepositoryName Parameter is member of ParameterSets' { + [String]$Function.Parameters.OverrideRepositoryName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'OverrideRepositoryName Parameter Position is defined correctly' { + [String]$Function.Parameters.OverrideRepositoryName.Attributes.Position | Should be '5' + } + It 'Does OverrideRepositoryName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.OverrideRepositoryName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does OverrideRepositoryName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.OverrideRepositoryName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does OverrideRepositoryName Parameter use advanced parameter Validation? ' { + $Function.Parameters.OverrideRepositoryName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.OverrideRepositoryName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.OverrideRepositoryName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.OverrideRepositoryName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.OverrideRepositoryName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for OverrideRepositoryName '{ + $function.Definition.Contains('.PARAMETER OverrideRepositoryName') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '6' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/InvokeModuleDownloadFromPSGallery.Functional.Tests.ps1 b/Private/Tests/InvokeModuleDownloadFromPSGallery.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/InvokeModuleDownloadFromPSGallery.Tests.ps1 b/Private/Tests/InvokeModuleDownloadFromPSGallery.Tests.ps1 new file mode 100644 index 00000000..e8df3be0 --- /dev/null +++ b/Private/Tests/InvokeModuleDownloadFromPSGallery.Tests.ps1 @@ -0,0 +1,190 @@ +Describe 'InvokeModuleDownloadFromPSGallery Tests' { + + Context 'Parameters for InvokeModuleDownloadFromPSGallery'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '-2147483648' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'False' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '-2147483648' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called MinimumVersion' { + $Function.Parameters.Keys.Contains('MinimumVersion') | Should Be 'True' + } + It 'MinimumVersion Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MinimumVersion.Attributes.Mandatory | Should be 'True' + } + It 'MinimumVersion Parameter is of Version Type' { + $Function.Parameters.MinimumVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'MinimumVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumVersion.ParameterSets.Keys | Should Be 'MinimumVersion' + } + It 'MinimumVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumVersion.Attributes.Position | Should be '-2147483648' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MinimumVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumVersion '{ + $function.Definition.Contains('.PARAMETER MinimumVersion') | Should Be 'True' + } + It 'Has a Parameter called RequiredVersion' { + $Function.Parameters.Keys.Contains('RequiredVersion') | Should Be 'True' + } + It 'RequiredVersion Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.RequiredVersion.Attributes.Mandatory | Should be 'True' + } + It 'RequiredVersion Parameter is of Version Type' { + $Function.Parameters.RequiredVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'RequiredVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.RequiredVersion.ParameterSets.Keys | Should Be 'RequiredVersion' + } + It 'RequiredVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.RequiredVersion.Attributes.Position | Should be '-2147483648' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RequiredVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RequiredVersion '{ + $function.Definition.Contains('.PARAMETER RequiredVersion') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '-2147483648' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/InvokeResourceDownload.Functional.Tests.ps1 b/Private/Tests/InvokeResourceDownload.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/InvokeResourceDownload.Tests.ps1 b/Private/Tests/InvokeResourceDownload.Tests.ps1 new file mode 100644 index 00000000..7b6e6c9b --- /dev/null +++ b/Private/Tests/InvokeResourceDownload.Tests.ps1 @@ -0,0 +1,190 @@ +Describe 'InvokeResourceDownload Tests' { + + Context 'Parameters for InvokeResourceDownload'{ + + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '0' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Uri' { + $Function.Parameters.Keys.Contains('Uri') | Should Be 'True' + } + It 'Uri Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Uri.Attributes.Mandatory | Should be 'True' + } + It 'Uri Parameter is of String Type' { + $Function.Parameters.Uri.ParameterType.FullName | Should be 'System.String' + } + It 'Uri Parameter is member of ParameterSets' { + [String]$Function.Parameters.Uri.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Uri Parameter Position is defined correctly' { + [String]$Function.Parameters.Uri.Attributes.Position | Should be '1' + } + It 'Does Uri Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Uri Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Uri Parameter use advanced parameter Validation? ' { + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Uri '{ + $function.Definition.Contains('.PARAMETER Uri') | Should Be 'True' + } + It 'Has a Parameter called Checksum' { + $Function.Parameters.Keys.Contains('Checksum') | Should Be 'True' + } + It 'Checksum Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Checksum.Attributes.Mandatory | Should be 'False' + } + It 'Checksum Parameter is of String Type' { + $Function.Parameters.Checksum.ParameterType.FullName | Should be 'System.String' + } + It 'Checksum Parameter is member of ParameterSets' { + [String]$Function.Parameters.Checksum.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Checksum Parameter Position is defined correctly' { + [String]$Function.Parameters.Checksum.Attributes.Position | Should be '2' + } + It 'Does Checksum Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Checksum Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Checksum Parameter use advanced parameter Validation? ' { + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Checksum '{ + $function.Definition.Contains('.PARAMETER Checksum') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + It 'Has a Parameter called BufferSize' { + $Function.Parameters.Keys.Contains('BufferSize') | Should Be 'True' + } + It 'BufferSize Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.BufferSize.Attributes.Mandatory | Should be 'False' + } + It 'BufferSize Parameter is of UInt32 Type' { + $Function.Parameters.BufferSize.ParameterType.FullName | Should be 'System.UInt32' + } + It 'BufferSize Parameter is member of ParameterSets' { + [String]$Function.Parameters.BufferSize.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'BufferSize Parameter Position is defined correctly' { + [String]$Function.Parameters.BufferSize.Attributes.Position | Should be '3' + } + It 'Does BufferSize Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.BufferSize.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does BufferSize Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.BufferSize.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does BufferSize Parameter use advanced parameter Validation? ' { + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for BufferSize '{ + $function.Definition.Contains('.PARAMETER BufferSize') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/InvokeWebClientDownload.Functional.Tests.ps1 b/Private/Tests/InvokeWebClientDownload.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/InvokeWebClientDownload.Tests.ps1 b/Private/Tests/InvokeWebClientDownload.Tests.ps1 new file mode 100644 index 00000000..c50a93f9 --- /dev/null +++ b/Private/Tests/InvokeWebClientDownload.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'InvokeWebClientDownload Tests' { + + Context 'Parameters for InvokeWebClientDownload'{ + + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '0' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Uri' { + $Function.Parameters.Keys.Contains('Uri') | Should Be 'True' + } + It 'Uri Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Uri.Attributes.Mandatory | Should be 'True' + } + It 'Uri Parameter is of String Type' { + $Function.Parameters.Uri.ParameterType.FullName | Should be 'System.String' + } + It 'Uri Parameter is member of ParameterSets' { + [String]$Function.Parameters.Uri.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Uri Parameter Position is defined correctly' { + [String]$Function.Parameters.Uri.Attributes.Position | Should be '1' + } + It 'Does Uri Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Uri Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Uri Parameter use advanced parameter Validation? ' { + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Uri '{ + $function.Definition.Contains('.PARAMETER Uri') | Should Be 'True' + } + It 'Has a Parameter called BufferSize' { + $Function.Parameters.Keys.Contains('BufferSize') | Should Be 'True' + } + It 'BufferSize Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.BufferSize.Attributes.Mandatory | Should be 'False' + } + It 'BufferSize Parameter is of UInt32 Type' { + $Function.Parameters.BufferSize.ParameterType.FullName | Should be 'System.UInt32' + } + It 'BufferSize Parameter is member of ParameterSets' { + [String]$Function.Parameters.BufferSize.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'BufferSize Parameter Position is defined correctly' { + [String]$Function.Parameters.BufferSize.Attributes.Position | Should be '2' + } + It 'Does BufferSize Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.BufferSize.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does BufferSize Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.BufferSize.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does BufferSize Parameter use advanced parameter Validation? ' { + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for BufferSize '{ + $function.Definition.Contains('.PARAMETER BufferSize') | Should Be 'True' + } + It 'Has a Parameter called Credential' { + $Function.Parameters.Keys.Contains('Credential') | Should Be 'True' + } + It 'Credential Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Credential.Attributes.Mandatory | Should be 'False' + } + It 'Credential Parameter is of PSCredential Type' { + $Function.Parameters.Credential.ParameterType.FullName | Should be 'System.Management.Automation.PSCredential' + } + It 'Credential Parameter is member of ParameterSets' { + [String]$Function.Parameters.Credential.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Credential Parameter Position is defined correctly' { + [String]$Function.Parameters.Credential.Attributes.Position | Should be '3' + } + It 'Does Credential Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Credential Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Credential Parameter use advanced parameter Validation? ' { + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Credential '{ + $function.Definition.Contains('.PARAMETER Credential') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/NewBootStrap.Functional.Tests.ps1 b/Private/Tests/NewBootStrap.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/NewBootStrap.Tests.ps1 b/Private/Tests/NewBootStrap.Tests.ps1 new file mode 100644 index 00000000..3ce14fba --- /dev/null +++ b/Private/Tests/NewBootStrap.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'NewBootStrap Tests' { + + Context 'Parameters for NewBootStrap'{ + + It 'Has a Parameter called CoreCLR' { + $Function.Parameters.Keys.Contains('CoreCLR') | Should Be 'True' + } + It 'CoreCLR Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CoreCLR.Attributes.Mandatory | Should be 'False' + } + It 'CoreCLR Parameter is of SwitchParameter Type' { + $Function.Parameters.CoreCLR.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'CoreCLR Parameter is member of ParameterSets' { + [String]$Function.Parameters.CoreCLR.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CoreCLR Parameter Position is defined correctly' { + [String]$Function.Parameters.CoreCLR.Attributes.Position | Should be '-2147483648' + } + It 'Does CoreCLR Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CoreCLR.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CoreCLR Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CoreCLR.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CoreCLR Parameter use advanced parameter Validation? ' { + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CoreCLR '{ + $function.Definition.Contains('.PARAMETER CoreCLR') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/NewDirectory.Functional.Tests.ps1 b/Private/Tests/NewDirectory.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/NewDirectory.Tests.ps1 b/Private/Tests/NewDirectory.Tests.ps1 new file mode 100644 index 00000000..c09a537f --- /dev/null +++ b/Private/Tests/NewDirectory.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'NewDirectory Tests' { + + Context 'Parameters for NewDirectory'{ + + It 'Has a Parameter called InputObject' { + $Function.Parameters.Keys.Contains('InputObject') | Should Be 'True' + } + It 'InputObject Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.InputObject.Attributes.Mandatory | Should be 'True' + } + It 'InputObject Parameter is of DirectoryInfo[] Type' { + $Function.Parameters.InputObject.ParameterType.FullName | Should be 'System.IO.DirectoryInfo[]' + } + It 'InputObject Parameter is member of ParameterSets' { + [String]$Function.Parameters.InputObject.ParameterSets.Keys | Should Be 'ByDirectoryInfo' + } + It 'InputObject Parameter Position is defined correctly' { + [String]$Function.Parameters.InputObject.Attributes.Position | Should be '0' + } + It 'Does InputObject Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.InputObject.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does InputObject Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.InputObject.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does InputObject Parameter use advanced parameter Validation? ' { + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for InputObject '{ + $function.Definition.Contains('.PARAMETER InputObject') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String[] Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String[]' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be 'ByString' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/NewDiskImage.Functional.Tests.ps1 b/Private/Tests/NewDiskImage.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/NewDiskImage.Tests.ps1 b/Private/Tests/NewDiskImage.Tests.ps1 new file mode 100644 index 00000000..1e5e4c8a --- /dev/null +++ b/Private/Tests/NewDiskImage.Tests.ps1 @@ -0,0 +1,190 @@ +Describe 'NewDiskImage Tests' { + + Context 'Parameters for NewDiskImage'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called PartitionStyle' { + $Function.Parameters.Keys.Contains('PartitionStyle') | Should Be 'True' + } + It 'PartitionStyle Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.PartitionStyle.Attributes.Mandatory | Should be 'True' + } + It 'PartitionStyle Parameter is of String Type' { + $Function.Parameters.PartitionStyle.ParameterType.FullName | Should be 'System.String' + } + It 'PartitionStyle Parameter is member of ParameterSets' { + [String]$Function.Parameters.PartitionStyle.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'PartitionStyle Parameter Position is defined correctly' { + [String]$Function.Parameters.PartitionStyle.Attributes.Position | Should be '1' + } + It 'Does PartitionStyle Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.PartitionStyle.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does PartitionStyle Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.PartitionStyle.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does PartitionStyle Parameter use advanced parameter Validation? ' { + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for PartitionStyle '{ + $function.Definition.Contains('.PARAMETER PartitionStyle') | Should Be 'True' + } + It 'Has a Parameter called Size' { + $Function.Parameters.Keys.Contains('Size') | Should Be 'True' + } + It 'Size Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Size.Attributes.Mandatory | Should be 'False' + } + It 'Size Parameter is of UInt64 Type' { + $Function.Parameters.Size.ParameterType.FullName | Should be 'System.UInt64' + } + It 'Size Parameter is member of ParameterSets' { + [String]$Function.Parameters.Size.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Size Parameter Position is defined correctly' { + [String]$Function.Parameters.Size.Attributes.Position | Should be '2' + } + It 'Does Size Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Size.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Size Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Size.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Size Parameter use advanced parameter Validation? ' { + $Function.Parameters.Size.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Size.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Size.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Size.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Size.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Size '{ + $function.Definition.Contains('.PARAMETER Size') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + It 'Has a Parameter called Passthru' { + $Function.Parameters.Keys.Contains('Passthru') | Should Be 'True' + } + It 'Passthru Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Passthru.Attributes.Mandatory | Should be 'False' + } + It 'Passthru Parameter is of SwitchParameter Type' { + $Function.Parameters.Passthru.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Passthru Parameter is member of ParameterSets' { + [String]$Function.Parameters.Passthru.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Passthru Parameter Position is defined correctly' { + [String]$Function.Parameters.Passthru.Attributes.Position | Should be '-2147483648' + } + It 'Does Passthru Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Passthru.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Passthru Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Passthru.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Passthru Parameter use advanced parameter Validation? ' { + $Function.Parameters.Passthru.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Passthru.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Passthru.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Passthru.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Passthru.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Passthru '{ + $function.Definition.Contains('.PARAMETER Passthru') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/NewDiskImageGpt.Functional.Tests.ps1 b/Private/Tests/NewDiskImageGpt.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/NewDiskImageGpt.Tests.ps1 b/Private/Tests/NewDiskImageGpt.Tests.ps1 new file mode 100644 index 00000000..2956471a --- /dev/null +++ b/Private/Tests/NewDiskImageGpt.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'NewDiskImageGpt Tests' { + + Context 'Parameters for NewDiskImageGpt'{ + + It 'Has a Parameter called Vhd' { + $Function.Parameters.Keys.Contains('Vhd') | Should Be 'True' + } + It 'Vhd Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Vhd.Attributes.Mandatory | Should be 'True' + } + It 'Vhd Parameter is of Object Type' { + $Function.Parameters.Vhd.ParameterType.FullName | Should be 'System.Object' + } + It 'Vhd Parameter is member of ParameterSets' { + [String]$Function.Parameters.Vhd.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Vhd Parameter Position is defined correctly' { + [String]$Function.Parameters.Vhd.Attributes.Position | Should be '0' + } + It 'Does Vhd Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Vhd Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Vhd Parameter use advanced parameter Validation? ' { + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Vhd '{ + $function.Definition.Contains('.PARAMETER Vhd') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/NewDiskImageMbr.Functional.Tests.ps1 b/Private/Tests/NewDiskImageMbr.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/NewDiskImageMbr.Tests.ps1 b/Private/Tests/NewDiskImageMbr.Tests.ps1 new file mode 100644 index 00000000..33b89101 --- /dev/null +++ b/Private/Tests/NewDiskImageMbr.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'NewDiskImageMbr Tests' { + + Context 'Parameters for NewDiskImageMbr'{ + + It 'Has a Parameter called Vhd' { + $Function.Parameters.Keys.Contains('Vhd') | Should Be 'True' + } + It 'Vhd Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Vhd.Attributes.Mandatory | Should be 'True' + } + It 'Vhd Parameter is of Object Type' { + $Function.Parameters.Vhd.ParameterType.FullName | Should be 'System.Object' + } + It 'Vhd Parameter is member of ParameterSets' { + [String]$Function.Parameters.Vhd.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Vhd Parameter Position is defined correctly' { + [String]$Function.Parameters.Vhd.Attributes.Position | Should be '0' + } + It 'Does Vhd Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Vhd Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Vhd Parameter use advanced parameter Validation? ' { + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Vhd '{ + $function.Definition.Contains('.PARAMETER Vhd') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/NewDiskPartFat32Partition.Functional.Tests.ps1 b/Private/Tests/NewDiskPartFat32Partition.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/NewDiskPartFat32Partition.Tests.ps1 b/Private/Tests/NewDiskPartFat32Partition.Tests.ps1 new file mode 100644 index 00000000..dcd54f6e --- /dev/null +++ b/Private/Tests/NewDiskPartFat32Partition.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'NewDiskPartFat32Partition Tests' { + + Context 'Parameters for NewDiskPartFat32Partition'{ + + It 'Has a Parameter called DiskNumber' { + $Function.Parameters.Keys.Contains('DiskNumber') | Should Be 'True' + } + It 'DiskNumber Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DiskNumber.Attributes.Mandatory | Should be 'True' + } + It 'DiskNumber Parameter is of Int32 Type' { + $Function.Parameters.DiskNumber.ParameterType.FullName | Should be 'System.Int32' + } + It 'DiskNumber Parameter is member of ParameterSets' { + [String]$Function.Parameters.DiskNumber.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DiskNumber Parameter Position is defined correctly' { + [String]$Function.Parameters.DiskNumber.Attributes.Position | Should be '0' + } + It 'Does DiskNumber Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DiskNumber.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DiskNumber Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DiskNumber.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does DiskNumber Parameter use advanced parameter Validation? ' { + $Function.Parameters.DiskNumber.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.DiskNumber.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DiskNumber.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DiskNumber.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DiskNumber.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DiskNumber '{ + $function.Definition.Contains('.PARAMETER DiskNumber') | Should Be 'True' + } + It 'Has a Parameter called PartitionNumber' { + $Function.Parameters.Keys.Contains('PartitionNumber') | Should Be 'True' + } + It 'PartitionNumber Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.PartitionNumber.Attributes.Mandatory | Should be 'True' + } + It 'PartitionNumber Parameter is of Int32 Type' { + $Function.Parameters.PartitionNumber.ParameterType.FullName | Should be 'System.Int32' + } + It 'PartitionNumber Parameter is member of ParameterSets' { + [String]$Function.Parameters.PartitionNumber.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'PartitionNumber Parameter Position is defined correctly' { + [String]$Function.Parameters.PartitionNumber.Attributes.Position | Should be '1' + } + It 'Does PartitionNumber Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.PartitionNumber.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does PartitionNumber Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.PartitionNumber.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does PartitionNumber Parameter use advanced parameter Validation? ' { + $Function.Parameters.PartitionNumber.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.PartitionNumber.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.PartitionNumber.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.PartitionNumber.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.PartitionNumber.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for PartitionNumber '{ + $function.Definition.Contains('.PARAMETER PartitionNumber') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/NewLabMedia.Functional.Tests.ps1 b/Private/Tests/NewLabMedia.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/NewLabMedia.Tests.ps1 b/Private/Tests/NewLabMedia.Tests.ps1 new file mode 100644 index 00000000..0cd60e90 --- /dev/null +++ b/Private/Tests/NewLabMedia.Tests.ps1 @@ -0,0 +1,407 @@ +Describe 'NewLabMedia Tests' { + + Context 'Parameters for NewLabMedia'{ + + It 'Has a Parameter called Id' { + $Function.Parameters.Keys.Contains('Id') | Should Be 'True' + } + It 'Id Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Id.Attributes.Mandatory | Should be 'False' + } + It 'Id Parameter is of String Type' { + $Function.Parameters.Id.ParameterType.FullName | Should be 'System.String' + } + It 'Id Parameter is member of ParameterSets' { + [String]$Function.Parameters.Id.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Id Parameter Position is defined correctly' { + [String]$Function.Parameters.Id.Attributes.Position | Should be '0' + } + It 'Does Id Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Id Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Id Parameter use advanced parameter Validation? ' { + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Id '{ + $function.Definition.Contains('.PARAMETER Id') | Should Be 'True' + } + It 'Has a Parameter called Filename' { + $Function.Parameters.Keys.Contains('Filename') | Should Be 'True' + } + It 'Filename Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Filename.Attributes.Mandatory | Should be 'False' + } + It 'Filename Parameter is of String Type' { + $Function.Parameters.Filename.ParameterType.FullName | Should be 'System.String' + } + It 'Filename Parameter is member of ParameterSets' { + [String]$Function.Parameters.Filename.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Filename Parameter Position is defined correctly' { + [String]$Function.Parameters.Filename.Attributes.Position | Should be '1' + } + It 'Does Filename Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Filename.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Filename Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Filename.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Filename Parameter use advanced parameter Validation? ' { + $Function.Parameters.Filename.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Filename.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Filename.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Filename.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Filename.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Filename '{ + $function.Definition.Contains('.PARAMETER Filename') | Should Be 'True' + } + It 'Has a Parameter called Description' { + $Function.Parameters.Keys.Contains('Description') | Should Be 'True' + } + It 'Description Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Description.Attributes.Mandatory | Should be 'False' + } + It 'Description Parameter is of String Type' { + $Function.Parameters.Description.ParameterType.FullName | Should be 'System.String' + } + It 'Description Parameter is member of ParameterSets' { + [String]$Function.Parameters.Description.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Description Parameter Position is defined correctly' { + [String]$Function.Parameters.Description.Attributes.Position | Should be '2' + } + It 'Does Description Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Description.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Description Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Description.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Description Parameter use advanced parameter Validation? ' { + $Function.Parameters.Description.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Description.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Description.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Description.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Description.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Description '{ + $function.Definition.Contains('.PARAMETER Description') | Should Be 'True' + } + It 'Has a Parameter called Architecture' { + $Function.Parameters.Keys.Contains('Architecture') | Should Be 'True' + } + It 'Architecture Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Architecture.Attributes.Mandatory | Should be 'False' + } + It 'Architecture Parameter is of String Type' { + $Function.Parameters.Architecture.ParameterType.FullName | Should be 'System.String' + } + It 'Architecture Parameter is member of ParameterSets' { + [String]$Function.Parameters.Architecture.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Architecture Parameter Position is defined correctly' { + [String]$Function.Parameters.Architecture.Attributes.Position | Should be '3' + } + It 'Does Architecture Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Architecture.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Architecture Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Architecture.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Architecture Parameter use advanced parameter Validation? ' { + $Function.Parameters.Architecture.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Architecture.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Architecture.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Architecture.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Architecture.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Architecture '{ + $function.Definition.Contains('.PARAMETER Architecture') | Should Be 'True' + } + It 'Has a Parameter called ImageName' { + $Function.Parameters.Keys.Contains('ImageName') | Should Be 'True' + } + It 'ImageName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ImageName.Attributes.Mandatory | Should be 'False' + } + It 'ImageName Parameter is of String Type' { + $Function.Parameters.ImageName.ParameterType.FullName | Should be 'System.String' + } + It 'ImageName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ImageName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ImageName Parameter Position is defined correctly' { + [String]$Function.Parameters.ImageName.Attributes.Position | Should be '4' + } + It 'Does ImageName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ImageName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ImageName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ImageName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ImageName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ImageName '{ + $function.Definition.Contains('.PARAMETER ImageName') | Should Be 'True' + } + It 'Has a Parameter called MediaType' { + $Function.Parameters.Keys.Contains('MediaType') | Should Be 'True' + } + It 'MediaType Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MediaType.Attributes.Mandatory | Should be 'False' + } + It 'MediaType Parameter is of String Type' { + $Function.Parameters.MediaType.ParameterType.FullName | Should be 'System.String' + } + It 'MediaType Parameter is member of ParameterSets' { + [String]$Function.Parameters.MediaType.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MediaType Parameter Position is defined correctly' { + [String]$Function.Parameters.MediaType.Attributes.Position | Should be '5' + } + It 'Does MediaType Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MediaType.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MediaType Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MediaType.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MediaType Parameter use advanced parameter Validation? ' { + $Function.Parameters.MediaType.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MediaType.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MediaType.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MediaType.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MediaType.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MediaType '{ + $function.Definition.Contains('.PARAMETER MediaType') | Should Be 'True' + } + It 'Has a Parameter called Uri' { + $Function.Parameters.Keys.Contains('Uri') | Should Be 'True' + } + It 'Uri Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Uri.Attributes.Mandatory | Should be 'False' + } + It 'Uri Parameter is of String Type' { + $Function.Parameters.Uri.ParameterType.FullName | Should be 'System.String' + } + It 'Uri Parameter is member of ParameterSets' { + [String]$Function.Parameters.Uri.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Uri Parameter Position is defined correctly' { + [String]$Function.Parameters.Uri.Attributes.Position | Should be '6' + } + It 'Does Uri Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Uri Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Uri Parameter use advanced parameter Validation? ' { + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Uri '{ + $function.Definition.Contains('.PARAMETER Uri') | Should Be 'True' + } + It 'Has a Parameter called Checksum' { + $Function.Parameters.Keys.Contains('Checksum') | Should Be 'True' + } + It 'Checksum Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Checksum.Attributes.Mandatory | Should be 'False' + } + It 'Checksum Parameter is of String Type' { + $Function.Parameters.Checksum.ParameterType.FullName | Should be 'System.String' + } + It 'Checksum Parameter is member of ParameterSets' { + [String]$Function.Parameters.Checksum.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Checksum Parameter Position is defined correctly' { + [String]$Function.Parameters.Checksum.Attributes.Position | Should be '7' + } + It 'Does Checksum Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Checksum Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Checksum Parameter use advanced parameter Validation? ' { + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Checksum '{ + $function.Definition.Contains('.PARAMETER Checksum') | Should Be 'True' + } + It 'Has a Parameter called ProductKey' { + $Function.Parameters.Keys.Contains('ProductKey') | Should Be 'True' + } + It 'ProductKey Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ProductKey.Attributes.Mandatory | Should be 'False' + } + It 'ProductKey Parameter is of String Type' { + $Function.Parameters.ProductKey.ParameterType.FullName | Should be 'System.String' + } + It 'ProductKey Parameter is member of ParameterSets' { + [String]$Function.Parameters.ProductKey.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ProductKey Parameter Position is defined correctly' { + [String]$Function.Parameters.ProductKey.Attributes.Position | Should be '8' + } + It 'Does ProductKey Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ProductKey.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ProductKey Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ProductKey.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ProductKey Parameter use advanced parameter Validation? ' { + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ProductKey '{ + $function.Definition.Contains('.PARAMETER ProductKey') | Should Be 'True' + } + It 'Has a Parameter called OperatingSystem' { + $Function.Parameters.Keys.Contains('OperatingSystem') | Should Be 'True' + } + It 'OperatingSystem Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.OperatingSystem.Attributes.Mandatory | Should be 'False' + } + It 'OperatingSystem Parameter is of String Type' { + $Function.Parameters.OperatingSystem.ParameterType.FullName | Should be 'System.String' + } + It 'OperatingSystem Parameter is member of ParameterSets' { + [String]$Function.Parameters.OperatingSystem.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'OperatingSystem Parameter Position is defined correctly' { + [String]$Function.Parameters.OperatingSystem.Attributes.Position | Should be '9' + } + It 'Does OperatingSystem Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.OperatingSystem.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does OperatingSystem Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.OperatingSystem.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does OperatingSystem Parameter use advanced parameter Validation? ' { + $Function.Parameters.OperatingSystem.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.OperatingSystem.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.OperatingSystem.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.OperatingSystem.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.OperatingSystem.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for OperatingSystem '{ + $function.Definition.Contains('.PARAMETER OperatingSystem') | Should Be 'True' + } + It 'Has a Parameter called CustomData' { + $Function.Parameters.Keys.Contains('CustomData') | Should Be 'True' + } + It 'CustomData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CustomData.Attributes.Mandatory | Should be 'False' + } + It 'CustomData Parameter is of Hashtable Type' { + $Function.Parameters.CustomData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'CustomData Parameter is member of ParameterSets' { + [String]$Function.Parameters.CustomData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CustomData Parameter Position is defined correctly' { + [String]$Function.Parameters.CustomData.Attributes.Position | Should be '10' + } + It 'Does CustomData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CustomData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CustomData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CustomData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CustomData Parameter use advanced parameter Validation? ' { + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CustomData '{ + $function.Definition.Contains('.PARAMETER CustomData') | Should Be 'True' + } + It 'Has a Parameter called Hotfixes' { + $Function.Parameters.Keys.Contains('Hotfixes') | Should Be 'True' + } + It 'Hotfixes Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Hotfixes.Attributes.Mandatory | Should be 'False' + } + It 'Hotfixes Parameter is of Array Type' { + $Function.Parameters.Hotfixes.ParameterType.FullName | Should be 'System.Array' + } + It 'Hotfixes Parameter is member of ParameterSets' { + [String]$Function.Parameters.Hotfixes.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Hotfixes Parameter Position is defined correctly' { + [String]$Function.Parameters.Hotfixes.Attributes.Position | Should be '11' + } + It 'Does Hotfixes Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Hotfixes.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Hotfixes Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Hotfixes.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Hotfixes Parameter use advanced parameter Validation? ' { + $Function.Parameters.Hotfixes.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Hotfixes.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Hotfixes.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Hotfixes.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Hotfixes.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Hotfixes '{ + $function.Definition.Contains('.PARAMETER Hotfixes') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/NewLabSwitch.Functional.Tests.ps1 b/Private/Tests/NewLabSwitch.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/NewLabSwitch.Tests.ps1 b/Private/Tests/NewLabSwitch.Tests.ps1 new file mode 100644 index 00000000..65c0aa67 --- /dev/null +++ b/Private/Tests/NewLabSwitch.Tests.ps1 @@ -0,0 +1,190 @@ +Describe 'NewLabSwitch Tests' { + + Context 'Parameters for NewLabSwitch'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called Type' { + $Function.Parameters.Keys.Contains('Type') | Should Be 'True' + } + It 'Type Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Type.Attributes.Mandatory | Should be 'True' + } + It 'Type Parameter is of String Type' { + $Function.Parameters.Type.ParameterType.FullName | Should be 'System.String' + } + It 'Type Parameter is member of ParameterSets' { + [String]$Function.Parameters.Type.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Type Parameter Position is defined correctly' { + [String]$Function.Parameters.Type.Attributes.Position | Should be '1' + } + It 'Does Type Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Type.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Type Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Type.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Type Parameter use advanced parameter Validation? ' { + $Function.Parameters.Type.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Type.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Type.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Type.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Type.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Type '{ + $function.Definition.Contains('.PARAMETER Type') | Should Be 'True' + } + It 'Has a Parameter called NetAdapterName' { + $Function.Parameters.Keys.Contains('NetAdapterName') | Should Be 'True' + } + It 'NetAdapterName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.NetAdapterName.Attributes.Mandatory | Should be 'False' + } + It 'NetAdapterName Parameter is of String Type' { + $Function.Parameters.NetAdapterName.ParameterType.FullName | Should be 'System.String' + } + It 'NetAdapterName Parameter is member of ParameterSets' { + [String]$Function.Parameters.NetAdapterName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NetAdapterName Parameter Position is defined correctly' { + [String]$Function.Parameters.NetAdapterName.Attributes.Position | Should be '2' + } + It 'Does NetAdapterName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NetAdapterName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does NetAdapterName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NetAdapterName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does NetAdapterName Parameter use advanced parameter Validation? ' { + $Function.Parameters.NetAdapterName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NetAdapterName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.NetAdapterName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NetAdapterName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NetAdapterName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NetAdapterName '{ + $function.Definition.Contains('.PARAMETER NetAdapterName') | Should Be 'True' + } + It 'Has a Parameter called AllowManagementOS' { + $Function.Parameters.Keys.Contains('AllowManagementOS') | Should Be 'True' + } + It 'AllowManagementOS Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.AllowManagementOS.Attributes.Mandatory | Should be 'False' + } + It 'AllowManagementOS Parameter is of Boolean Type' { + $Function.Parameters.AllowManagementOS.ParameterType.FullName | Should be 'System.Boolean' + } + It 'AllowManagementOS Parameter is member of ParameterSets' { + [String]$Function.Parameters.AllowManagementOS.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'AllowManagementOS Parameter Position is defined correctly' { + [String]$Function.Parameters.AllowManagementOS.Attributes.Position | Should be '3' + } + It 'Does AllowManagementOS Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.AllowManagementOS.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does AllowManagementOS Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.AllowManagementOS.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does AllowManagementOS Parameter use advanced parameter Validation? ' { + $Function.Parameters.AllowManagementOS.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.AllowManagementOS.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.AllowManagementOS.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.AllowManagementOS.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.AllowManagementOS.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for AllowManagementOS '{ + $function.Definition.Contains('.PARAMETER AllowManagementOS') | Should Be 'True' + } + It 'Has a Parameter called Ensure' { + $Function.Parameters.Keys.Contains('Ensure') | Should Be 'True' + } + It 'Ensure Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Ensure.Attributes.Mandatory | Should be 'False' + } + It 'Ensure Parameter is of String Type' { + $Function.Parameters.Ensure.ParameterType.FullName | Should be 'System.String' + } + It 'Ensure Parameter is member of ParameterSets' { + [String]$Function.Parameters.Ensure.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Ensure Parameter Position is defined correctly' { + [String]$Function.Parameters.Ensure.Attributes.Position | Should be '4' + } + It 'Does Ensure Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Ensure.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Ensure Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Ensure.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Ensure Parameter use advanced parameter Validation? ' { + $Function.Parameters.Ensure.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Ensure.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Ensure.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Ensure.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Ensure.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Ensure '{ + $function.Definition.Contains('.PARAMETER Ensure') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/NewLabVM.Functional.Tests.ps1 b/Private/Tests/NewLabVM.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/NewLabVM.Tests.ps1 b/Private/Tests/NewLabVM.Tests.ps1 new file mode 100644 index 00000000..fa0115e3 --- /dev/null +++ b/Private/Tests/NewLabVM.Tests.ps1 @@ -0,0 +1,252 @@ +Describe 'NewLabVM Tests' { + + Context 'Parameters for NewLabVM'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '-2147483648' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '-2147483648' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called Credential' { + $Function.Parameters.Keys.Contains('Credential') | Should Be 'True' + } + It 'Credential Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Credential.Attributes.Mandatory | Should be 'False' + } + It 'Credential Parameter is of PSCredential Type' { + $Function.Parameters.Credential.ParameterType.FullName | Should be 'System.Management.Automation.PSCredential' + } + It 'Credential Parameter is member of ParameterSets' { + [String]$Function.Parameters.Credential.ParameterSets.Keys | Should Be 'PSCredential' + } + It 'Credential Parameter Position is defined correctly' { + [String]$Function.Parameters.Credential.Attributes.Position | Should be '-2147483648' + } + It 'Does Credential Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Credential Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Credential Parameter use advanced parameter Validation? ' { + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Credential '{ + $function.Definition.Contains('.PARAMETER Credential') | Should Be 'True' + } + It 'Has a Parameter called Password' { + $Function.Parameters.Keys.Contains('Password') | Should Be 'True' + } + It 'Password Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Password.Attributes.Mandatory | Should be 'True' + } + It 'Password Parameter is of SecureString Type' { + $Function.Parameters.Password.ParameterType.FullName | Should be 'System.Security.SecureString' + } + It 'Password Parameter is member of ParameterSets' { + [String]$Function.Parameters.Password.ParameterSets.Keys | Should Be 'Password' + } + It 'Password Parameter Position is defined correctly' { + [String]$Function.Parameters.Password.Attributes.Position | Should be '-2147483648' + } + It 'Does Password Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Password.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Password Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Password.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Password Parameter use advanced parameter Validation? ' { + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Password '{ + $function.Definition.Contains('.PARAMETER Password') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'False' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '-2147483648' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called NoSnapshot' { + $Function.Parameters.Keys.Contains('NoSnapshot') | Should Be 'True' + } + It 'NoSnapshot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.NoSnapshot.Attributes.Mandatory | Should be 'False' + } + It 'NoSnapshot Parameter is of SwitchParameter Type' { + $Function.Parameters.NoSnapshot.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'NoSnapshot Parameter is member of ParameterSets' { + [String]$Function.Parameters.NoSnapshot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NoSnapshot Parameter Position is defined correctly' { + [String]$Function.Parameters.NoSnapshot.Attributes.Position | Should be '-2147483648' + } + It 'Does NoSnapshot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NoSnapshot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does NoSnapshot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NoSnapshot.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does NoSnapshot Parameter use advanced parameter Validation? ' { + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NoSnapshot '{ + $function.Definition.Contains('.PARAMETER NoSnapshot') | Should Be 'True' + } + It 'Has a Parameter called IsQuickVM' { + $Function.Parameters.Keys.Contains('IsQuickVM') | Should Be 'True' + } + It 'IsQuickVM Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.IsQuickVM.Attributes.Mandatory | Should be 'False' + } + It 'IsQuickVM Parameter is of SwitchParameter Type' { + $Function.Parameters.IsQuickVM.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'IsQuickVM Parameter is member of ParameterSets' { + [String]$Function.Parameters.IsQuickVM.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'IsQuickVM Parameter Position is defined correctly' { + [String]$Function.Parameters.IsQuickVM.Attributes.Position | Should be '-2147483648' + } + It 'Does IsQuickVM Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.IsQuickVM.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does IsQuickVM Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.IsQuickVM.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does IsQuickVM Parameter use advanced parameter Validation? ' { + $Function.Parameters.IsQuickVM.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.IsQuickVM.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.IsQuickVM.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.IsQuickVM.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.IsQuickVM.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for IsQuickVM '{ + $function.Definition.Contains('.PARAMETER IsQuickVM') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/NewLabVMSnapshot.Functional.Tests.ps1 b/Private/Tests/NewLabVMSnapshot.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/NewLabVMSnapshot.Tests.ps1 b/Private/Tests/NewLabVMSnapshot.Tests.ps1 new file mode 100644 index 00000000..2038ee8d --- /dev/null +++ b/Private/Tests/NewLabVMSnapshot.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'NewLabVMSnapshot Tests' { + + Context 'Parameters for NewLabVMSnapshot'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String[] Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String[]' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called SnapshotName' { + $Function.Parameters.Keys.Contains('SnapshotName') | Should Be 'True' + } + It 'SnapshotName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.SnapshotName.Attributes.Mandatory | Should be 'True' + } + It 'SnapshotName Parameter is of String Type' { + $Function.Parameters.SnapshotName.ParameterType.FullName | Should be 'System.String' + } + It 'SnapshotName Parameter is member of ParameterSets' { + [String]$Function.Parameters.SnapshotName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SnapshotName Parameter Position is defined correctly' { + [String]$Function.Parameters.SnapshotName.Attributes.Position | Should be '1' + } + It 'Does SnapshotName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SnapshotName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SnapshotName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SnapshotName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SnapshotName Parameter use advanced parameter Validation? ' { + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SnapshotName '{ + $function.Definition.Contains('.PARAMETER SnapshotName') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/NewUnattendXml.Functional.Tests.ps1 b/Private/Tests/NewUnattendXml.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/NewUnattendXml.Tests.ps1 b/Private/Tests/NewUnattendXml.Tests.ps1 new file mode 100644 index 00000000..6005a7dd --- /dev/null +++ b/Private/Tests/NewUnattendXml.Tests.ps1 @@ -0,0 +1,376 @@ +Describe 'NewUnattendXml Tests' { + + Context 'Parameters for NewUnattendXml'{ + + It 'Has a Parameter called Credential' { + $Function.Parameters.Keys.Contains('Credential') | Should Be 'True' + } + It 'Credential Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Credential.Attributes.Mandatory | Should be 'True' + } + It 'Credential Parameter is of PSCredential Type' { + $Function.Parameters.Credential.ParameterType.FullName | Should be 'System.Management.Automation.PSCredential' + } + It 'Credential Parameter is member of ParameterSets' { + [String]$Function.Parameters.Credential.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Credential Parameter Position is defined correctly' { + [String]$Function.Parameters.Credential.Attributes.Position | Should be '0' + } + It 'Does Credential Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Credential Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Credential Parameter use advanced parameter Validation? ' { + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Credential '{ + $function.Definition.Contains('.PARAMETER Credential') | Should Be 'True' + } + It 'Has a Parameter called ComputerName' { + $Function.Parameters.Keys.Contains('ComputerName') | Should Be 'True' + } + It 'ComputerName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ComputerName.Attributes.Mandatory | Should be 'False' + } + It 'ComputerName Parameter is of String Type' { + $Function.Parameters.ComputerName.ParameterType.FullName | Should be 'System.String' + } + It 'ComputerName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ComputerName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ComputerName Parameter Position is defined correctly' { + [String]$Function.Parameters.ComputerName.Attributes.Position | Should be '1' + } + It 'Does ComputerName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ComputerName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ComputerName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ComputerName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ComputerName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ComputerName '{ + $function.Definition.Contains('.PARAMETER ComputerName') | Should Be 'True' + } + It 'Has a Parameter called ProductKey' { + $Function.Parameters.Keys.Contains('ProductKey') | Should Be 'True' + } + It 'ProductKey Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ProductKey.Attributes.Mandatory | Should be 'False' + } + It 'ProductKey Parameter is of String Type' { + $Function.Parameters.ProductKey.ParameterType.FullName | Should be 'System.String' + } + It 'ProductKey Parameter is member of ParameterSets' { + [String]$Function.Parameters.ProductKey.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ProductKey Parameter Position is defined correctly' { + [String]$Function.Parameters.ProductKey.Attributes.Position | Should be '2' + } + It 'Does ProductKey Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ProductKey.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ProductKey Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ProductKey.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ProductKey Parameter use advanced parameter Validation? ' { + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for ProductKey '{ + $function.Definition.Contains('.PARAMETER ProductKey') | Should Be 'True' + } + It 'Has a Parameter called InputLocale' { + $Function.Parameters.Keys.Contains('InputLocale') | Should Be 'True' + } + It 'InputLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.InputLocale.Attributes.Mandatory | Should be 'False' + } + It 'InputLocale Parameter is of String Type' { + $Function.Parameters.InputLocale.ParameterType.FullName | Should be 'System.String' + } + It 'InputLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.InputLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'InputLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.InputLocale.Attributes.Position | Should be '3' + } + It 'Does InputLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.InputLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does InputLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.InputLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does InputLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for InputLocale '{ + $function.Definition.Contains('.PARAMETER InputLocale') | Should Be 'True' + } + It 'Has a Parameter called SystemLocale' { + $Function.Parameters.Keys.Contains('SystemLocale') | Should Be 'True' + } + It 'SystemLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SystemLocale.Attributes.Mandatory | Should be 'False' + } + It 'SystemLocale Parameter is of String Type' { + $Function.Parameters.SystemLocale.ParameterType.FullName | Should be 'System.String' + } + It 'SystemLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.SystemLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SystemLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.SystemLocale.Attributes.Position | Should be '4' + } + It 'Does SystemLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SystemLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SystemLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SystemLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SystemLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SystemLocale '{ + $function.Definition.Contains('.PARAMETER SystemLocale') | Should Be 'True' + } + It 'Has a Parameter called UserLocale' { + $Function.Parameters.Keys.Contains('UserLocale') | Should Be 'True' + } + It 'UserLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.UserLocale.Attributes.Mandatory | Should be 'False' + } + It 'UserLocale Parameter is of String Type' { + $Function.Parameters.UserLocale.ParameterType.FullName | Should be 'System.String' + } + It 'UserLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.UserLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'UserLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.UserLocale.Attributes.Position | Should be '5' + } + It 'Does UserLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.UserLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does UserLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.UserLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does UserLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for UserLocale '{ + $function.Definition.Contains('.PARAMETER UserLocale') | Should Be 'True' + } + It 'Has a Parameter called UILanguage' { + $Function.Parameters.Keys.Contains('UILanguage') | Should Be 'True' + } + It 'UILanguage Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.UILanguage.Attributes.Mandatory | Should be 'False' + } + It 'UILanguage Parameter is of String Type' { + $Function.Parameters.UILanguage.ParameterType.FullName | Should be 'System.String' + } + It 'UILanguage Parameter is member of ParameterSets' { + [String]$Function.Parameters.UILanguage.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'UILanguage Parameter Position is defined correctly' { + [String]$Function.Parameters.UILanguage.Attributes.Position | Should be '6' + } + It 'Does UILanguage Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.UILanguage.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does UILanguage Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.UILanguage.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does UILanguage Parameter use advanced parameter Validation? ' { + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for UILanguage '{ + $function.Definition.Contains('.PARAMETER UILanguage') | Should Be 'True' + } + It 'Has a Parameter called Timezone' { + $Function.Parameters.Keys.Contains('Timezone') | Should Be 'True' + } + It 'Timezone Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Timezone.Attributes.Mandatory | Should be 'True' + } + It 'Timezone Parameter is of String Type' { + $Function.Parameters.Timezone.ParameterType.FullName | Should be 'System.String' + } + It 'Timezone Parameter is member of ParameterSets' { + [String]$Function.Parameters.Timezone.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Timezone Parameter Position is defined correctly' { + [String]$Function.Parameters.Timezone.Attributes.Position | Should be '7' + } + It 'Does Timezone Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Timezone.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Timezone Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Timezone.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Timezone Parameter use advanced parameter Validation? ' { + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Timezone '{ + $function.Definition.Contains('.PARAMETER Timezone') | Should Be 'True' + } + It 'Has a Parameter called RegisteredOwner' { + $Function.Parameters.Keys.Contains('RegisteredOwner') | Should Be 'True' + } + It 'RegisteredOwner Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RegisteredOwner.Attributes.Mandatory | Should be 'False' + } + It 'RegisteredOwner Parameter is of String Type' { + $Function.Parameters.RegisteredOwner.ParameterType.FullName | Should be 'System.String' + } + It 'RegisteredOwner Parameter is member of ParameterSets' { + [String]$Function.Parameters.RegisteredOwner.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RegisteredOwner Parameter Position is defined correctly' { + [String]$Function.Parameters.RegisteredOwner.Attributes.Position | Should be '8' + } + It 'Does RegisteredOwner Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RegisteredOwner.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RegisteredOwner Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RegisteredOwner.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RegisteredOwner Parameter use advanced parameter Validation? ' { + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RegisteredOwner '{ + $function.Definition.Contains('.PARAMETER RegisteredOwner') | Should Be 'True' + } + It 'Has a Parameter called RegisteredOrganization' { + $Function.Parameters.Keys.Contains('RegisteredOrganization') | Should Be 'True' + } + It 'RegisteredOrganization Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.Mandatory | Should be 'False' + } + It 'RegisteredOrganization Parameter is of String Type' { + $Function.Parameters.RegisteredOrganization.ParameterType.FullName | Should be 'System.String' + } + It 'RegisteredOrganization Parameter is member of ParameterSets' { + [String]$Function.Parameters.RegisteredOrganization.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RegisteredOrganization Parameter Position is defined correctly' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.Position | Should be '9' + } + It 'Does RegisteredOrganization Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RegisteredOrganization Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RegisteredOrganization Parameter use advanced parameter Validation? ' { + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RegisteredOrganization '{ + $function.Definition.Contains('.PARAMETER RegisteredOrganization') | Should Be 'True' + } + It 'Has a Parameter called ExecuteCommand' { + $Function.Parameters.Keys.Contains('ExecuteCommand') | Should Be 'True' + } + It 'ExecuteCommand Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ExecuteCommand.Attributes.Mandatory | Should be 'False' + } + It 'ExecuteCommand Parameter is of Hashtable[] Type' { + $Function.Parameters.ExecuteCommand.ParameterType.FullName | Should be 'System.Collections.Hashtable[]' + } + It 'ExecuteCommand Parameter is member of ParameterSets' { + [String]$Function.Parameters.ExecuteCommand.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ExecuteCommand Parameter Position is defined correctly' { + [String]$Function.Parameters.ExecuteCommand.Attributes.Position | Should be '10' + } + It 'Does ExecuteCommand Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ExecuteCommand.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ExecuteCommand Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ExecuteCommand.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ExecuteCommand Parameter use advanced parameter Validation? ' { + $Function.Parameters.ExecuteCommand.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ExecuteCommand.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ExecuteCommand.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ExecuteCommand.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ExecuteCommand.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ExecuteCommand '{ + $function.Definition.Contains('.PARAMETER ExecuteCommand') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/RemoveConfigurationData.Functional.Tests.ps1 b/Private/Tests/RemoveConfigurationData.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/RemoveConfigurationData.Tests.ps1 b/Private/Tests/RemoveConfigurationData.Tests.ps1 new file mode 100644 index 00000000..298223d9 --- /dev/null +++ b/Private/Tests/RemoveConfigurationData.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'RemoveConfigurationData Tests' { + + Context 'Parameters for RemoveConfigurationData'{ + + It 'Has a Parameter called Configuration' { + $Function.Parameters.Keys.Contains('Configuration') | Should Be 'True' + } + It 'Configuration Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Configuration.Attributes.Mandatory | Should be 'True' + } + It 'Configuration Parameter is of String Type' { + $Function.Parameters.Configuration.ParameterType.FullName | Should be 'System.String' + } + It 'Configuration Parameter is member of ParameterSets' { + [String]$Function.Parameters.Configuration.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Configuration Parameter Position is defined correctly' { + [String]$Function.Parameters.Configuration.Attributes.Position | Should be '0' + } + It 'Does Configuration Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Configuration.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Configuration Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Configuration.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Configuration Parameter use advanced parameter Validation? ' { + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Configuration '{ + $function.Definition.Contains('.PARAMETER Configuration') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/RemoveLabSwitch.Functional.Tests.ps1 b/Private/Tests/RemoveLabSwitch.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/RemoveLabSwitch.Tests.ps1 b/Private/Tests/RemoveLabSwitch.Tests.ps1 new file mode 100644 index 00000000..23285e92 --- /dev/null +++ b/Private/Tests/RemoveLabSwitch.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'RemoveLabSwitch Tests' { + + Context 'Parameters for RemoveLabSwitch'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/RemoveLabVM.Functional.Tests.ps1 b/Private/Tests/RemoveLabVM.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/RemoveLabVM.Tests.ps1 b/Private/Tests/RemoveLabVM.Tests.ps1 new file mode 100644 index 00000000..cb4994ec --- /dev/null +++ b/Private/Tests/RemoveLabVM.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'RemoveLabVM Tests' { + + Context 'Parameters for RemoveLabVM'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called RemoveSwitch' { + $Function.Parameters.Keys.Contains('RemoveSwitch') | Should Be 'True' + } + It 'RemoveSwitch Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemoveSwitch.Attributes.Mandatory | Should be 'False' + } + It 'RemoveSwitch Parameter is of SwitchParameter Type' { + $Function.Parameters.RemoveSwitch.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'RemoveSwitch Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemoveSwitch.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemoveSwitch Parameter Position is defined correctly' { + [String]$Function.Parameters.RemoveSwitch.Attributes.Position | Should be '-2147483648' + } + It 'Does RemoveSwitch Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemoveSwitch.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemoveSwitch Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemoveSwitch.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RemoveSwitch Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemoveSwitch.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemoveSwitch.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemoveSwitch.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemoveSwitch.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemoveSwitch.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemoveSwitch '{ + $function.Definition.Contains('.PARAMETER RemoveSwitch') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/RemoveLabVMDisk.Functional.Tests.ps1 b/Private/Tests/RemoveLabVMDisk.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/RemoveLabVMDisk.Tests.ps1 b/Private/Tests/RemoveLabVMDisk.Tests.ps1 new file mode 100644 index 00000000..6082eb02 --- /dev/null +++ b/Private/Tests/RemoveLabVMDisk.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'RemoveLabVMDisk Tests' { + + Context 'Parameters for RemoveLabVMDisk'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'True' + } + It 'Media Parameter is of String Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.String' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '1' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '2' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/RemoveLabVMSnapshot.Functional.Tests.ps1 b/Private/Tests/RemoveLabVMSnapshot.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/RemoveLabVMSnapshot.Tests.ps1 b/Private/Tests/RemoveLabVMSnapshot.Tests.ps1 new file mode 100644 index 00000000..82c4472c --- /dev/null +++ b/Private/Tests/RemoveLabVMSnapshot.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'RemoveLabVMSnapshot Tests' { + + Context 'Parameters for RemoveLabVMSnapshot'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String[] Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String[]' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called SnapshotName' { + $Function.Parameters.Keys.Contains('SnapshotName') | Should Be 'True' + } + It 'SnapshotName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SnapshotName.Attributes.Mandatory | Should be 'False' + } + It 'SnapshotName Parameter is of String Type' { + $Function.Parameters.SnapshotName.ParameterType.FullName | Should be 'System.String' + } + It 'SnapshotName Parameter is member of ParameterSets' { + [String]$Function.Parameters.SnapshotName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SnapshotName Parameter Position is defined correctly' { + [String]$Function.Parameters.SnapshotName.Attributes.Position | Should be '1' + } + It 'Does SnapshotName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SnapshotName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SnapshotName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SnapshotName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SnapshotName Parameter use advanced parameter Validation? ' { + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SnapshotName '{ + $function.Definition.Contains('.PARAMETER SnapshotName') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/RemoveLabVirtualMachine.Functional.Tests.ps1 b/Private/Tests/RemoveLabVirtualMachine.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/RemoveLabVirtualMachine.Tests.ps1 b/Private/Tests/RemoveLabVirtualMachine.Tests.ps1 new file mode 100644 index 00000000..c7d87869 --- /dev/null +++ b/Private/Tests/RemoveLabVirtualMachine.Tests.ps1 @@ -0,0 +1,376 @@ +Describe 'RemoveLabVirtualMachine Tests' { + + Context 'Parameters for RemoveLabVirtualMachine'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called SwitchName' { + $Function.Parameters.Keys.Contains('SwitchName') | Should Be 'True' + } + It 'SwitchName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.SwitchName.Attributes.Mandatory | Should be 'True' + } + It 'SwitchName Parameter is of String[] Type' { + $Function.Parameters.SwitchName.ParameterType.FullName | Should be 'System.String[]' + } + It 'SwitchName Parameter is member of ParameterSets' { + [String]$Function.Parameters.SwitchName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SwitchName Parameter Position is defined correctly' { + [String]$Function.Parameters.SwitchName.Attributes.Position | Should be '1' + } + It 'Does SwitchName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SwitchName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does SwitchName Parameter use advanced parameter Validation? ' { + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SwitchName '{ + $function.Definition.Contains('.PARAMETER SwitchName') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'True' + } + It 'Media Parameter is of String Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.String' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '2' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called StartupMemory' { + $Function.Parameters.Keys.Contains('StartupMemory') | Should Be 'True' + } + It 'StartupMemory Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.StartupMemory.Attributes.Mandatory | Should be 'True' + } + It 'StartupMemory Parameter is of UInt64 Type' { + $Function.Parameters.StartupMemory.ParameterType.FullName | Should be 'System.UInt64' + } + It 'StartupMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.StartupMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'StartupMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.StartupMemory.Attributes.Position | Should be '3' + } + It 'Does StartupMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does StartupMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does StartupMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for StartupMemory '{ + $function.Definition.Contains('.PARAMETER StartupMemory') | Should Be 'True' + } + It 'Has a Parameter called MinimumMemory' { + $Function.Parameters.Keys.Contains('MinimumMemory') | Should Be 'True' + } + It 'MinimumMemory Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MinimumMemory.Attributes.Mandatory | Should be 'True' + } + It 'MinimumMemory Parameter is of UInt64 Type' { + $Function.Parameters.MinimumMemory.ParameterType.FullName | Should be 'System.UInt64' + } + It 'MinimumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MinimumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumMemory.Attributes.Position | Should be '4' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MinimumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumMemory '{ + $function.Definition.Contains('.PARAMETER MinimumMemory') | Should Be 'True' + } + It 'Has a Parameter called MaximumMemory' { + $Function.Parameters.Keys.Contains('MaximumMemory') | Should Be 'True' + } + It 'MaximumMemory Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MaximumMemory.Attributes.Mandatory | Should be 'True' + } + It 'MaximumMemory Parameter is of UInt64 Type' { + $Function.Parameters.MaximumMemory.ParameterType.FullName | Should be 'System.UInt64' + } + It 'MaximumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MaximumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MaximumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MaximumMemory.Attributes.Position | Should be '5' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MaximumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MaximumMemory '{ + $function.Definition.Contains('.PARAMETER MaximumMemory') | Should Be 'True' + } + It 'Has a Parameter called ProcessorCount' { + $Function.Parameters.Keys.Contains('ProcessorCount') | Should Be 'True' + } + It 'ProcessorCount Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ProcessorCount.Attributes.Mandatory | Should be 'True' + } + It 'ProcessorCount Parameter is of Int32 Type' { + $Function.Parameters.ProcessorCount.ParameterType.FullName | Should be 'System.Int32' + } + It 'ProcessorCount Parameter is member of ParameterSets' { + [String]$Function.Parameters.ProcessorCount.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ProcessorCount Parameter Position is defined correctly' { + [String]$Function.Parameters.ProcessorCount.Attributes.Position | Should be '6' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ProcessorCount Parameter use advanced parameter Validation? ' { + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ProcessorCount '{ + $function.Definition.Contains('.PARAMETER ProcessorCount') | Should Be 'True' + } + It 'Has a Parameter called MACAddress' { + $Function.Parameters.Keys.Contains('MACAddress') | Should Be 'True' + } + It 'MACAddress Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MACAddress.Attributes.Mandatory | Should be 'False' + } + It 'MACAddress Parameter is of String[] Type' { + $Function.Parameters.MACAddress.ParameterType.FullName | Should be 'System.String[]' + } + It 'MACAddress Parameter is member of ParameterSets' { + [String]$Function.Parameters.MACAddress.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MACAddress Parameter Position is defined correctly' { + [String]$Function.Parameters.MACAddress.Attributes.Position | Should be '7' + } + It 'Does MACAddress Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MACAddress.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MACAddress Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MACAddress.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MACAddress Parameter use advanced parameter Validation? ' { + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MACAddress '{ + $function.Definition.Contains('.PARAMETER MACAddress') | Should Be 'True' + } + It 'Has a Parameter called SecureBoot' { + $Function.Parameters.Keys.Contains('SecureBoot') | Should Be 'True' + } + It 'SecureBoot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SecureBoot.Attributes.Mandatory | Should be 'False' + } + It 'SecureBoot Parameter is of Boolean Type' { + $Function.Parameters.SecureBoot.ParameterType.FullName | Should be 'System.Boolean' + } + It 'SecureBoot Parameter is member of ParameterSets' { + [String]$Function.Parameters.SecureBoot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SecureBoot Parameter Position is defined correctly' { + [String]$Function.Parameters.SecureBoot.Attributes.Position | Should be '8' + } + It 'Does SecureBoot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SecureBoot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does SecureBoot Parameter use advanced parameter Validation? ' { + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SecureBoot '{ + $function.Definition.Contains('.PARAMETER SecureBoot') | Should Be 'True' + } + It 'Has a Parameter called GuestIntegrationServices' { + $Function.Parameters.Keys.Contains('GuestIntegrationServices') | Should Be 'True' + } + It 'GuestIntegrationServices Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Mandatory | Should be 'False' + } + It 'GuestIntegrationServices Parameter is of Boolean Type' { + $Function.Parameters.GuestIntegrationServices.ParameterType.FullName | Should be 'System.Boolean' + } + It 'GuestIntegrationServices Parameter is member of ParameterSets' { + [String]$Function.Parameters.GuestIntegrationServices.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'GuestIntegrationServices Parameter Position is defined correctly' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Position | Should be '9' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does GuestIntegrationServices Parameter use advanced parameter Validation? ' { + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for GuestIntegrationServices '{ + $function.Definition.Contains('.PARAMETER GuestIntegrationServices') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '10' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/RenameModuleCacheVersion.Functional.Tests.ps1 b/Private/Tests/RenameModuleCacheVersion.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/RenameModuleCacheVersion.Tests.ps1 b/Private/Tests/RenameModuleCacheVersion.Tests.ps1 new file mode 100644 index 00000000..3a139495 --- /dev/null +++ b/Private/Tests/RenameModuleCacheVersion.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'RenameModuleCacheVersion Tests' { + + Context 'Parameters for RenameModuleCacheVersion'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '-2147483648' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '-2147483648' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called Owner' { + $Function.Parameters.Keys.Contains('Owner') | Should Be 'True' + } + It 'Owner Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Owner.Attributes.Mandatory | Should be 'True' + } + It 'Owner Parameter is of String Type' { + $Function.Parameters.Owner.ParameterType.FullName | Should be 'System.String' + } + It 'Owner Parameter is member of ParameterSets' { + [String]$Function.Parameters.Owner.ParameterSets.Keys | Should Be 'GitHub' + } + It 'Owner Parameter Position is defined correctly' { + [String]$Function.Parameters.Owner.Attributes.Position | Should be '-2147483648' + } + It 'Does Owner Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Owner.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Owner Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Owner.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Owner Parameter use advanced parameter Validation? ' { + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Owner '{ + $function.Definition.Contains('.PARAMETER Owner') | Should Be 'True' + } + It 'Has a Parameter called Branch' { + $Function.Parameters.Keys.Contains('Branch') | Should Be 'True' + } + It 'Branch Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Branch.Attributes.Mandatory | Should be 'True' + } + It 'Branch Parameter is of String Type' { + $Function.Parameters.Branch.ParameterType.FullName | Should be 'System.String' + } + It 'Branch Parameter is member of ParameterSets' { + [String]$Function.Parameters.Branch.ParameterSets.Keys | Should Be 'GitHub' + } + It 'Branch Parameter Position is defined correctly' { + [String]$Function.Parameters.Branch.Attributes.Position | Should be '-2147483648' + } + It 'Does Branch Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Branch.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Branch Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Branch.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Branch Parameter use advanced parameter Validation? ' { + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Branch '{ + $function.Definition.Contains('.PARAMETER Branch') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResetLabVMDisk.Functional.Tests.ps1 b/Private/Tests/ResetLabVMDisk.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResetLabVMDisk.Tests.ps1 b/Private/Tests/ResetLabVMDisk.Tests.ps1 new file mode 100644 index 00000000..15eced54 --- /dev/null +++ b/Private/Tests/ResetLabVMDisk.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'ResetLabVMDisk Tests' { + + Context 'Parameters for ResetLabVMDisk'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'True' + } + It 'Media Parameter is of String Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.String' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '1' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '2' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolveConfigurationDataPath.Functional.Tests.ps1 b/Private/Tests/ResolveConfigurationDataPath.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolveConfigurationDataPath.Tests.ps1 b/Private/Tests/ResolveConfigurationDataPath.Tests.ps1 new file mode 100644 index 00000000..cf13e97b --- /dev/null +++ b/Private/Tests/ResolveConfigurationDataPath.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'ResolveConfigurationDataPath Tests' { + + Context 'Parameters for ResolveConfigurationDataPath'{ + + It 'Has a Parameter called Configuration' { + $Function.Parameters.Keys.Contains('Configuration') | Should Be 'True' + } + It 'Configuration Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Configuration.Attributes.Mandatory | Should be 'True' + } + It 'Configuration Parameter is of String Type' { + $Function.Parameters.Configuration.ParameterType.FullName | Should be 'System.String' + } + It 'Configuration Parameter is member of ParameterSets' { + [String]$Function.Parameters.Configuration.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Configuration Parameter Position is defined correctly' { + [String]$Function.Parameters.Configuration.Attributes.Position | Should be '0' + } + It 'Does Configuration Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Configuration.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Configuration Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Configuration.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Configuration Parameter use advanced parameter Validation? ' { + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Configuration '{ + $function.Definition.Contains('.PARAMETER Configuration') | Should Be 'True' + } + It 'Has a Parameter called IncludeDefaultPath' { + $Function.Parameters.Keys.Contains('IncludeDefaultPath') | Should Be 'True' + } + It 'IncludeDefaultPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.IncludeDefaultPath.Attributes.Mandatory | Should be 'False' + } + It 'IncludeDefaultPath Parameter is of SwitchParameter Type' { + $Function.Parameters.IncludeDefaultPath.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'IncludeDefaultPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.IncludeDefaultPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'IncludeDefaultPath Parameter Position is defined correctly' { + [String]$Function.Parameters.IncludeDefaultPath.Attributes.Position | Should be '-2147483648' + } + It 'Does IncludeDefaultPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.IncludeDefaultPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does IncludeDefaultPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.IncludeDefaultPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does IncludeDefaultPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.IncludeDefaultPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.IncludeDefaultPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.IncludeDefaultPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.IncludeDefaultPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.IncludeDefaultPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for IncludeDefaultPath '{ + $function.Definition.Contains('.PARAMETER IncludeDefaultPath') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolveCustomBootStrap.Functional.Tests.ps1 b/Private/Tests/ResolveCustomBootStrap.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolveCustomBootStrap.Tests.ps1 b/Private/Tests/ResolveCustomBootStrap.Tests.ps1 new file mode 100644 index 00000000..9bb11ef0 --- /dev/null +++ b/Private/Tests/ResolveCustomBootStrap.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'ResolveCustomBootStrap Tests' { + + Context 'Parameters for ResolveCustomBootStrap'{ + + It 'Has a Parameter called CustomBootstrapOrder' { + $Function.Parameters.Keys.Contains('CustomBootstrapOrder') | Should Be 'True' + } + It 'CustomBootstrapOrder Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.CustomBootstrapOrder.Attributes.Mandatory | Should be 'True' + } + It 'CustomBootstrapOrder Parameter is of String Type' { + $Function.Parameters.CustomBootstrapOrder.ParameterType.FullName | Should be 'System.String' + } + It 'CustomBootstrapOrder Parameter is member of ParameterSets' { + [String]$Function.Parameters.CustomBootstrapOrder.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CustomBootstrapOrder Parameter Position is defined correctly' { + [String]$Function.Parameters.CustomBootstrapOrder.Attributes.Position | Should be '0' + } + It 'Does CustomBootstrapOrder Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CustomBootstrapOrder.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does CustomBootstrapOrder Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CustomBootstrapOrder.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does CustomBootstrapOrder Parameter use advanced parameter Validation? ' { + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CustomBootstrapOrder '{ + $function.Definition.Contains('.PARAMETER CustomBootstrapOrder') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationCustomBootStrap' { + $Function.Parameters.Keys.Contains('ConfigurationCustomBootStrap') | Should Be 'True' + } + It 'ConfigurationCustomBootStrap Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationCustomBootStrap.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationCustomBootStrap Parameter is of String Type' { + $Function.Parameters.ConfigurationCustomBootStrap.ParameterType.FullName | Should be 'System.String' + } + It 'ConfigurationCustomBootStrap Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationCustomBootStrap.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationCustomBootStrap Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationCustomBootStrap.Attributes.Position | Should be '1' + } + It 'Does ConfigurationCustomBootStrap Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationCustomBootStrap.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationCustomBootStrap Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationCustomBootStrap.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationCustomBootStrap Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationCustomBootStrap.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationCustomBootStrap.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationCustomBootStrap.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationCustomBootStrap.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationCustomBootStrap.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationCustomBootStrap '{ + $function.Definition.Contains('.PARAMETER ConfigurationCustomBootStrap') | Should Be 'True' + } + It 'Has a Parameter called MediaCustomBootStrap' { + $Function.Parameters.Keys.Contains('MediaCustomBootStrap') | Should Be 'True' + } + It 'MediaCustomBootStrap Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MediaCustomBootStrap.Attributes.Mandatory | Should be 'False' + } + It 'MediaCustomBootStrap Parameter is of String[] Type' { + $Function.Parameters.MediaCustomBootStrap.ParameterType.FullName | Should be 'System.String[]' + } + It 'MediaCustomBootStrap Parameter is member of ParameterSets' { + [String]$Function.Parameters.MediaCustomBootStrap.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MediaCustomBootStrap Parameter Position is defined correctly' { + [String]$Function.Parameters.MediaCustomBootStrap.Attributes.Position | Should be '2' + } + It 'Does MediaCustomBootStrap Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MediaCustomBootStrap.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MediaCustomBootStrap Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MediaCustomBootStrap.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MediaCustomBootStrap Parameter use advanced parameter Validation? ' { + $Function.Parameters.MediaCustomBootStrap.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MediaCustomBootStrap.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MediaCustomBootStrap.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MediaCustomBootStrap.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MediaCustomBootStrap.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MediaCustomBootStrap '{ + $function.Definition.Contains('.PARAMETER MediaCustomBootStrap') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolveDismPath.Functional.Tests.ps1 b/Private/Tests/ResolveDismPath.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolveDismPath.Tests.ps1 b/Private/Tests/ResolveDismPath.Tests.ps1 new file mode 100644 index 00000000..915954df --- /dev/null +++ b/Private/Tests/ResolveDismPath.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'ResolveDismPath Tests' { + + Context 'Parameters for ResolveDismPath'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolveGitHubModuleUri.Functional.Tests.ps1 b/Private/Tests/ResolveGitHubModuleUri.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolveGitHubModuleUri.Tests.ps1 b/Private/Tests/ResolveGitHubModuleUri.Tests.ps1 new file mode 100644 index 00000000..fb2b59b9 --- /dev/null +++ b/Private/Tests/ResolveGitHubModuleUri.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'ResolveGitHubModuleUri Tests' { + + Context 'Parameters for ResolveGitHubModuleUri'{ + + It 'Has a Parameter called Owner' { + $Function.Parameters.Keys.Contains('Owner') | Should Be 'True' + } + It 'Owner Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Owner.Attributes.Mandatory | Should be 'True' + } + It 'Owner Parameter is of String Type' { + $Function.Parameters.Owner.ParameterType.FullName | Should be 'System.String' + } + It 'Owner Parameter is member of ParameterSets' { + [String]$Function.Parameters.Owner.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Owner Parameter Position is defined correctly' { + [String]$Function.Parameters.Owner.Attributes.Position | Should be '0' + } + It 'Does Owner Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Owner.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Owner Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Owner.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Owner Parameter use advanced parameter Validation? ' { + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Owner '{ + $function.Definition.Contains('.PARAMETER Owner') | Should Be 'True' + } + It 'Has a Parameter called Repository' { + $Function.Parameters.Keys.Contains('Repository') | Should Be 'True' + } + It 'Repository Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Repository.Attributes.Mandatory | Should be 'True' + } + It 'Repository Parameter is of String Type' { + $Function.Parameters.Repository.ParameterType.FullName | Should be 'System.String' + } + It 'Repository Parameter is member of ParameterSets' { + [String]$Function.Parameters.Repository.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Repository Parameter Position is defined correctly' { + [String]$Function.Parameters.Repository.Attributes.Position | Should be '1' + } + It 'Does Repository Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Repository.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Repository Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Repository.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Repository Parameter use advanced parameter Validation? ' { + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Repository.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Repository '{ + $function.Definition.Contains('.PARAMETER Repository') | Should Be 'True' + } + It 'Has a Parameter called Branch' { + $Function.Parameters.Keys.Contains('Branch') | Should Be 'True' + } + It 'Branch Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Branch.Attributes.Mandatory | Should be 'False' + } + It 'Branch Parameter is of String Type' { + $Function.Parameters.Branch.ParameterType.FullName | Should be 'System.String' + } + It 'Branch Parameter is member of ParameterSets' { + [String]$Function.Parameters.Branch.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Branch Parameter Position is defined correctly' { + [String]$Function.Parameters.Branch.Attributes.Position | Should be '2' + } + It 'Does Branch Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Branch.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Branch Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Branch.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Branch Parameter use advanced parameter Validation? ' { + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Branch '{ + $function.Definition.Contains('.PARAMETER Branch') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '3' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolveLabMedia.Functional.Tests.ps1 b/Private/Tests/ResolveLabMedia.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolveLabMedia.Tests.ps1 b/Private/Tests/ResolveLabMedia.Tests.ps1 new file mode 100644 index 00000000..3e8ae061 --- /dev/null +++ b/Private/Tests/ResolveLabMedia.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'ResolveLabMedia Tests' { + + Context 'Parameters for ResolveLabMedia'{ + + It 'Has a Parameter called Id' { + $Function.Parameters.Keys.Contains('Id') | Should Be 'True' + } + It 'Id Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Id.Attributes.Mandatory | Should be 'True' + } + It 'Id Parameter is of String Type' { + $Function.Parameters.Id.ParameterType.FullName | Should be 'System.String' + } + It 'Id Parameter is member of ParameterSets' { + [String]$Function.Parameters.Id.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Id Parameter Position is defined correctly' { + [String]$Function.Parameters.Id.Attributes.Position | Should be '0' + } + It 'Does Id Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Id Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Id Parameter use advanced parameter Validation? ' { + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Id '{ + $function.Definition.Contains('.PARAMETER Id') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolveLabModule.Functional.Tests.ps1 b/Private/Tests/ResolveLabModule.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolveLabModule.Tests.ps1 b/Private/Tests/ResolveLabModule.Tests.ps1 new file mode 100644 index 00000000..c05bd896 --- /dev/null +++ b/Private/Tests/ResolveLabModule.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'ResolveLabModule Tests' { + + Context 'Parameters for ResolveLabModule'{ + + It 'Has a Parameter called NodeName' { + $Function.Parameters.Keys.Contains('NodeName') | Should Be 'True' + } + It 'NodeName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.NodeName.Attributes.Mandatory | Should be 'True' + } + It 'NodeName Parameter is of String Type' { + $Function.Parameters.NodeName.ParameterType.FullName | Should be 'System.String' + } + It 'NodeName Parameter is member of ParameterSets' { + [String]$Function.Parameters.NodeName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NodeName Parameter Position is defined correctly' { + [String]$Function.Parameters.NodeName.Attributes.Position | Should be '0' + } + It 'Does NodeName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does NodeName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does NodeName Parameter use advanced parameter Validation? ' { + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NodeName '{ + $function.Definition.Contains('.PARAMETER NodeName') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called ModuleType' { + $Function.Parameters.Keys.Contains('ModuleType') | Should Be 'True' + } + It 'ModuleType Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ModuleType.Attributes.Mandatory | Should be 'True' + } + It 'ModuleType Parameter is of String Type' { + $Function.Parameters.ModuleType.ParameterType.FullName | Should be 'System.String' + } + It 'ModuleType Parameter is member of ParameterSets' { + [String]$Function.Parameters.ModuleType.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ModuleType Parameter Position is defined correctly' { + [String]$Function.Parameters.ModuleType.Attributes.Position | Should be '2' + } + It 'Does ModuleType Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ModuleType.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ModuleType Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ModuleType.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ModuleType Parameter use advanced parameter Validation? ' { + $Function.Parameters.ModuleType.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ModuleType.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ModuleType.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ModuleType.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ModuleType.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ModuleType '{ + $function.Definition.Contains('.PARAMETER ModuleType') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolveLabResource.Functional.Tests.ps1 b/Private/Tests/ResolveLabResource.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolveLabResource.Tests.ps1 b/Private/Tests/ResolveLabResource.Tests.ps1 new file mode 100644 index 00000000..c49fc345 --- /dev/null +++ b/Private/Tests/ResolveLabResource.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'ResolveLabResource Tests' { + + Context 'Parameters for ResolveLabResource'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called ResourceId' { + $Function.Parameters.Keys.Contains('ResourceId') | Should Be 'True' + } + It 'ResourceId Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ResourceId.Attributes.Mandatory | Should be 'True' + } + It 'ResourceId Parameter is of String Type' { + $Function.Parameters.ResourceId.ParameterType.FullName | Should be 'System.String' + } + It 'ResourceId Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceId.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourceId Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceId.Attributes.Position | Should be '1' + } + It 'Does ResourceId Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceId.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourceId Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceId.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ResourceId Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceId '{ + $function.Definition.Contains('.PARAMETER ResourceId') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolveLabSwitch.Functional.Tests.ps1 b/Private/Tests/ResolveLabSwitch.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolveLabSwitch.Tests.ps1 b/Private/Tests/ResolveLabSwitch.Tests.ps1 new file mode 100644 index 00000000..5947841f --- /dev/null +++ b/Private/Tests/ResolveLabSwitch.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'ResolveLabSwitch Tests' { + + Context 'Parameters for ResolveLabSwitch'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolveLabVMDiskPath.Functional.Tests.ps1 b/Private/Tests/ResolveLabVMDiskPath.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolveLabVMDiskPath.Tests.ps1 b/Private/Tests/ResolveLabVMDiskPath.Tests.ps1 new file mode 100644 index 00000000..8b6082cf --- /dev/null +++ b/Private/Tests/ResolveLabVMDiskPath.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'ResolveLabVMDiskPath Tests' { + + Context 'Parameters for ResolveLabVMDiskPath'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called Generation' { + $Function.Parameters.Keys.Contains('Generation') | Should Be 'True' + } + It 'Generation Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Generation.Attributes.Mandatory | Should be 'False' + } + It 'Generation Parameter is of String Type' { + $Function.Parameters.Generation.ParameterType.FullName | Should be 'System.String' + } + It 'Generation Parameter is member of ParameterSets' { + [String]$Function.Parameters.Generation.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Generation Parameter Position is defined correctly' { + [String]$Function.Parameters.Generation.Attributes.Position | Should be '1' + } + It 'Does Generation Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Generation.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Generation Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Generation.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Generation Parameter use advanced parameter Validation? ' { + $Function.Parameters.Generation.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Generation.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Generation.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Generation.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Generation.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Generation '{ + $function.Definition.Contains('.PARAMETER Generation') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolveLabVMProperties.Functional.Tests.ps1 b/Private/Tests/ResolveLabVMProperties.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolveLabVMProperties.Tests.ps1 b/Private/Tests/ResolveLabVMProperties.Tests.ps1 new file mode 100644 index 00000000..2268f0ab --- /dev/null +++ b/Private/Tests/ResolveLabVMProperties.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'ResolveLabVMProperties Tests' { + + Context 'Parameters for ResolveLabVMProperties'{ + + It 'Has a Parameter called NodeName' { + $Function.Parameters.Keys.Contains('NodeName') | Should Be 'True' + } + It 'NodeName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.NodeName.Attributes.Mandatory | Should be 'True' + } + It 'NodeName Parameter is of String Type' { + $Function.Parameters.NodeName.ParameterType.FullName | Should be 'System.String' + } + It 'NodeName Parameter is member of ParameterSets' { + [String]$Function.Parameters.NodeName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NodeName Parameter Position is defined correctly' { + [String]$Function.Parameters.NodeName.Attributes.Position | Should be '0' + } + It 'Does NodeName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does NodeName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does NodeName Parameter use advanced parameter Validation? ' { + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NodeName '{ + $function.Definition.Contains('.PARAMETER NodeName') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called NoEnumerateWildcardNode' { + $Function.Parameters.Keys.Contains('NoEnumerateWildcardNode') | Should Be 'True' + } + It 'NoEnumerateWildcardNode Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.NoEnumerateWildcardNode.Attributes.Mandatory | Should be 'False' + } + It 'NoEnumerateWildcardNode Parameter is of SwitchParameter Type' { + $Function.Parameters.NoEnumerateWildcardNode.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'NoEnumerateWildcardNode Parameter is member of ParameterSets' { + [String]$Function.Parameters.NoEnumerateWildcardNode.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NoEnumerateWildcardNode Parameter Position is defined correctly' { + [String]$Function.Parameters.NoEnumerateWildcardNode.Attributes.Position | Should be '-2147483648' + } + It 'Does NoEnumerateWildcardNode Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NoEnumerateWildcardNode.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does NoEnumerateWildcardNode Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NoEnumerateWildcardNode.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does NoEnumerateWildcardNode Parameter use advanced parameter Validation? ' { + $Function.Parameters.NoEnumerateWildcardNode.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NoEnumerateWildcardNode.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NoEnumerateWildcardNode.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NoEnumerateWildcardNode.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NoEnumerateWildcardNode.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NoEnumerateWildcardNode '{ + $function.Definition.Contains('.PARAMETER NoEnumerateWildcardNode') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolveModule.Functional.Tests.ps1 b/Private/Tests/ResolveModule.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolveModule.Tests.ps1 b/Private/Tests/ResolveModule.Tests.ps1 new file mode 100644 index 00000000..9167eaa1 --- /dev/null +++ b/Private/Tests/ResolveModule.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'ResolveModule Tests' { + + Context 'Parameters for ResolveModule'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called ModuleType' { + $Function.Parameters.Keys.Contains('ModuleType') | Should Be 'True' + } + It 'ModuleType Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ModuleType.Attributes.Mandatory | Should be 'True' + } + It 'ModuleType Parameter is of String Type' { + $Function.Parameters.ModuleType.ParameterType.FullName | Should be 'System.String' + } + It 'ModuleType Parameter is member of ParameterSets' { + [String]$Function.Parameters.ModuleType.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ModuleType Parameter Position is defined correctly' { + [String]$Function.Parameters.ModuleType.Attributes.Position | Should be '1' + } + It 'Does ModuleType Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ModuleType.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ModuleType Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ModuleType.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ModuleType Parameter use advanced parameter Validation? ' { + $Function.Parameters.ModuleType.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ModuleType.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ModuleType.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ModuleType.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ModuleType.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ModuleType '{ + $function.Definition.Contains('.PARAMETER ModuleType') | Should Be 'True' + } + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'False' + } + It 'Name Parameter is of String[] Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String[]' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '2' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called ThrowIfNotFound' { + $Function.Parameters.Keys.Contains('ThrowIfNotFound') | Should Be 'True' + } + It 'ThrowIfNotFound Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ThrowIfNotFound.Attributes.Mandatory | Should be 'False' + } + It 'ThrowIfNotFound Parameter is of SwitchParameter Type' { + $Function.Parameters.ThrowIfNotFound.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'ThrowIfNotFound Parameter is member of ParameterSets' { + [String]$Function.Parameters.ThrowIfNotFound.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ThrowIfNotFound Parameter Position is defined correctly' { + [String]$Function.Parameters.ThrowIfNotFound.Attributes.Position | Should be '-2147483648' + } + It 'Does ThrowIfNotFound Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ThrowIfNotFound.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ThrowIfNotFound Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ThrowIfNotFound.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ThrowIfNotFound Parameter use advanced parameter Validation? ' { + $Function.Parameters.ThrowIfNotFound.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ThrowIfNotFound.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ThrowIfNotFound.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ThrowIfNotFound.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ThrowIfNotFound.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ThrowIfNotFound '{ + $function.Definition.Contains('.PARAMETER ThrowIfNotFound') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolvePSGalleryModuleUri.Functional.Tests.ps1 b/Private/Tests/ResolvePSGalleryModuleUri.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolvePSGalleryModuleUri.Tests.ps1 b/Private/Tests/ResolvePSGalleryModuleUri.Tests.ps1 new file mode 100644 index 00000000..db5487a0 --- /dev/null +++ b/Private/Tests/ResolvePSGalleryModuleUri.Tests.ps1 @@ -0,0 +1,190 @@ +Describe 'ResolvePSGalleryModuleUri Tests' { + + Context 'Parameters for ResolvePSGalleryModuleUri'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called MinimumVersion' { + $Function.Parameters.Keys.Contains('MinimumVersion') | Should Be 'True' + } + It 'MinimumVersion Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MinimumVersion.Attributes.Mandatory | Should be 'False' + } + It 'MinimumVersion Parameter is of Version Type' { + $Function.Parameters.MinimumVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'MinimumVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumVersion.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MinimumVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumVersion.Attributes.Position | Should be '1' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MinimumVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumVersion '{ + $function.Definition.Contains('.PARAMETER MinimumVersion') | Should Be 'True' + } + It 'Has a Parameter called RequiredVersion' { + $Function.Parameters.Keys.Contains('RequiredVersion') | Should Be 'True' + } + It 'RequiredVersion Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RequiredVersion.Attributes.Mandatory | Should be 'False' + } + It 'RequiredVersion Parameter is of Version Type' { + $Function.Parameters.RequiredVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'RequiredVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.RequiredVersion.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RequiredVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.RequiredVersion.Attributes.Position | Should be '2' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RequiredVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RequiredVersion '{ + $function.Definition.Contains('.PARAMETER RequiredVersion') | Should Be 'True' + } + It 'Has a Parameter called Uri' { + $Function.Parameters.Keys.Contains('Uri') | Should Be 'True' + } + It 'Uri Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Uri.Attributes.Mandatory | Should be 'False' + } + It 'Uri Parameter is of String Type' { + $Function.Parameters.Uri.ParameterType.FullName | Should be 'System.String' + } + It 'Uri Parameter is member of ParameterSets' { + [String]$Function.Parameters.Uri.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Uri Parameter Position is defined correctly' { + [String]$Function.Parameters.Uri.Attributes.Position | Should be '3' + } + It 'Does Uri Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Uri Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Uri Parameter use advanced parameter Validation? ' { + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Uri '{ + $function.Definition.Contains('.PARAMETER Uri') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '4' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolvePathEx.Functional.Tests.ps1 b/Private/Tests/ResolvePathEx.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolvePathEx.Tests.ps1 b/Private/Tests/ResolvePathEx.Tests.ps1 new file mode 100644 index 00000000..4c6d608d --- /dev/null +++ b/Private/Tests/ResolvePathEx.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'ResolvePathEx Tests' { + + Context 'Parameters for ResolvePathEx'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ResolveProgramFilesFolder.Functional.Tests.ps1 b/Private/Tests/ResolveProgramFilesFolder.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ResolveProgramFilesFolder.Tests.ps1 b/Private/Tests/ResolveProgramFilesFolder.Tests.ps1 new file mode 100644 index 00000000..21b7f756 --- /dev/null +++ b/Private/Tests/ResolveProgramFilesFolder.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'ResolveProgramFilesFolder Tests' { + + Context 'Parameters for ResolveProgramFilesFolder'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be 'Path' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '-2147483648' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called Drive' { + $Function.Parameters.Keys.Contains('Drive') | Should Be 'True' + } + It 'Drive Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Drive.Attributes.Mandatory | Should be 'True' + } + It 'Drive Parameter is of String Type' { + $Function.Parameters.Drive.ParameterType.FullName | Should be 'System.String' + } + It 'Drive Parameter is member of ParameterSets' { + [String]$Function.Parameters.Drive.ParameterSets.Keys | Should Be 'Drive' + } + It 'Drive Parameter Position is defined correctly' { + [String]$Function.Parameters.Drive.Attributes.Position | Should be '-2147483648' + } + It 'Does Drive Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Drive.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Drive Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Drive.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Drive Parameter use advanced parameter Validation? ' { + $Function.Parameters.Drive.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Drive.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Drive.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Drive.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Drive.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Drive '{ + $function.Definition.Contains('.PARAMETER Drive') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetBootStrap.Functional.Tests.ps1 b/Private/Tests/SetBootStrap.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetBootStrap.Tests.ps1 b/Private/Tests/SetBootStrap.Tests.ps1 new file mode 100644 index 00000000..f2ea2991 --- /dev/null +++ b/Private/Tests/SetBootStrap.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'SetBootStrap Tests' { + + Context 'Parameters for SetBootStrap'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called CustomBootStrap' { + $Function.Parameters.Keys.Contains('CustomBootStrap') | Should Be 'True' + } + It 'CustomBootStrap Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CustomBootStrap.Attributes.Mandatory | Should be 'False' + } + It 'CustomBootStrap Parameter is of String Type' { + $Function.Parameters.CustomBootStrap.ParameterType.FullName | Should be 'System.String' + } + It 'CustomBootStrap Parameter is member of ParameterSets' { + [String]$Function.Parameters.CustomBootStrap.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CustomBootStrap Parameter Position is defined correctly' { + [String]$Function.Parameters.CustomBootStrap.Attributes.Position | Should be '1' + } + It 'Does CustomBootStrap Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CustomBootStrap.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CustomBootStrap Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CustomBootStrap.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CustomBootStrap Parameter use advanced parameter Validation? ' { + $Function.Parameters.CustomBootStrap.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.CustomBootStrap.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.CustomBootStrap.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CustomBootStrap.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CustomBootStrap.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CustomBootStrap '{ + $function.Definition.Contains('.PARAMETER CustomBootStrap') | Should Be 'True' + } + It 'Has a Parameter called CoreCLR' { + $Function.Parameters.Keys.Contains('CoreCLR') | Should Be 'True' + } + It 'CoreCLR Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CoreCLR.Attributes.Mandatory | Should be 'False' + } + It 'CoreCLR Parameter is of SwitchParameter Type' { + $Function.Parameters.CoreCLR.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'CoreCLR Parameter is member of ParameterSets' { + [String]$Function.Parameters.CoreCLR.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CoreCLR Parameter Position is defined correctly' { + [String]$Function.Parameters.CoreCLR.Attributes.Position | Should be '-2147483648' + } + It 'Does CoreCLR Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CoreCLR.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CoreCLR Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CoreCLR.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CoreCLR Parameter use advanced parameter Validation? ' { + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CoreCLR '{ + $function.Definition.Contains('.PARAMETER CoreCLR') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetConfigurationData.Functional.Tests.ps1 b/Private/Tests/SetConfigurationData.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetConfigurationData.Tests.ps1 b/Private/Tests/SetConfigurationData.Tests.ps1 new file mode 100644 index 00000000..81125dd9 --- /dev/null +++ b/Private/Tests/SetConfigurationData.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'SetConfigurationData Tests' { + + Context 'Parameters for SetConfigurationData'{ + + It 'Has a Parameter called Configuration' { + $Function.Parameters.Keys.Contains('Configuration') | Should Be 'True' + } + It 'Configuration Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Configuration.Attributes.Mandatory | Should be 'True' + } + It 'Configuration Parameter is of String Type' { + $Function.Parameters.Configuration.ParameterType.FullName | Should be 'System.String' + } + It 'Configuration Parameter is member of ParameterSets' { + [String]$Function.Parameters.Configuration.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Configuration Parameter Position is defined correctly' { + [String]$Function.Parameters.Configuration.Attributes.Position | Should be '0' + } + It 'Does Configuration Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Configuration.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Configuration Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Configuration.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Configuration Parameter use advanced parameter Validation? ' { + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Configuration.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Configuration '{ + $function.Definition.Contains('.PARAMETER Configuration') | Should Be 'True' + } + It 'Has a Parameter called InputObject' { + $Function.Parameters.Keys.Contains('InputObject') | Should Be 'True' + } + It 'InputObject Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.InputObject.Attributes.Mandatory | Should be 'True' + } + It 'InputObject Parameter is of Object Type' { + $Function.Parameters.InputObject.ParameterType.FullName | Should be 'System.Object' + } + It 'InputObject Parameter is member of ParameterSets' { + [String]$Function.Parameters.InputObject.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'InputObject Parameter Position is defined correctly' { + [String]$Function.Parameters.InputObject.Attributes.Position | Should be '1' + } + It 'Does InputObject Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.InputObject.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does InputObject Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.InputObject.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does InputObject Parameter use advanced parameter Validation? ' { + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.InputObject.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for InputObject '{ + $function.Definition.Contains('.PARAMETER InputObject') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetDiskImageBootVolume.Functional.Tests.ps1 b/Private/Tests/SetDiskImageBootVolume.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetDiskImageBootVolume.Tests.ps1 b/Private/Tests/SetDiskImageBootVolume.Tests.ps1 new file mode 100644 index 00000000..838a2cdb --- /dev/null +++ b/Private/Tests/SetDiskImageBootVolume.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'SetDiskImageBootVolume Tests' { + + Context 'Parameters for SetDiskImageBootVolume'{ + + It 'Has a Parameter called Vhd' { + $Function.Parameters.Keys.Contains('Vhd') | Should Be 'True' + } + It 'Vhd Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Vhd.Attributes.Mandatory | Should be 'True' + } + It 'Vhd Parameter is of Object Type' { + $Function.Parameters.Vhd.ParameterType.FullName | Should be 'System.Object' + } + It 'Vhd Parameter is member of ParameterSets' { + [String]$Function.Parameters.Vhd.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Vhd Parameter Position is defined correctly' { + [String]$Function.Parameters.Vhd.Attributes.Position | Should be '0' + } + It 'Does Vhd Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Vhd Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Vhd Parameter use advanced parameter Validation? ' { + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Vhd '{ + $function.Definition.Contains('.PARAMETER Vhd') | Should Be 'True' + } + It 'Has a Parameter called PartitionStyle' { + $Function.Parameters.Keys.Contains('PartitionStyle') | Should Be 'True' + } + It 'PartitionStyle Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.PartitionStyle.Attributes.Mandatory | Should be 'True' + } + It 'PartitionStyle Parameter is of String Type' { + $Function.Parameters.PartitionStyle.ParameterType.FullName | Should be 'System.String' + } + It 'PartitionStyle Parameter is member of ParameterSets' { + [String]$Function.Parameters.PartitionStyle.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'PartitionStyle Parameter Position is defined correctly' { + [String]$Function.Parameters.PartitionStyle.Attributes.Position | Should be '1' + } + It 'Does PartitionStyle Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.PartitionStyle.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does PartitionStyle Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.PartitionStyle.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does PartitionStyle Parameter use advanced parameter Validation? ' { + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.PartitionStyle.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for PartitionStyle '{ + $function.Definition.Contains('.PARAMETER PartitionStyle') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetDiskImageBootVolumeGpt.Functional.Tests.ps1 b/Private/Tests/SetDiskImageBootVolumeGpt.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetDiskImageBootVolumeGpt.Tests.ps1 b/Private/Tests/SetDiskImageBootVolumeGpt.Tests.ps1 new file mode 100644 index 00000000..6ff4092b --- /dev/null +++ b/Private/Tests/SetDiskImageBootVolumeGpt.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'SetDiskImageBootVolumeGpt Tests' { + + Context 'Parameters for SetDiskImageBootVolumeGpt'{ + + It 'Has a Parameter called Vhd' { + $Function.Parameters.Keys.Contains('Vhd') | Should Be 'True' + } + It 'Vhd Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Vhd.Attributes.Mandatory | Should be 'True' + } + It 'Vhd Parameter is of Object Type' { + $Function.Parameters.Vhd.ParameterType.FullName | Should be 'System.Object' + } + It 'Vhd Parameter is member of ParameterSets' { + [String]$Function.Parameters.Vhd.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Vhd Parameter Position is defined correctly' { + [String]$Function.Parameters.Vhd.Attributes.Position | Should be '0' + } + It 'Does Vhd Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Vhd Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Vhd Parameter use advanced parameter Validation? ' { + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Vhd '{ + $function.Definition.Contains('.PARAMETER Vhd') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetDiskImageBootVolumeMbr.Functional.Tests.ps1 b/Private/Tests/SetDiskImageBootVolumeMbr.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetDiskImageBootVolumeMbr.Tests.ps1 b/Private/Tests/SetDiskImageBootVolumeMbr.Tests.ps1 new file mode 100644 index 00000000..e5941e68 --- /dev/null +++ b/Private/Tests/SetDiskImageBootVolumeMbr.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'SetDiskImageBootVolumeMbr Tests' { + + Context 'Parameters for SetDiskImageBootVolumeMbr'{ + + It 'Has a Parameter called Vhd' { + $Function.Parameters.Keys.Contains('Vhd') | Should Be 'True' + } + It 'Vhd Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Vhd.Attributes.Mandatory | Should be 'True' + } + It 'Vhd Parameter is of Object Type' { + $Function.Parameters.Vhd.ParameterType.FullName | Should be 'System.Object' + } + It 'Vhd Parameter is member of ParameterSets' { + [String]$Function.Parameters.Vhd.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Vhd Parameter Position is defined correctly' { + [String]$Function.Parameters.Vhd.Attributes.Position | Should be '0' + } + It 'Does Vhd Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Vhd Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Vhd.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Vhd Parameter use advanced parameter Validation? ' { + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Vhd.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Vhd '{ + $function.Definition.Contains('.PARAMETER Vhd') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetDscResource.Functional.Tests.ps1 b/Private/Tests/SetDscResource.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetDscResource.Tests.ps1 b/Private/Tests/SetDscResource.Tests.ps1 new file mode 100644 index 00000000..eb303d48 --- /dev/null +++ b/Private/Tests/SetDscResource.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'SetDscResource Tests' { + + Context 'Parameters for SetDscResource'{ + + It 'Has a Parameter called ResourceName' { + $Function.Parameters.Keys.Contains('ResourceName') | Should Be 'True' + } + It 'ResourceName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ResourceName.Attributes.Mandatory | Should be 'True' + } + It 'ResourceName Parameter is of String Type' { + $Function.Parameters.ResourceName.ParameterType.FullName | Should be 'System.String' + } + It 'ResourceName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourceName Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceName.Attributes.Position | Should be '0' + } + It 'Does ResourceName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ResourceName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ResourceName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceName '{ + $function.Definition.Contains('.PARAMETER ResourceName') | Should Be 'True' + } + It 'Has a Parameter called Parameters' { + $Function.Parameters.Keys.Contains('Parameters') | Should Be 'True' + } + It 'Parameters Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Parameters.Attributes.Mandatory | Should be 'True' + } + It 'Parameters Parameter is of Hashtable Type' { + $Function.Parameters.Parameters.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'Parameters Parameter is member of ParameterSets' { + [String]$Function.Parameters.Parameters.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Parameters Parameter Position is defined correctly' { + [String]$Function.Parameters.Parameters.Attributes.Position | Should be '1' + } + It 'Does Parameters Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Parameters.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Parameters Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Parameters.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Parameters Parameter use advanced parameter Validation? ' { + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Parameters '{ + $function.Definition.Contains('.PARAMETER Parameters') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetLabSwitch.Functional.Tests.ps1 b/Private/Tests/SetLabSwitch.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetLabSwitch.Tests.ps1 b/Private/Tests/SetLabSwitch.Tests.ps1 new file mode 100644 index 00000000..4b2459d4 --- /dev/null +++ b/Private/Tests/SetLabSwitch.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'SetLabSwitch Tests' { + + Context 'Parameters for SetLabSwitch'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetLabVMDisk.Functional.Tests.ps1 b/Private/Tests/SetLabVMDisk.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetLabVMDisk.Tests.ps1 b/Private/Tests/SetLabVMDisk.Tests.ps1 new file mode 100644 index 00000000..2a042359 --- /dev/null +++ b/Private/Tests/SetLabVMDisk.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'SetLabVMDisk Tests' { + + Context 'Parameters for SetLabVMDisk'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'True' + } + It 'Media Parameter is of String Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.String' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '1' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '2' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetLabVMDiskFile.Functional.Tests.ps1 b/Private/Tests/SetLabVMDiskFile.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetLabVMDiskFile.Tests.ps1 b/Private/Tests/SetLabVMDiskFile.Tests.ps1 new file mode 100644 index 00000000..e0c20779 --- /dev/null +++ b/Private/Tests/SetLabVMDiskFile.Tests.ps1 @@ -0,0 +1,252 @@ +Describe 'SetLabVMDiskFile Tests' { + + Context 'Parameters for SetLabVMDiskFile'{ + + It 'Has a Parameter called NodeName' { + $Function.Parameters.Keys.Contains('NodeName') | Should Be 'True' + } + It 'NodeName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.NodeName.Attributes.Mandatory | Should be 'True' + } + It 'NodeName Parameter is of String Type' { + $Function.Parameters.NodeName.ParameterType.FullName | Should be 'System.String' + } + It 'NodeName Parameter is member of ParameterSets' { + [String]$Function.Parameters.NodeName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NodeName Parameter Position is defined correctly' { + [String]$Function.Parameters.NodeName.Attributes.Position | Should be '0' + } + It 'Does NodeName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does NodeName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does NodeName Parameter use advanced parameter Validation? ' { + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NodeName '{ + $function.Definition.Contains('.PARAMETER NodeName') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called Credential' { + $Function.Parameters.Keys.Contains('Credential') | Should Be 'True' + } + It 'Credential Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Credential.Attributes.Mandatory | Should be 'True' + } + It 'Credential Parameter is of PSCredential Type' { + $Function.Parameters.Credential.ParameterType.FullName | Should be 'System.Management.Automation.PSCredential' + } + It 'Credential Parameter is member of ParameterSets' { + [String]$Function.Parameters.Credential.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Credential Parameter Position is defined correctly' { + [String]$Function.Parameters.Credential.Attributes.Position | Should be '2' + } + It 'Does Credential Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Credential Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Credential Parameter use advanced parameter Validation? ' { + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Credential '{ + $function.Definition.Contains('.PARAMETER Credential') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '3' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called CustomBootstrap' { + $Function.Parameters.Keys.Contains('CustomBootstrap') | Should Be 'True' + } + It 'CustomBootstrap Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CustomBootstrap.Attributes.Mandatory | Should be 'False' + } + It 'CustomBootstrap Parameter is of String Type' { + $Function.Parameters.CustomBootstrap.ParameterType.FullName | Should be 'System.String' + } + It 'CustomBootstrap Parameter is member of ParameterSets' { + [String]$Function.Parameters.CustomBootstrap.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CustomBootstrap Parameter Position is defined correctly' { + [String]$Function.Parameters.CustomBootstrap.Attributes.Position | Should be '4' + } + It 'Does CustomBootstrap Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CustomBootstrap.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CustomBootstrap Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CustomBootstrap.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CustomBootstrap Parameter use advanced parameter Validation? ' { + $Function.Parameters.CustomBootstrap.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.CustomBootstrap.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrap.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CustomBootstrap.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrap.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CustomBootstrap '{ + $function.Definition.Contains('.PARAMETER CustomBootstrap') | Should Be 'True' + } + It 'Has a Parameter called CoreCLR' { + $Function.Parameters.Keys.Contains('CoreCLR') | Should Be 'True' + } + It 'CoreCLR Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CoreCLR.Attributes.Mandatory | Should be 'False' + } + It 'CoreCLR Parameter is of SwitchParameter Type' { + $Function.Parameters.CoreCLR.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'CoreCLR Parameter is member of ParameterSets' { + [String]$Function.Parameters.CoreCLR.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CoreCLR Parameter Position is defined correctly' { + [String]$Function.Parameters.CoreCLR.Attributes.Position | Should be '-2147483648' + } + It 'Does CoreCLR Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CoreCLR.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CoreCLR Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CoreCLR.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CoreCLR Parameter use advanced parameter Validation? ' { + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CoreCLR '{ + $function.Definition.Contains('.PARAMETER CoreCLR') | Should Be 'True' + } + It 'Has a Parameter called ProductKey' { + $Function.Parameters.Keys.Contains('ProductKey') | Should Be 'True' + } + It 'ProductKey Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ProductKey.Attributes.Mandatory | Should be 'False' + } + It 'ProductKey Parameter is of String Type' { + $Function.Parameters.ProductKey.ParameterType.FullName | Should be 'System.String' + } + It 'ProductKey Parameter is member of ParameterSets' { + [String]$Function.Parameters.ProductKey.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ProductKey Parameter Position is defined correctly' { + [String]$Function.Parameters.ProductKey.Attributes.Position | Should be '5' + } + It 'Does ProductKey Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ProductKey.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ProductKey Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ProductKey.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ProductKey Parameter use advanced parameter Validation? ' { + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ProductKey '{ + $function.Definition.Contains('.PARAMETER ProductKey') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetLabVMDiskFileBootstrap.Functional.Tests.ps1 b/Private/Tests/SetLabVMDiskFileBootstrap.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetLabVMDiskFileBootstrap.Tests.ps1 b/Private/Tests/SetLabVMDiskFileBootstrap.Tests.ps1 new file mode 100644 index 00000000..bc1c4e7e --- /dev/null +++ b/Private/Tests/SetLabVMDiskFileBootstrap.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'SetLabVMDiskFileBootstrap Tests' { + + Context 'Parameters for SetLabVMDiskFileBootstrap'{ + + It 'Has a Parameter called VhdDriveLetter' { + $Function.Parameters.Keys.Contains('VhdDriveLetter') | Should Be 'True' + } + It 'VhdDriveLetter Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.Mandatory | Should be 'True' + } + It 'VhdDriveLetter Parameter is of String Type' { + $Function.Parameters.VhdDriveLetter.ParameterType.FullName | Should be 'System.String' + } + It 'VhdDriveLetter Parameter is member of ParameterSets' { + [String]$Function.Parameters.VhdDriveLetter.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'VhdDriveLetter Parameter Position is defined correctly' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.Position | Should be '0' + } + It 'Does VhdDriveLetter Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does VhdDriveLetter Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does VhdDriveLetter Parameter use advanced parameter Validation? ' { + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for VhdDriveLetter '{ + $function.Definition.Contains('.PARAMETER VhdDriveLetter') | Should Be 'True' + } + It 'Has a Parameter called CustomBootstrap' { + $Function.Parameters.Keys.Contains('CustomBootstrap') | Should Be 'True' + } + It 'CustomBootstrap Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CustomBootstrap.Attributes.Mandatory | Should be 'False' + } + It 'CustomBootstrap Parameter is of String Type' { + $Function.Parameters.CustomBootstrap.ParameterType.FullName | Should be 'System.String' + } + It 'CustomBootstrap Parameter is member of ParameterSets' { + [String]$Function.Parameters.CustomBootstrap.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CustomBootstrap Parameter Position is defined correctly' { + [String]$Function.Parameters.CustomBootstrap.Attributes.Position | Should be '1' + } + It 'Does CustomBootstrap Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CustomBootstrap.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CustomBootstrap Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CustomBootstrap.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CustomBootstrap Parameter use advanced parameter Validation? ' { + $Function.Parameters.CustomBootstrap.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.CustomBootstrap.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrap.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CustomBootstrap.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrap.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CustomBootstrap '{ + $function.Definition.Contains('.PARAMETER CustomBootstrap') | Should Be 'True' + } + It 'Has a Parameter called CoreCLR' { + $Function.Parameters.Keys.Contains('CoreCLR') | Should Be 'True' + } + It 'CoreCLR Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CoreCLR.Attributes.Mandatory | Should be 'False' + } + It 'CoreCLR Parameter is of SwitchParameter Type' { + $Function.Parameters.CoreCLR.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'CoreCLR Parameter is member of ParameterSets' { + [String]$Function.Parameters.CoreCLR.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CoreCLR Parameter Position is defined correctly' { + [String]$Function.Parameters.CoreCLR.Attributes.Position | Should be '-2147483648' + } + It 'Does CoreCLR Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CoreCLR.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CoreCLR Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CoreCLR.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CoreCLR Parameter use advanced parameter Validation? ' { + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CoreCLR '{ + $function.Definition.Contains('.PARAMETER CoreCLR') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '2' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetLabVMDiskFileCertificate.Functional.Tests.ps1 b/Private/Tests/SetLabVMDiskFileCertificate.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetLabVMDiskFileCertificate.Tests.ps1 b/Private/Tests/SetLabVMDiskFileCertificate.Tests.ps1 new file mode 100644 index 00000000..2c9b9f83 --- /dev/null +++ b/Private/Tests/SetLabVMDiskFileCertificate.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'SetLabVMDiskFileCertificate Tests' { + + Context 'Parameters for SetLabVMDiskFileCertificate'{ + + It 'Has a Parameter called NodeName' { + $Function.Parameters.Keys.Contains('NodeName') | Should Be 'True' + } + It 'NodeName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.NodeName.Attributes.Mandatory | Should be 'True' + } + It 'NodeName Parameter is of String Type' { + $Function.Parameters.NodeName.ParameterType.FullName | Should be 'System.String' + } + It 'NodeName Parameter is member of ParameterSets' { + [String]$Function.Parameters.NodeName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NodeName Parameter Position is defined correctly' { + [String]$Function.Parameters.NodeName.Attributes.Position | Should be '0' + } + It 'Does NodeName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does NodeName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does NodeName Parameter use advanced parameter Validation? ' { + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NodeName '{ + $function.Definition.Contains('.PARAMETER NodeName') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called VhdDriveLetter' { + $Function.Parameters.Keys.Contains('VhdDriveLetter') | Should Be 'True' + } + It 'VhdDriveLetter Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.Mandatory | Should be 'True' + } + It 'VhdDriveLetter Parameter is of String Type' { + $Function.Parameters.VhdDriveLetter.ParameterType.FullName | Should be 'System.String' + } + It 'VhdDriveLetter Parameter is member of ParameterSets' { + [String]$Function.Parameters.VhdDriveLetter.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'VhdDriveLetter Parameter Position is defined correctly' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.Position | Should be '2' + } + It 'Does VhdDriveLetter Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does VhdDriveLetter Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does VhdDriveLetter Parameter use advanced parameter Validation? ' { + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for VhdDriveLetter '{ + $function.Definition.Contains('.PARAMETER VhdDriveLetter') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '3' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetLabVMDiskFileModule.Functional.Tests.ps1 b/Private/Tests/SetLabVMDiskFileModule.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetLabVMDiskFileModule.Tests.ps1 b/Private/Tests/SetLabVMDiskFileModule.Tests.ps1 new file mode 100644 index 00000000..d9d64a66 --- /dev/null +++ b/Private/Tests/SetLabVMDiskFileModule.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'SetLabVMDiskFileModule Tests' { + + Context 'Parameters for SetLabVMDiskFileModule'{ + + It 'Has a Parameter called NodeName' { + $Function.Parameters.Keys.Contains('NodeName') | Should Be 'True' + } + It 'NodeName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.NodeName.Attributes.Mandatory | Should be 'True' + } + It 'NodeName Parameter is of String Type' { + $Function.Parameters.NodeName.ParameterType.FullName | Should be 'System.String' + } + It 'NodeName Parameter is member of ParameterSets' { + [String]$Function.Parameters.NodeName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NodeName Parameter Position is defined correctly' { + [String]$Function.Parameters.NodeName.Attributes.Position | Should be '0' + } + It 'Does NodeName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does NodeName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does NodeName Parameter use advanced parameter Validation? ' { + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NodeName '{ + $function.Definition.Contains('.PARAMETER NodeName') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called VhdDriveLetter' { + $Function.Parameters.Keys.Contains('VhdDriveLetter') | Should Be 'True' + } + It 'VhdDriveLetter Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.Mandatory | Should be 'True' + } + It 'VhdDriveLetter Parameter is of String Type' { + $Function.Parameters.VhdDriveLetter.ParameterType.FullName | Should be 'System.String' + } + It 'VhdDriveLetter Parameter is member of ParameterSets' { + [String]$Function.Parameters.VhdDriveLetter.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'VhdDriveLetter Parameter Position is defined correctly' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.Position | Should be '2' + } + It 'Does VhdDriveLetter Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does VhdDriveLetter Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does VhdDriveLetter Parameter use advanced parameter Validation? ' { + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for VhdDriveLetter '{ + $function.Definition.Contains('.PARAMETER VhdDriveLetter') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '3' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetLabVMDiskFileMof.Functional.Tests.ps1 b/Private/Tests/SetLabVMDiskFileMof.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetLabVMDiskFileMof.Tests.ps1 b/Private/Tests/SetLabVMDiskFileMof.Tests.ps1 new file mode 100644 index 00000000..ed45e3b0 --- /dev/null +++ b/Private/Tests/SetLabVMDiskFileMof.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'SetLabVMDiskFileMof Tests' { + + Context 'Parameters for SetLabVMDiskFileMof'{ + + It 'Has a Parameter called NodeName' { + $Function.Parameters.Keys.Contains('NodeName') | Should Be 'True' + } + It 'NodeName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.NodeName.Attributes.Mandatory | Should be 'True' + } + It 'NodeName Parameter is of String Type' { + $Function.Parameters.NodeName.ParameterType.FullName | Should be 'System.String' + } + It 'NodeName Parameter is member of ParameterSets' { + [String]$Function.Parameters.NodeName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NodeName Parameter Position is defined correctly' { + [String]$Function.Parameters.NodeName.Attributes.Position | Should be '0' + } + It 'Does NodeName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does NodeName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does NodeName Parameter use advanced parameter Validation? ' { + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NodeName '{ + $function.Definition.Contains('.PARAMETER NodeName') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '1' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called VhdDriveLetter' { + $Function.Parameters.Keys.Contains('VhdDriveLetter') | Should Be 'True' + } + It 'VhdDriveLetter Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.Mandatory | Should be 'True' + } + It 'VhdDriveLetter Parameter is of String Type' { + $Function.Parameters.VhdDriveLetter.ParameterType.FullName | Should be 'System.String' + } + It 'VhdDriveLetter Parameter is member of ParameterSets' { + [String]$Function.Parameters.VhdDriveLetter.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'VhdDriveLetter Parameter Position is defined correctly' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.Position | Should be '2' + } + It 'Does VhdDriveLetter Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does VhdDriveLetter Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does VhdDriveLetter Parameter use advanced parameter Validation? ' { + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for VhdDriveLetter '{ + $function.Definition.Contains('.PARAMETER VhdDriveLetter') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '3' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetLabVMDiskFileResource.Functional.Tests.ps1 b/Private/Tests/SetLabVMDiskFileResource.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetLabVMDiskFileResource.Tests.ps1 b/Private/Tests/SetLabVMDiskFileResource.Tests.ps1 new file mode 100644 index 00000000..06a02dcf --- /dev/null +++ b/Private/Tests/SetLabVMDiskFileResource.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'SetLabVMDiskFileResource Tests' { + + Context 'Parameters for SetLabVMDiskFileResource'{ + + It 'Has a Parameter called NodeName' { + $Function.Parameters.Keys.Contains('NodeName') | Should Be 'True' + } + It 'NodeName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.NodeName.Attributes.Mandatory | Should be 'True' + } + It 'NodeName Parameter is of String Type' { + $Function.Parameters.NodeName.ParameterType.FullName | Should be 'System.String' + } + It 'NodeName Parameter is member of ParameterSets' { + [String]$Function.Parameters.NodeName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NodeName Parameter Position is defined correctly' { + [String]$Function.Parameters.NodeName.Attributes.Position | Should be '0' + } + It 'Does NodeName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does NodeName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does NodeName Parameter use advanced parameter Validation? ' { + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NodeName '{ + $function.Definition.Contains('.PARAMETER NodeName') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called VhdDriveLetter' { + $Function.Parameters.Keys.Contains('VhdDriveLetter') | Should Be 'True' + } + It 'VhdDriveLetter Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.Mandatory | Should be 'True' + } + It 'VhdDriveLetter Parameter is of String Type' { + $Function.Parameters.VhdDriveLetter.ParameterType.FullName | Should be 'System.String' + } + It 'VhdDriveLetter Parameter is member of ParameterSets' { + [String]$Function.Parameters.VhdDriveLetter.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'VhdDriveLetter Parameter Position is defined correctly' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.Position | Should be '2' + } + It 'Does VhdDriveLetter Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does VhdDriveLetter Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does VhdDriveLetter Parameter use advanced parameter Validation? ' { + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for VhdDriveLetter '{ + $function.Definition.Contains('.PARAMETER VhdDriveLetter') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '3' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetLabVMDiskFileUnattendXml.Functional.Tests.ps1 b/Private/Tests/SetLabVMDiskFileUnattendXml.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetLabVMDiskFileUnattendXml.Tests.ps1 b/Private/Tests/SetLabVMDiskFileUnattendXml.Tests.ps1 new file mode 100644 index 00000000..73b2992a --- /dev/null +++ b/Private/Tests/SetLabVMDiskFileUnattendXml.Tests.ps1 @@ -0,0 +1,221 @@ +Describe 'SetLabVMDiskFileUnattendXml Tests' { + + Context 'Parameters for SetLabVMDiskFileUnattendXml'{ + + It 'Has a Parameter called NodeName' { + $Function.Parameters.Keys.Contains('NodeName') | Should Be 'True' + } + It 'NodeName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.NodeName.Attributes.Mandatory | Should be 'True' + } + It 'NodeName Parameter is of String Type' { + $Function.Parameters.NodeName.ParameterType.FullName | Should be 'System.String' + } + It 'NodeName Parameter is member of ParameterSets' { + [String]$Function.Parameters.NodeName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NodeName Parameter Position is defined correctly' { + [String]$Function.Parameters.NodeName.Attributes.Position | Should be '0' + } + It 'Does NodeName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does NodeName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NodeName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does NodeName Parameter use advanced parameter Validation? ' { + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NodeName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NodeName '{ + $function.Definition.Contains('.PARAMETER NodeName') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called VhdDriveLetter' { + $Function.Parameters.Keys.Contains('VhdDriveLetter') | Should Be 'True' + } + It 'VhdDriveLetter Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.Mandatory | Should be 'True' + } + It 'VhdDriveLetter Parameter is of String Type' { + $Function.Parameters.VhdDriveLetter.ParameterType.FullName | Should be 'System.String' + } + It 'VhdDriveLetter Parameter is member of ParameterSets' { + [String]$Function.Parameters.VhdDriveLetter.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'VhdDriveLetter Parameter Position is defined correctly' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.Position | Should be '2' + } + It 'Does VhdDriveLetter Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does VhdDriveLetter Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.VhdDriveLetter.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does VhdDriveLetter Parameter use advanced parameter Validation? ' { + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.VhdDriveLetter.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for VhdDriveLetter '{ + $function.Definition.Contains('.PARAMETER VhdDriveLetter') | Should Be 'True' + } + It 'Has a Parameter called Credential' { + $Function.Parameters.Keys.Contains('Credential') | Should Be 'True' + } + It 'Credential Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Credential.Attributes.Mandatory | Should be 'True' + } + It 'Credential Parameter is of PSCredential Type' { + $Function.Parameters.Credential.ParameterType.FullName | Should be 'System.Management.Automation.PSCredential' + } + It 'Credential Parameter is member of ParameterSets' { + [String]$Function.Parameters.Credential.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Credential Parameter Position is defined correctly' { + [String]$Function.Parameters.Credential.Attributes.Position | Should be '3' + } + It 'Does Credential Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Credential Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Credential Parameter use advanced parameter Validation? ' { + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Credential '{ + $function.Definition.Contains('.PARAMETER Credential') | Should Be 'True' + } + It 'Has a Parameter called ProductKey' { + $Function.Parameters.Keys.Contains('ProductKey') | Should Be 'True' + } + It 'ProductKey Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ProductKey.Attributes.Mandatory | Should be 'False' + } + It 'ProductKey Parameter is of String Type' { + $Function.Parameters.ProductKey.ParameterType.FullName | Should be 'System.String' + } + It 'ProductKey Parameter is member of ParameterSets' { + [String]$Function.Parameters.ProductKey.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ProductKey Parameter Position is defined correctly' { + [String]$Function.Parameters.ProductKey.Attributes.Position | Should be '4' + } + It 'Does ProductKey Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ProductKey.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ProductKey Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ProductKey.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ProductKey Parameter use advanced parameter Validation? ' { + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ProductKey '{ + $function.Definition.Contains('.PARAMETER ProductKey') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '5' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetLabVMDiskModule.Functional.Tests.ps1 b/Private/Tests/SetLabVMDiskModule.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetLabVMDiskModule.Tests.ps1 b/Private/Tests/SetLabVMDiskModule.Tests.ps1 new file mode 100644 index 00000000..daae432c --- /dev/null +++ b/Private/Tests/SetLabVMDiskModule.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'SetLabVMDiskModule Tests' { + + Context 'Parameters for SetLabVMDiskModule'{ + + It 'Has a Parameter called Module' { + $Function.Parameters.Keys.Contains('Module') | Should Be 'True' + } + It 'Module Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Module.Attributes.Mandatory | Should be 'True' + } + It 'Module Parameter is of Hashtable[] Type' { + $Function.Parameters.Module.ParameterType.FullName | Should be 'System.Collections.Hashtable[]' + } + It 'Module Parameter is member of ParameterSets' { + [String]$Function.Parameters.Module.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Module Parameter Position is defined correctly' { + [String]$Function.Parameters.Module.Attributes.Position | Should be '0' + } + It 'Does Module Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Module.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Module Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Module.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Module Parameter use advanced parameter Validation? ' { + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Module '{ + $function.Definition.Contains('.PARAMETER Module') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '1' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + It 'Has a Parameter called Clean' { + $Function.Parameters.Keys.Contains('Clean') | Should Be 'True' + } + It 'Clean Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Clean.Attributes.Mandatory | Should be 'False' + } + It 'Clean Parameter is of SwitchParameter Type' { + $Function.Parameters.Clean.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Clean Parameter is member of ParameterSets' { + [String]$Function.Parameters.Clean.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Clean Parameter Position is defined correctly' { + [String]$Function.Parameters.Clean.Attributes.Position | Should be '-2147483648' + } + It 'Does Clean Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Clean.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Clean Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Clean.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Clean Parameter use advanced parameter Validation? ' { + $Function.Parameters.Clean.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Clean.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Clean.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Clean.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Clean.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Clean '{ + $function.Definition.Contains('.PARAMETER Clean') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetLabVirtualMachine.Functional.Tests.ps1 b/Private/Tests/SetLabVirtualMachine.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetLabVirtualMachine.Tests.ps1 b/Private/Tests/SetLabVirtualMachine.Tests.ps1 new file mode 100644 index 00000000..83d7ad94 --- /dev/null +++ b/Private/Tests/SetLabVirtualMachine.Tests.ps1 @@ -0,0 +1,376 @@ +Describe 'SetLabVirtualMachine Tests' { + + Context 'Parameters for SetLabVirtualMachine'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called SwitchName' { + $Function.Parameters.Keys.Contains('SwitchName') | Should Be 'True' + } + It 'SwitchName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.SwitchName.Attributes.Mandatory | Should be 'True' + } + It 'SwitchName Parameter is of String[] Type' { + $Function.Parameters.SwitchName.ParameterType.FullName | Should be 'System.String[]' + } + It 'SwitchName Parameter is member of ParameterSets' { + [String]$Function.Parameters.SwitchName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SwitchName Parameter Position is defined correctly' { + [String]$Function.Parameters.SwitchName.Attributes.Position | Should be '1' + } + It 'Does SwitchName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SwitchName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does SwitchName Parameter use advanced parameter Validation? ' { + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SwitchName '{ + $function.Definition.Contains('.PARAMETER SwitchName') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'True' + } + It 'Media Parameter is of String Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.String' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '2' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called StartupMemory' { + $Function.Parameters.Keys.Contains('StartupMemory') | Should Be 'True' + } + It 'StartupMemory Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.StartupMemory.Attributes.Mandatory | Should be 'True' + } + It 'StartupMemory Parameter is of UInt64 Type' { + $Function.Parameters.StartupMemory.ParameterType.FullName | Should be 'System.UInt64' + } + It 'StartupMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.StartupMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'StartupMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.StartupMemory.Attributes.Position | Should be '3' + } + It 'Does StartupMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does StartupMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does StartupMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for StartupMemory '{ + $function.Definition.Contains('.PARAMETER StartupMemory') | Should Be 'True' + } + It 'Has a Parameter called MinimumMemory' { + $Function.Parameters.Keys.Contains('MinimumMemory') | Should Be 'True' + } + It 'MinimumMemory Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MinimumMemory.Attributes.Mandatory | Should be 'True' + } + It 'MinimumMemory Parameter is of UInt64 Type' { + $Function.Parameters.MinimumMemory.ParameterType.FullName | Should be 'System.UInt64' + } + It 'MinimumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MinimumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumMemory.Attributes.Position | Should be '4' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MinimumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumMemory '{ + $function.Definition.Contains('.PARAMETER MinimumMemory') | Should Be 'True' + } + It 'Has a Parameter called MaximumMemory' { + $Function.Parameters.Keys.Contains('MaximumMemory') | Should Be 'True' + } + It 'MaximumMemory Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MaximumMemory.Attributes.Mandatory | Should be 'True' + } + It 'MaximumMemory Parameter is of UInt64 Type' { + $Function.Parameters.MaximumMemory.ParameterType.FullName | Should be 'System.UInt64' + } + It 'MaximumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MaximumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MaximumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MaximumMemory.Attributes.Position | Should be '5' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MaximumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MaximumMemory '{ + $function.Definition.Contains('.PARAMETER MaximumMemory') | Should Be 'True' + } + It 'Has a Parameter called ProcessorCount' { + $Function.Parameters.Keys.Contains('ProcessorCount') | Should Be 'True' + } + It 'ProcessorCount Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ProcessorCount.Attributes.Mandatory | Should be 'True' + } + It 'ProcessorCount Parameter is of Int32 Type' { + $Function.Parameters.ProcessorCount.ParameterType.FullName | Should be 'System.Int32' + } + It 'ProcessorCount Parameter is member of ParameterSets' { + [String]$Function.Parameters.ProcessorCount.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ProcessorCount Parameter Position is defined correctly' { + [String]$Function.Parameters.ProcessorCount.Attributes.Position | Should be '6' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ProcessorCount Parameter use advanced parameter Validation? ' { + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ProcessorCount '{ + $function.Definition.Contains('.PARAMETER ProcessorCount') | Should Be 'True' + } + It 'Has a Parameter called MACAddress' { + $Function.Parameters.Keys.Contains('MACAddress') | Should Be 'True' + } + It 'MACAddress Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MACAddress.Attributes.Mandatory | Should be 'False' + } + It 'MACAddress Parameter is of String[] Type' { + $Function.Parameters.MACAddress.ParameterType.FullName | Should be 'System.String[]' + } + It 'MACAddress Parameter is member of ParameterSets' { + [String]$Function.Parameters.MACAddress.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MACAddress Parameter Position is defined correctly' { + [String]$Function.Parameters.MACAddress.Attributes.Position | Should be '7' + } + It 'Does MACAddress Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MACAddress.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MACAddress Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MACAddress.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MACAddress Parameter use advanced parameter Validation? ' { + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MACAddress '{ + $function.Definition.Contains('.PARAMETER MACAddress') | Should Be 'True' + } + It 'Has a Parameter called SecureBoot' { + $Function.Parameters.Keys.Contains('SecureBoot') | Should Be 'True' + } + It 'SecureBoot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SecureBoot.Attributes.Mandatory | Should be 'False' + } + It 'SecureBoot Parameter is of Boolean Type' { + $Function.Parameters.SecureBoot.ParameterType.FullName | Should be 'System.Boolean' + } + It 'SecureBoot Parameter is member of ParameterSets' { + [String]$Function.Parameters.SecureBoot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SecureBoot Parameter Position is defined correctly' { + [String]$Function.Parameters.SecureBoot.Attributes.Position | Should be '8' + } + It 'Does SecureBoot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SecureBoot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does SecureBoot Parameter use advanced parameter Validation? ' { + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SecureBoot '{ + $function.Definition.Contains('.PARAMETER SecureBoot') | Should Be 'True' + } + It 'Has a Parameter called GuestIntegrationServices' { + $Function.Parameters.Keys.Contains('GuestIntegrationServices') | Should Be 'True' + } + It 'GuestIntegrationServices Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Mandatory | Should be 'False' + } + It 'GuestIntegrationServices Parameter is of Boolean Type' { + $Function.Parameters.GuestIntegrationServices.ParameterType.FullName | Should be 'System.Boolean' + } + It 'GuestIntegrationServices Parameter is member of ParameterSets' { + [String]$Function.Parameters.GuestIntegrationServices.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'GuestIntegrationServices Parameter Position is defined correctly' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Position | Should be '9' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does GuestIntegrationServices Parameter use advanced parameter Validation? ' { + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for GuestIntegrationServices '{ + $function.Definition.Contains('.PARAMETER GuestIntegrationServices') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '10' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetResourceChecksum.Functional.Tests.ps1 b/Private/Tests/SetResourceChecksum.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetResourceChecksum.Tests.ps1 b/Private/Tests/SetResourceChecksum.Tests.ps1 new file mode 100644 index 00000000..caafc5b5 --- /dev/null +++ b/Private/Tests/SetResourceChecksum.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'SetResourceChecksum Tests' { + + Context 'Parameters for SetResourceChecksum'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetResourceDownload.Functional.Tests.ps1 b/Private/Tests/SetResourceDownload.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetResourceDownload.Tests.ps1 b/Private/Tests/SetResourceDownload.Tests.ps1 new file mode 100644 index 00000000..0be51caf --- /dev/null +++ b/Private/Tests/SetResourceDownload.Tests.ps1 @@ -0,0 +1,190 @@ +Describe 'SetResourceDownload Tests' { + + Context 'Parameters for SetResourceDownload'{ + + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '0' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Uri' { + $Function.Parameters.Keys.Contains('Uri') | Should Be 'True' + } + It 'Uri Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Uri.Attributes.Mandatory | Should be 'True' + } + It 'Uri Parameter is of String Type' { + $Function.Parameters.Uri.ParameterType.FullName | Should be 'System.String' + } + It 'Uri Parameter is member of ParameterSets' { + [String]$Function.Parameters.Uri.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Uri Parameter Position is defined correctly' { + [String]$Function.Parameters.Uri.Attributes.Position | Should be '1' + } + It 'Does Uri Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Uri Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Uri Parameter use advanced parameter Validation? ' { + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Uri '{ + $function.Definition.Contains('.PARAMETER Uri') | Should Be 'True' + } + It 'Has a Parameter called Checksum' { + $Function.Parameters.Keys.Contains('Checksum') | Should Be 'True' + } + It 'Checksum Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Checksum.Attributes.Mandatory | Should be 'False' + } + It 'Checksum Parameter is of String Type' { + $Function.Parameters.Checksum.ParameterType.FullName | Should be 'System.String' + } + It 'Checksum Parameter is member of ParameterSets' { + [String]$Function.Parameters.Checksum.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Checksum Parameter Position is defined correctly' { + [String]$Function.Parameters.Checksum.Attributes.Position | Should be '2' + } + It 'Does Checksum Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Checksum Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Checksum Parameter use advanced parameter Validation? ' { + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Checksum '{ + $function.Definition.Contains('.PARAMETER Checksum') | Should Be 'True' + } + It 'Has a Parameter called BufferSize' { + $Function.Parameters.Keys.Contains('BufferSize') | Should Be 'True' + } + It 'BufferSize Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.BufferSize.Attributes.Mandatory | Should be 'False' + } + It 'BufferSize Parameter is of UInt32 Type' { + $Function.Parameters.BufferSize.ParameterType.FullName | Should be 'System.UInt32' + } + It 'BufferSize Parameter is member of ParameterSets' { + [String]$Function.Parameters.BufferSize.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'BufferSize Parameter Position is defined correctly' { + [String]$Function.Parameters.BufferSize.Attributes.Position | Should be '3' + } + It 'Does BufferSize Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.BufferSize.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does BufferSize Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.BufferSize.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does BufferSize Parameter use advanced parameter Validation? ' { + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for BufferSize '{ + $function.Definition.Contains('.PARAMETER BufferSize') | Should Be 'True' + } + It 'Has a Parameter called NoChecksum' { + $Function.Parameters.Keys.Contains('NoChecksum') | Should Be 'True' + } + It 'NoChecksum Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.NoChecksum.Attributes.Mandatory | Should be 'False' + } + It 'NoChecksum Parameter is of SwitchParameter Type' { + $Function.Parameters.NoChecksum.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'NoChecksum Parameter is member of ParameterSets' { + [String]$Function.Parameters.NoChecksum.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NoChecksum Parameter Position is defined correctly' { + [String]$Function.Parameters.NoChecksum.Attributes.Position | Should be '-2147483648' + } + It 'Does NoChecksum Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NoChecksum.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does NoChecksum Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NoChecksum.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does NoChecksum Parameter use advanced parameter Validation? ' { + $Function.Parameters.NoChecksum.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NoChecksum.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NoChecksum.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NoChecksum.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NoChecksum.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NoChecksum '{ + $function.Definition.Contains('.PARAMETER NoChecksum') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetSetupCompleteCmd.Functional.Tests.ps1 b/Private/Tests/SetSetupCompleteCmd.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetSetupCompleteCmd.Tests.ps1 b/Private/Tests/SetSetupCompleteCmd.Tests.ps1 new file mode 100644 index 00000000..282a9511 --- /dev/null +++ b/Private/Tests/SetSetupCompleteCmd.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'SetSetupCompleteCmd Tests' { + + Context 'Parameters for SetSetupCompleteCmd'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called CoreCLR' { + $Function.Parameters.Keys.Contains('CoreCLR') | Should Be 'True' + } + It 'CoreCLR Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CoreCLR.Attributes.Mandatory | Should be 'False' + } + It 'CoreCLR Parameter is of SwitchParameter Type' { + $Function.Parameters.CoreCLR.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'CoreCLR Parameter is member of ParameterSets' { + [String]$Function.Parameters.CoreCLR.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CoreCLR Parameter Position is defined correctly' { + [String]$Function.Parameters.CoreCLR.Attributes.Position | Should be '-2147483648' + } + It 'Does CoreCLR Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CoreCLR.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CoreCLR Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CoreCLR.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CoreCLR Parameter use advanced parameter Validation? ' { + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CoreCLR.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CoreCLR '{ + $function.Definition.Contains('.PARAMETER CoreCLR') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/SetUnattendXml.Functional.Tests.ps1 b/Private/Tests/SetUnattendXml.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/SetUnattendXml.Tests.ps1 b/Private/Tests/SetUnattendXml.Tests.ps1 new file mode 100644 index 00000000..0d039255 --- /dev/null +++ b/Private/Tests/SetUnattendXml.Tests.ps1 @@ -0,0 +1,407 @@ +Describe 'SetUnattendXml Tests' { + + Context 'Parameters for SetUnattendXml'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called Credential' { + $Function.Parameters.Keys.Contains('Credential') | Should Be 'True' + } + It 'Credential Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Credential.Attributes.Mandatory | Should be 'True' + } + It 'Credential Parameter is of PSCredential Type' { + $Function.Parameters.Credential.ParameterType.FullName | Should be 'System.Management.Automation.PSCredential' + } + It 'Credential Parameter is member of ParameterSets' { + [String]$Function.Parameters.Credential.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Credential Parameter Position is defined correctly' { + [String]$Function.Parameters.Credential.Attributes.Position | Should be '1' + } + It 'Does Credential Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Credential Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Credential Parameter use advanced parameter Validation? ' { + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Credential '{ + $function.Definition.Contains('.PARAMETER Credential') | Should Be 'True' + } + It 'Has a Parameter called ComputerName' { + $Function.Parameters.Keys.Contains('ComputerName') | Should Be 'True' + } + It 'ComputerName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ComputerName.Attributes.Mandatory | Should be 'False' + } + It 'ComputerName Parameter is of String Type' { + $Function.Parameters.ComputerName.ParameterType.FullName | Should be 'System.String' + } + It 'ComputerName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ComputerName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ComputerName Parameter Position is defined correctly' { + [String]$Function.Parameters.ComputerName.Attributes.Position | Should be '2' + } + It 'Does ComputerName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ComputerName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ComputerName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ComputerName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ComputerName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ComputerName '{ + $function.Definition.Contains('.PARAMETER ComputerName') | Should Be 'True' + } + It 'Has a Parameter called ProductKey' { + $Function.Parameters.Keys.Contains('ProductKey') | Should Be 'True' + } + It 'ProductKey Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ProductKey.Attributes.Mandatory | Should be 'False' + } + It 'ProductKey Parameter is of String Type' { + $Function.Parameters.ProductKey.ParameterType.FullName | Should be 'System.String' + } + It 'ProductKey Parameter is member of ParameterSets' { + [String]$Function.Parameters.ProductKey.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ProductKey Parameter Position is defined correctly' { + [String]$Function.Parameters.ProductKey.Attributes.Position | Should be '3' + } + It 'Does ProductKey Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ProductKey.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ProductKey Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ProductKey.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ProductKey Parameter use advanced parameter Validation? ' { + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ProductKey.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for ProductKey '{ + $function.Definition.Contains('.PARAMETER ProductKey') | Should Be 'True' + } + It 'Has a Parameter called InputLocale' { + $Function.Parameters.Keys.Contains('InputLocale') | Should Be 'True' + } + It 'InputLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.InputLocale.Attributes.Mandatory | Should be 'False' + } + It 'InputLocale Parameter is of String Type' { + $Function.Parameters.InputLocale.ParameterType.FullName | Should be 'System.String' + } + It 'InputLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.InputLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'InputLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.InputLocale.Attributes.Position | Should be '4' + } + It 'Does InputLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.InputLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does InputLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.InputLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does InputLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for InputLocale '{ + $function.Definition.Contains('.PARAMETER InputLocale') | Should Be 'True' + } + It 'Has a Parameter called SystemLocale' { + $Function.Parameters.Keys.Contains('SystemLocale') | Should Be 'True' + } + It 'SystemLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SystemLocale.Attributes.Mandatory | Should be 'False' + } + It 'SystemLocale Parameter is of String Type' { + $Function.Parameters.SystemLocale.ParameterType.FullName | Should be 'System.String' + } + It 'SystemLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.SystemLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SystemLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.SystemLocale.Attributes.Position | Should be '5' + } + It 'Does SystemLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SystemLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SystemLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SystemLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SystemLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SystemLocale '{ + $function.Definition.Contains('.PARAMETER SystemLocale') | Should Be 'True' + } + It 'Has a Parameter called UserLocale' { + $Function.Parameters.Keys.Contains('UserLocale') | Should Be 'True' + } + It 'UserLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.UserLocale.Attributes.Mandatory | Should be 'False' + } + It 'UserLocale Parameter is of String Type' { + $Function.Parameters.UserLocale.ParameterType.FullName | Should be 'System.String' + } + It 'UserLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.UserLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'UserLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.UserLocale.Attributes.Position | Should be '6' + } + It 'Does UserLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.UserLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does UserLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.UserLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does UserLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for UserLocale '{ + $function.Definition.Contains('.PARAMETER UserLocale') | Should Be 'True' + } + It 'Has a Parameter called UILanguage' { + $Function.Parameters.Keys.Contains('UILanguage') | Should Be 'True' + } + It 'UILanguage Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.UILanguage.Attributes.Mandatory | Should be 'False' + } + It 'UILanguage Parameter is of String Type' { + $Function.Parameters.UILanguage.ParameterType.FullName | Should be 'System.String' + } + It 'UILanguage Parameter is member of ParameterSets' { + [String]$Function.Parameters.UILanguage.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'UILanguage Parameter Position is defined correctly' { + [String]$Function.Parameters.UILanguage.Attributes.Position | Should be '7' + } + It 'Does UILanguage Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.UILanguage.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does UILanguage Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.UILanguage.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does UILanguage Parameter use advanced parameter Validation? ' { + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for UILanguage '{ + $function.Definition.Contains('.PARAMETER UILanguage') | Should Be 'True' + } + It 'Has a Parameter called Timezone' { + $Function.Parameters.Keys.Contains('Timezone') | Should Be 'True' + } + It 'Timezone Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Timezone.Attributes.Mandatory | Should be 'True' + } + It 'Timezone Parameter is of String Type' { + $Function.Parameters.Timezone.ParameterType.FullName | Should be 'System.String' + } + It 'Timezone Parameter is member of ParameterSets' { + [String]$Function.Parameters.Timezone.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Timezone Parameter Position is defined correctly' { + [String]$Function.Parameters.Timezone.Attributes.Position | Should be '8' + } + It 'Does Timezone Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Timezone.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Timezone Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Timezone.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Timezone Parameter use advanced parameter Validation? ' { + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Timezone '{ + $function.Definition.Contains('.PARAMETER Timezone') | Should Be 'True' + } + It 'Has a Parameter called RegisteredOwner' { + $Function.Parameters.Keys.Contains('RegisteredOwner') | Should Be 'True' + } + It 'RegisteredOwner Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RegisteredOwner.Attributes.Mandatory | Should be 'False' + } + It 'RegisteredOwner Parameter is of String Type' { + $Function.Parameters.RegisteredOwner.ParameterType.FullName | Should be 'System.String' + } + It 'RegisteredOwner Parameter is member of ParameterSets' { + [String]$Function.Parameters.RegisteredOwner.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RegisteredOwner Parameter Position is defined correctly' { + [String]$Function.Parameters.RegisteredOwner.Attributes.Position | Should be '9' + } + It 'Does RegisteredOwner Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RegisteredOwner.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RegisteredOwner Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RegisteredOwner.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RegisteredOwner Parameter use advanced parameter Validation? ' { + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RegisteredOwner '{ + $function.Definition.Contains('.PARAMETER RegisteredOwner') | Should Be 'True' + } + It 'Has a Parameter called RegisteredOrganization' { + $Function.Parameters.Keys.Contains('RegisteredOrganization') | Should Be 'True' + } + It 'RegisteredOrganization Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.Mandatory | Should be 'False' + } + It 'RegisteredOrganization Parameter is of String Type' { + $Function.Parameters.RegisteredOrganization.ParameterType.FullName | Should be 'System.String' + } + It 'RegisteredOrganization Parameter is member of ParameterSets' { + [String]$Function.Parameters.RegisteredOrganization.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RegisteredOrganization Parameter Position is defined correctly' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.Position | Should be '10' + } + It 'Does RegisteredOrganization Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RegisteredOrganization Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RegisteredOrganization Parameter use advanced parameter Validation? ' { + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RegisteredOrganization '{ + $function.Definition.Contains('.PARAMETER RegisteredOrganization') | Should Be 'True' + } + It 'Has a Parameter called ExecuteCommand' { + $Function.Parameters.Keys.Contains('ExecuteCommand') | Should Be 'True' + } + It 'ExecuteCommand Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ExecuteCommand.Attributes.Mandatory | Should be 'False' + } + It 'ExecuteCommand Parameter is of Hashtable[] Type' { + $Function.Parameters.ExecuteCommand.ParameterType.FullName | Should be 'System.Collections.Hashtable[]' + } + It 'ExecuteCommand Parameter is member of ParameterSets' { + [String]$Function.Parameters.ExecuteCommand.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ExecuteCommand Parameter Position is defined correctly' { + [String]$Function.Parameters.ExecuteCommand.Attributes.Position | Should be '11' + } + It 'Does ExecuteCommand Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ExecuteCommand.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ExecuteCommand Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ExecuteCommand.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ExecuteCommand Parameter use advanced parameter Validation? ' { + $Function.Parameters.ExecuteCommand.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ExecuteCommand.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ExecuteCommand.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ExecuteCommand.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ExecuteCommand.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ExecuteCommand '{ + $function.Definition.Contains('.PARAMETER ExecuteCommand') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestComputerName.Functional.Tests.ps1 b/Private/Tests/TestComputerName.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestComputerName.Tests.ps1 b/Private/Tests/TestComputerName.Tests.ps1 new file mode 100644 index 00000000..ab470403 --- /dev/null +++ b/Private/Tests/TestComputerName.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'TestComputerName Tests' { + + Context 'Parameters for TestComputerName'{ + + It 'Has a Parameter called ComputerName' { + $Function.Parameters.Keys.Contains('ComputerName') | Should Be 'True' + } + It 'ComputerName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ComputerName.Attributes.Mandatory | Should be 'True' + } + It 'ComputerName Parameter is of String Type' { + $Function.Parameters.ComputerName.ParameterType.FullName | Should be 'System.String' + } + It 'ComputerName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ComputerName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ComputerName Parameter Position is defined correctly' { + [String]$Function.Parameters.ComputerName.Attributes.Position | Should be '0' + } + It 'Does ComputerName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ComputerName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ComputerName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ComputerName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ComputerName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ComputerName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ComputerName '{ + $function.Definition.Contains('.PARAMETER ComputerName') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestDscModule.Functional.Tests.ps1 b/Private/Tests/TestDscModule.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestDscModule.Tests.ps1 b/Private/Tests/TestDscModule.Tests.ps1 new file mode 100644 index 00000000..94e6d413 --- /dev/null +++ b/Private/Tests/TestDscModule.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'TestDscModule Tests' { + + Context 'Parameters for TestDscModule'{ + + It 'Has a Parameter called ModuleName' { + $Function.Parameters.Keys.Contains('ModuleName') | Should Be 'True' + } + It 'ModuleName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ModuleName.Attributes.Mandatory | Should be 'True' + } + It 'ModuleName Parameter is of String Type' { + $Function.Parameters.ModuleName.ParameterType.FullName | Should be 'System.String' + } + It 'ModuleName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ModuleName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ModuleName Parameter Position is defined correctly' { + [String]$Function.Parameters.ModuleName.Attributes.Position | Should be '0' + } + It 'Does ModuleName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ModuleName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ModuleName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ModuleName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ModuleName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ModuleName '{ + $function.Definition.Contains('.PARAMETER ModuleName') | Should Be 'True' + } + It 'Has a Parameter called ResourceName' { + $Function.Parameters.Keys.Contains('ResourceName') | Should Be 'True' + } + It 'ResourceName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ResourceName.Attributes.Mandatory | Should be 'False' + } + It 'ResourceName Parameter is of String Type' { + $Function.Parameters.ResourceName.ParameterType.FullName | Should be 'System.String' + } + It 'ResourceName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourceName Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceName.Attributes.Position | Should be '1' + } + It 'Does ResourceName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourceName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ResourceName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceName '{ + $function.Definition.Contains('.PARAMETER ResourceName') | Should Be 'True' + } + It 'Has a Parameter called MinimumVersion' { + $Function.Parameters.Keys.Contains('MinimumVersion') | Should Be 'True' + } + It 'MinimumVersion Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MinimumVersion.Attributes.Mandatory | Should be 'False' + } + It 'MinimumVersion Parameter is of String Type' { + $Function.Parameters.MinimumVersion.ParameterType.FullName | Should be 'System.String' + } + It 'MinimumVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumVersion.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MinimumVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumVersion.Attributes.Position | Should be '2' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MinimumVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumVersion '{ + $function.Definition.Contains('.PARAMETER MinimumVersion') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestDscResource.Functional.Tests.ps1 b/Private/Tests/TestDscResource.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestDscResource.Tests.ps1 b/Private/Tests/TestDscResource.Tests.ps1 new file mode 100644 index 00000000..0ef13ad7 --- /dev/null +++ b/Private/Tests/TestDscResource.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'TestDscResource Tests' { + + Context 'Parameters for TestDscResource'{ + + It 'Has a Parameter called ResourceName' { + $Function.Parameters.Keys.Contains('ResourceName') | Should Be 'True' + } + It 'ResourceName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ResourceName.Attributes.Mandatory | Should be 'True' + } + It 'ResourceName Parameter is of String Type' { + $Function.Parameters.ResourceName.ParameterType.FullName | Should be 'System.String' + } + It 'ResourceName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourceName Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceName.Attributes.Position | Should be '0' + } + It 'Does ResourceName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ResourceName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ResourceName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceName '{ + $function.Definition.Contains('.PARAMETER ResourceName') | Should Be 'True' + } + It 'Has a Parameter called Parameters' { + $Function.Parameters.Keys.Contains('Parameters') | Should Be 'True' + } + It 'Parameters Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Parameters.Attributes.Mandatory | Should be 'True' + } + It 'Parameters Parameter is of Hashtable Type' { + $Function.Parameters.Parameters.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'Parameters Parameter is member of ParameterSets' { + [String]$Function.Parameters.Parameters.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Parameters Parameter Position is defined correctly' { + [String]$Function.Parameters.Parameters.Attributes.Position | Should be '1' + } + It 'Does Parameters Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Parameters.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Parameters Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Parameters.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Parameters Parameter use advanced parameter Validation? ' { + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Parameters.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Parameters '{ + $function.Definition.Contains('.PARAMETER Parameters') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestDscResourceModule.Functional.Tests.ps1 b/Private/Tests/TestDscResourceModule.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestDscResourceModule.Tests.ps1 b/Private/Tests/TestDscResourceModule.Tests.ps1 new file mode 100644 index 00000000..6d628e3f --- /dev/null +++ b/Private/Tests/TestDscResourceModule.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'TestDscResourceModule Tests' { + + Context 'Parameters for TestDscResourceModule'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '0' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called ModuleName' { + $Function.Parameters.Keys.Contains('ModuleName') | Should Be 'True' + } + It 'ModuleName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ModuleName.Attributes.Mandatory | Should be 'True' + } + It 'ModuleName Parameter is of String Type' { + $Function.Parameters.ModuleName.ParameterType.FullName | Should be 'System.String' + } + It 'ModuleName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ModuleName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ModuleName Parameter Position is defined correctly' { + [String]$Function.Parameters.ModuleName.Attributes.Position | Should be '1' + } + It 'Does ModuleName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ModuleName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ModuleName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ModuleName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ModuleName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ModuleName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ModuleName '{ + $function.Definition.Contains('.PARAMETER ModuleName') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestLabConfigurationMof.Functional.Tests.ps1 b/Private/Tests/TestLabConfigurationMof.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestLabConfigurationMof.Tests.ps1 b/Private/Tests/TestLabConfigurationMof.Tests.ps1 new file mode 100644 index 00000000..18a66e15 --- /dev/null +++ b/Private/Tests/TestLabConfigurationMof.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'TestLabConfigurationMof Tests' { + + Context 'Parameters for TestLabConfigurationMof'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'False' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '1' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'False' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '2' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called SkipMofCheck' { + $Function.Parameters.Keys.Contains('SkipMofCheck') | Should Be 'True' + } + It 'SkipMofCheck Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SkipMofCheck.Attributes.Mandatory | Should be 'False' + } + It 'SkipMofCheck Parameter is of SwitchParameter Type' { + $Function.Parameters.SkipMofCheck.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'SkipMofCheck Parameter is member of ParameterSets' { + [String]$Function.Parameters.SkipMofCheck.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SkipMofCheck Parameter Position is defined correctly' { + [String]$Function.Parameters.SkipMofCheck.Attributes.Position | Should be '-2147483648' + } + It 'Does SkipMofCheck Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SkipMofCheck.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SkipMofCheck Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SkipMofCheck.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SkipMofCheck Parameter use advanced parameter Validation? ' { + $Function.Parameters.SkipMofCheck.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SkipMofCheck.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SkipMofCheck.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SkipMofCheck.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SkipMofCheck.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SkipMofCheck '{ + $function.Definition.Contains('.PARAMETER SkipMofCheck') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestLabResourceIsLocal.Functional.Tests.ps1 b/Private/Tests/TestLabResourceIsLocal.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestLabResourceIsLocal.Tests.ps1 b/Private/Tests/TestLabResourceIsLocal.Tests.ps1 new file mode 100644 index 00000000..a034fb54 --- /dev/null +++ b/Private/Tests/TestLabResourceIsLocal.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'TestLabResourceIsLocal Tests' { + + Context 'Parameters for TestLabResourceIsLocal'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called ResourceId' { + $Function.Parameters.Keys.Contains('ResourceId') | Should Be 'True' + } + It 'ResourceId Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ResourceId.Attributes.Mandatory | Should be 'True' + } + It 'ResourceId Parameter is of String Type' { + $Function.Parameters.ResourceId.ParameterType.FullName | Should be 'System.String' + } + It 'ResourceId Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceId.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourceId Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceId.Attributes.Position | Should be '1' + } + It 'Does ResourceId Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceId.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourceId Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceId.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ResourceId Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceId '{ + $function.Definition.Contains('.PARAMETER ResourceId') | Should Be 'True' + } + It 'Has a Parameter called LocalResourcePath' { + $Function.Parameters.Keys.Contains('LocalResourcePath') | Should Be 'True' + } + It 'LocalResourcePath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.LocalResourcePath.Attributes.Mandatory | Should be 'True' + } + It 'LocalResourcePath Parameter is of String Type' { + $Function.Parameters.LocalResourcePath.ParameterType.FullName | Should be 'System.String' + } + It 'LocalResourcePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.LocalResourcePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'LocalResourcePath Parameter Position is defined correctly' { + [String]$Function.Parameters.LocalResourcePath.Attributes.Position | Should be '2' + } + It 'Does LocalResourcePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.LocalResourcePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does LocalResourcePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.LocalResourcePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does LocalResourcePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.LocalResourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.LocalResourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.LocalResourcePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.LocalResourcePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.LocalResourcePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for LocalResourcePath '{ + $function.Definition.Contains('.PARAMETER LocalResourcePath') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestLabSwitch.Functional.Tests.ps1 b/Private/Tests/TestLabSwitch.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestLabSwitch.Tests.ps1 b/Private/Tests/TestLabSwitch.Tests.ps1 new file mode 100644 index 00000000..b2a38fc7 --- /dev/null +++ b/Private/Tests/TestLabSwitch.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'TestLabSwitch Tests' { + + Context 'Parameters for TestLabSwitch'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestLabVMDisk.Functional.Tests.ps1 b/Private/Tests/TestLabVMDisk.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestLabVMDisk.Tests.ps1 b/Private/Tests/TestLabVMDisk.Tests.ps1 new file mode 100644 index 00000000..05f01ed4 --- /dev/null +++ b/Private/Tests/TestLabVMDisk.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'TestLabVMDisk Tests' { + + Context 'Parameters for TestLabVMDisk'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'True' + } + It 'Media Parameter is of String Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.String' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '1' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '2' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestLabVirtualMachine.Functional.Tests.ps1 b/Private/Tests/TestLabVirtualMachine.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestLabVirtualMachine.Tests.ps1 b/Private/Tests/TestLabVirtualMachine.Tests.ps1 new file mode 100644 index 00000000..e8588981 --- /dev/null +++ b/Private/Tests/TestLabVirtualMachine.Tests.ps1 @@ -0,0 +1,376 @@ +Describe 'TestLabVirtualMachine Tests' { + + Context 'Parameters for TestLabVirtualMachine'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called SwitchName' { + $Function.Parameters.Keys.Contains('SwitchName') | Should Be 'True' + } + It 'SwitchName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.SwitchName.Attributes.Mandatory | Should be 'True' + } + It 'SwitchName Parameter is of String[] Type' { + $Function.Parameters.SwitchName.ParameterType.FullName | Should be 'System.String[]' + } + It 'SwitchName Parameter is member of ParameterSets' { + [String]$Function.Parameters.SwitchName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SwitchName Parameter Position is defined correctly' { + [String]$Function.Parameters.SwitchName.Attributes.Position | Should be '1' + } + It 'Does SwitchName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SwitchName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does SwitchName Parameter use advanced parameter Validation? ' { + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SwitchName '{ + $function.Definition.Contains('.PARAMETER SwitchName') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'True' + } + It 'Media Parameter is of String Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.String' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '2' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called StartupMemory' { + $Function.Parameters.Keys.Contains('StartupMemory') | Should Be 'True' + } + It 'StartupMemory Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.StartupMemory.Attributes.Mandatory | Should be 'True' + } + It 'StartupMemory Parameter is of UInt64 Type' { + $Function.Parameters.StartupMemory.ParameterType.FullName | Should be 'System.UInt64' + } + It 'StartupMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.StartupMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'StartupMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.StartupMemory.Attributes.Position | Should be '3' + } + It 'Does StartupMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does StartupMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does StartupMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for StartupMemory '{ + $function.Definition.Contains('.PARAMETER StartupMemory') | Should Be 'True' + } + It 'Has a Parameter called MinimumMemory' { + $Function.Parameters.Keys.Contains('MinimumMemory') | Should Be 'True' + } + It 'MinimumMemory Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MinimumMemory.Attributes.Mandatory | Should be 'True' + } + It 'MinimumMemory Parameter is of UInt64 Type' { + $Function.Parameters.MinimumMemory.ParameterType.FullName | Should be 'System.UInt64' + } + It 'MinimumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MinimumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumMemory.Attributes.Position | Should be '4' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MinimumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumMemory '{ + $function.Definition.Contains('.PARAMETER MinimumMemory') | Should Be 'True' + } + It 'Has a Parameter called MaximumMemory' { + $Function.Parameters.Keys.Contains('MaximumMemory') | Should Be 'True' + } + It 'MaximumMemory Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MaximumMemory.Attributes.Mandatory | Should be 'True' + } + It 'MaximumMemory Parameter is of UInt64 Type' { + $Function.Parameters.MaximumMemory.ParameterType.FullName | Should be 'System.UInt64' + } + It 'MaximumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MaximumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MaximumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MaximumMemory.Attributes.Position | Should be '5' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MaximumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MaximumMemory '{ + $function.Definition.Contains('.PARAMETER MaximumMemory') | Should Be 'True' + } + It 'Has a Parameter called ProcessorCount' { + $Function.Parameters.Keys.Contains('ProcessorCount') | Should Be 'True' + } + It 'ProcessorCount Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ProcessorCount.Attributes.Mandatory | Should be 'True' + } + It 'ProcessorCount Parameter is of Int32 Type' { + $Function.Parameters.ProcessorCount.ParameterType.FullName | Should be 'System.Int32' + } + It 'ProcessorCount Parameter is member of ParameterSets' { + [String]$Function.Parameters.ProcessorCount.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ProcessorCount Parameter Position is defined correctly' { + [String]$Function.Parameters.ProcessorCount.Attributes.Position | Should be '6' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ProcessorCount Parameter use advanced parameter Validation? ' { + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ProcessorCount '{ + $function.Definition.Contains('.PARAMETER ProcessorCount') | Should Be 'True' + } + It 'Has a Parameter called MACAddress' { + $Function.Parameters.Keys.Contains('MACAddress') | Should Be 'True' + } + It 'MACAddress Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MACAddress.Attributes.Mandatory | Should be 'False' + } + It 'MACAddress Parameter is of String[] Type' { + $Function.Parameters.MACAddress.ParameterType.FullName | Should be 'System.String[]' + } + It 'MACAddress Parameter is member of ParameterSets' { + [String]$Function.Parameters.MACAddress.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MACAddress Parameter Position is defined correctly' { + [String]$Function.Parameters.MACAddress.Attributes.Position | Should be '7' + } + It 'Does MACAddress Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MACAddress.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MACAddress Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MACAddress.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MACAddress Parameter use advanced parameter Validation? ' { + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MACAddress '{ + $function.Definition.Contains('.PARAMETER MACAddress') | Should Be 'True' + } + It 'Has a Parameter called SecureBoot' { + $Function.Parameters.Keys.Contains('SecureBoot') | Should Be 'True' + } + It 'SecureBoot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SecureBoot.Attributes.Mandatory | Should be 'False' + } + It 'SecureBoot Parameter is of Boolean Type' { + $Function.Parameters.SecureBoot.ParameterType.FullName | Should be 'System.Boolean' + } + It 'SecureBoot Parameter is member of ParameterSets' { + [String]$Function.Parameters.SecureBoot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SecureBoot Parameter Position is defined correctly' { + [String]$Function.Parameters.SecureBoot.Attributes.Position | Should be '8' + } + It 'Does SecureBoot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SecureBoot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does SecureBoot Parameter use advanced parameter Validation? ' { + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SecureBoot '{ + $function.Definition.Contains('.PARAMETER SecureBoot') | Should Be 'True' + } + It 'Has a Parameter called GuestIntegrationServices' { + $Function.Parameters.Keys.Contains('GuestIntegrationServices') | Should Be 'True' + } + It 'GuestIntegrationServices Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Mandatory | Should be 'False' + } + It 'GuestIntegrationServices Parameter is of Boolean Type' { + $Function.Parameters.GuestIntegrationServices.ParameterType.FullName | Should be 'System.Boolean' + } + It 'GuestIntegrationServices Parameter is member of ParameterSets' { + [String]$Function.Parameters.GuestIntegrationServices.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'GuestIntegrationServices Parameter Position is defined correctly' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Position | Should be '9' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does GuestIntegrationServices Parameter use advanced parameter Validation? ' { + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for GuestIntegrationServices '{ + $function.Definition.Contains('.PARAMETER GuestIntegrationServices') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '10' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestModule.Functional.Tests.ps1 b/Private/Tests/TestModule.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestModule.Tests.ps1 b/Private/Tests/TestModule.Tests.ps1 new file mode 100644 index 00000000..fa0ed328 --- /dev/null +++ b/Private/Tests/TestModule.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'TestModule Tests' { + + Context 'Parameters for TestModule'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '-2147483648' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called MinimumVersion' { + $Function.Parameters.Keys.Contains('MinimumVersion') | Should Be 'True' + } + It 'MinimumVersion Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MinimumVersion.Attributes.Mandatory | Should be 'True' + } + It 'MinimumVersion Parameter is of Version Type' { + $Function.Parameters.MinimumVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'MinimumVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumVersion.ParameterSets.Keys | Should Be 'MinimumVersion' + } + It 'MinimumVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumVersion.Attributes.Position | Should be '-2147483648' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MinimumVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumVersion '{ + $function.Definition.Contains('.PARAMETER MinimumVersion') | Should Be 'True' + } + It 'Has a Parameter called RequiredVersion' { + $Function.Parameters.Keys.Contains('RequiredVersion') | Should Be 'True' + } + It 'RequiredVersion Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.RequiredVersion.Attributes.Mandatory | Should be 'True' + } + It 'RequiredVersion Parameter is of Version Type' { + $Function.Parameters.RequiredVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'RequiredVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.RequiredVersion.ParameterSets.Keys | Should Be 'RequiredVersion' + } + It 'RequiredVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.RequiredVersion.Attributes.Position | Should be '-2147483648' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RequiredVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RequiredVersion '{ + $function.Definition.Contains('.PARAMETER RequiredVersion') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '-2147483648' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestModuleCache.Functional.Tests.ps1 b/Private/Tests/TestModuleCache.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestModuleCache.Tests.ps1 b/Private/Tests/TestModuleCache.Tests.ps1 new file mode 100644 index 00000000..a36e741d --- /dev/null +++ b/Private/Tests/TestModuleCache.Tests.ps1 @@ -0,0 +1,314 @@ +Describe 'TestModuleCache Tests' { + + Context 'Parameters for TestModuleCache'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True True True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True True True' + } + It 'Name Parameter is of String Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called MinimumVersion' { + $Function.Parameters.Keys.Contains('MinimumVersion') | Should Be 'True' + } + It 'MinimumVersion Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MinimumVersion.Attributes.Mandatory | Should be 'True' + } + It 'MinimumVersion Parameter is of Version Type' { + $Function.Parameters.MinimumVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'MinimumVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumVersion.ParameterSets.Keys | Should Be 'NameMinimum' + } + It 'MinimumVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumVersion.Attributes.Position | Should be '-2147483648' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MinimumVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumVersion '{ + $function.Definition.Contains('.PARAMETER MinimumVersion') | Should Be 'True' + } + It 'Has a Parameter called RequiredVersion' { + $Function.Parameters.Keys.Contains('RequiredVersion') | Should Be 'True' + } + It 'RequiredVersion Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.RequiredVersion.Attributes.Mandatory | Should be 'True' + } + It 'RequiredVersion Parameter is of Version Type' { + $Function.Parameters.RequiredVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'RequiredVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.RequiredVersion.ParameterSets.Keys | Should Be 'NameRequired' + } + It 'RequiredVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.RequiredVersion.Attributes.Position | Should be '-2147483648' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RequiredVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RequiredVersion '{ + $function.Definition.Contains('.PARAMETER RequiredVersion') | Should Be 'True' + } + It 'Has a Parameter called Owner' { + $Function.Parameters.Keys.Contains('Owner') | Should Be 'True' + } + It 'Owner Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Owner.Attributes.Mandatory | Should be 'False False False' + } + It 'Owner Parameter is of String Type' { + $Function.Parameters.Owner.ParameterType.FullName | Should be 'System.String' + } + It 'Owner Parameter is member of ParameterSets' { + [String]$Function.Parameters.Owner.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Owner Parameter Position is defined correctly' { + [String]$Function.Parameters.Owner.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Owner Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Owner.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Owner Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Owner.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Owner Parameter use advanced parameter Validation? ' { + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Owner.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Owner '{ + $function.Definition.Contains('.PARAMETER Owner') | Should Be 'True' + } + It 'Has a Parameter called Branch' { + $Function.Parameters.Keys.Contains('Branch') | Should Be 'True' + } + It 'Branch Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Branch.Attributes.Mandatory | Should be 'False False False' + } + It 'Branch Parameter is of String Type' { + $Function.Parameters.Branch.ParameterType.FullName | Should be 'System.String' + } + It 'Branch Parameter is member of ParameterSets' { + [String]$Function.Parameters.Branch.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Branch Parameter Position is defined correctly' { + [String]$Function.Parameters.Branch.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Branch Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Branch.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Branch Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Branch.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Branch Parameter use advanced parameter Validation? ' { + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Branch.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Branch '{ + $function.Definition.Contains('.PARAMETER Branch') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'False False False' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called Provider' { + $Function.Parameters.Keys.Contains('Provider') | Should Be 'True' + } + It 'Provider Parameter is Identified as Mandatory being False False False' { + [String]$Function.Parameters.Provider.Attributes.Mandatory | Should be 'False False False' + } + It 'Provider Parameter is of String Type' { + $Function.Parameters.Provider.ParameterType.FullName | Should be 'System.String' + } + It 'Provider Parameter is member of ParameterSets' { + [String]$Function.Parameters.Provider.ParameterSets.Keys | Should Be 'NameRequired NameMinimum Name' + } + It 'Provider Parameter Position is defined correctly' { + [String]$Function.Parameters.Provider.Attributes.Position | Should be '-2147483648 -2147483648 -2147483648' + } + It 'Does Provider Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Provider.Attributes.ValueFromPipeline | Should be 'True True True' + } + It 'Does Provider Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Provider.Attributes.ValueFromPipelineByPropertyName | Should be 'True True True' + } + It 'Does Provider Parameter use advanced parameter Validation? ' { + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Provider.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Provider '{ + $function.Definition.Contains('.PARAMETER Provider') | Should Be 'True' + } + It 'Has a Parameter called Module' { + $Function.Parameters.Keys.Contains('Module') | Should Be 'True' + } + It 'Module Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Module.Attributes.Mandatory | Should be 'True' + } + It 'Module Parameter is of Hashtable Type' { + $Function.Parameters.Module.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'Module Parameter is member of ParameterSets' { + [String]$Function.Parameters.Module.ParameterSets.Keys | Should Be 'Module' + } + It 'Module Parameter Position is defined correctly' { + [String]$Function.Parameters.Module.Attributes.Position | Should be '-2147483648' + } + It 'Does Module Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Module.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Module Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Module.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Module Parameter use advanced parameter Validation? ' { + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Module.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Module '{ + $function.Definition.Contains('.PARAMETER Module') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '-2147483648' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestModuleVersion.Functional.Tests.ps1 b/Private/Tests/TestModuleVersion.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestModuleVersion.Tests.ps1 b/Private/Tests/TestModuleVersion.Tests.ps1 new file mode 100644 index 00000000..821d7615 --- /dev/null +++ b/Private/Tests/TestModuleVersion.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'TestModuleVersion Tests' { + + Context 'Parameters for TestModuleVersion'{ + + It 'Has a Parameter called ModulePath' { + $Function.Parameters.Keys.Contains('ModulePath') | Should Be 'True' + } + It 'ModulePath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ModulePath.Attributes.Mandatory | Should be 'True' + } + It 'ModulePath Parameter is of String Type' { + $Function.Parameters.ModulePath.ParameterType.FullName | Should be 'System.String' + } + It 'ModulePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ModulePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ModulePath Parameter Position is defined correctly' { + [String]$Function.Parameters.ModulePath.Attributes.Position | Should be '-2147483648' + } + It 'Does ModulePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ModulePath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ModulePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ModulePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ModulePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ModulePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ModulePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ModulePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ModulePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ModulePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ModulePath '{ + $function.Definition.Contains('.PARAMETER ModulePath') | Should Be 'True' + } + It 'Has a Parameter called MinimumVersion' { + $Function.Parameters.Keys.Contains('MinimumVersion') | Should Be 'True' + } + It 'MinimumVersion Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MinimumVersion.Attributes.Mandatory | Should be 'True' + } + It 'MinimumVersion Parameter is of Version Type' { + $Function.Parameters.MinimumVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'MinimumVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumVersion.ParameterSets.Keys | Should Be 'MinimumVersion' + } + It 'MinimumVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumVersion.Attributes.Position | Should be '-2147483648' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MinimumVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MinimumVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumVersion '{ + $function.Definition.Contains('.PARAMETER MinimumVersion') | Should Be 'True' + } + It 'Has a Parameter called RequiredVersion' { + $Function.Parameters.Keys.Contains('RequiredVersion') | Should Be 'True' + } + It 'RequiredVersion Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.RequiredVersion.Attributes.Mandatory | Should be 'True' + } + It 'RequiredVersion Parameter is of Version Type' { + $Function.Parameters.RequiredVersion.ParameterType.FullName | Should be 'System.Version' + } + It 'RequiredVersion Parameter is member of ParameterSets' { + [String]$Function.Parameters.RequiredVersion.ParameterSets.Keys | Should Be 'RequiredVersion' + } + It 'RequiredVersion Parameter Position is defined correctly' { + [String]$Function.Parameters.RequiredVersion.Attributes.Position | Should be '-2147483648' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RequiredVersion Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RequiredVersion.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RequiredVersion Parameter use advanced parameter Validation? ' { + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RequiredVersion.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RequiredVersion '{ + $function.Definition.Contains('.PARAMETER RequiredVersion') | Should Be 'True' + } + It 'Has a Parameter called RemainingArguments' { + $Function.Parameters.Keys.Contains('RemainingArguments') | Should Be 'True' + } + It 'RemainingArguments Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemainingArguments.Attributes.Mandatory | Should be 'False' + } + It 'RemainingArguments Parameter is of Object Type' { + $Function.Parameters.RemainingArguments.ParameterType.FullName | Should be 'System.Object' + } + It 'RemainingArguments Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemainingArguments.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemainingArguments Parameter Position is defined correctly' { + [String]$Function.Parameters.RemainingArguments.Attributes.Position | Should be '-2147483648' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemainingArguments Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemainingArguments.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does RemainingArguments Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemainingArguments.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemainingArguments '{ + $function.Definition.Contains('.PARAMETER RemainingArguments') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/TestResourceDownload.Functional.Tests.ps1 b/Private/Tests/TestResourceDownload.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/TestResourceDownload.Tests.ps1 b/Private/Tests/TestResourceDownload.Tests.ps1 new file mode 100644 index 00000000..8b97db47 --- /dev/null +++ b/Private/Tests/TestResourceDownload.Tests.ps1 @@ -0,0 +1,159 @@ +Describe 'TestResourceDownload Tests' { + + Context 'Parameters for TestResourceDownload'{ + + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'True' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '0' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Uri' { + $Function.Parameters.Keys.Contains('Uri') | Should Be 'True' + } + It 'Uri Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Uri.Attributes.Mandatory | Should be 'True' + } + It 'Uri Parameter is of String Type' { + $Function.Parameters.Uri.ParameterType.FullName | Should be 'System.String' + } + It 'Uri Parameter is member of ParameterSets' { + [String]$Function.Parameters.Uri.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Uri Parameter Position is defined correctly' { + [String]$Function.Parameters.Uri.Attributes.Position | Should be '1' + } + It 'Does Uri Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Uri Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Uri Parameter use advanced parameter Validation? ' { + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Uri '{ + $function.Definition.Contains('.PARAMETER Uri') | Should Be 'True' + } + It 'Has a Parameter called Checksum' { + $Function.Parameters.Keys.Contains('Checksum') | Should Be 'True' + } + It 'Checksum Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Checksum.Attributes.Mandatory | Should be 'False' + } + It 'Checksum Parameter is of String Type' { + $Function.Parameters.Checksum.ParameterType.FullName | Should be 'System.String' + } + It 'Checksum Parameter is member of ParameterSets' { + [String]$Function.Parameters.Checksum.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Checksum Parameter Position is defined correctly' { + [String]$Function.Parameters.Checksum.Attributes.Position | Should be '2' + } + It 'Does Checksum Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Checksum Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Checksum Parameter use advanced parameter Validation? ' { + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Checksum '{ + $function.Definition.Contains('.PARAMETER Checksum') | Should Be 'True' + } + It 'Has a Parameter called BufferSize' { + $Function.Parameters.Keys.Contains('BufferSize') | Should Be 'True' + } + It 'BufferSize Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.BufferSize.Attributes.Mandatory | Should be 'False' + } + It 'BufferSize Parameter is of UInt32 Type' { + $Function.Parameters.BufferSize.ParameterType.FullName | Should be 'System.UInt32' + } + It 'BufferSize Parameter is member of ParameterSets' { + [String]$Function.Parameters.BufferSize.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'BufferSize Parameter Position is defined correctly' { + [String]$Function.Parameters.BufferSize.Attributes.Position | Should be '3' + } + It 'Does BufferSize Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.BufferSize.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does BufferSize Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.BufferSize.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does BufferSize Parameter use advanced parameter Validation? ' { + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.BufferSize.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for BufferSize '{ + $function.Definition.Contains('.PARAMETER BufferSize') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/ValidateTimeZone.Functional.Tests.ps1 b/Private/Tests/ValidateTimeZone.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/ValidateTimeZone.Tests.ps1 b/Private/Tests/ValidateTimeZone.Tests.ps1 new file mode 100644 index 00000000..d4636184 --- /dev/null +++ b/Private/Tests/ValidateTimeZone.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'ValidateTimeZone Tests' { + + Context 'Parameters for ValidateTimeZone'{ + + It 'Has a Parameter called TimeZone' { + $Function.Parameters.Keys.Contains('TimeZone') | Should Be 'True' + } + It 'TimeZone Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.TimeZone.Attributes.Mandatory | Should be 'True' + } + It 'TimeZone Parameter is of String Type' { + $Function.Parameters.TimeZone.ParameterType.FullName | Should be 'System.String' + } + It 'TimeZone Parameter is member of ParameterSets' { + [String]$Function.Parameters.TimeZone.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'TimeZone Parameter Position is defined correctly' { + [String]$Function.Parameters.TimeZone.Attributes.Position | Should be '0' + } + It 'Does TimeZone Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.TimeZone.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does TimeZone Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.TimeZone.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does TimeZone Parameter use advanced parameter Validation? ' { + $Function.Parameters.TimeZone.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.TimeZone.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.TimeZone.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.TimeZone.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.TimeZone.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for TimeZone '{ + $function.Definition.Contains('.PARAMETER TimeZone') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/WriteVerbose.Functional.Tests.ps1 b/Private/Tests/WriteVerbose.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/WriteVerbose.Tests.ps1 b/Private/Tests/WriteVerbose.Tests.ps1 new file mode 100644 index 00000000..1b4b0017 --- /dev/null +++ b/Private/Tests/WriteVerbose.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'WriteVerbose Tests' { + + Context 'Parameters for WriteVerbose'{ + + It 'Has a Parameter called Message' { + $Function.Parameters.Keys.Contains('Message') | Should Be 'True' + } + It 'Message Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Message.Attributes.Mandatory | Should be 'False' + } + It 'Message Parameter is of String Type' { + $Function.Parameters.Message.ParameterType.FullName | Should be 'System.String' + } + It 'Message Parameter is member of ParameterSets' { + [String]$Function.Parameters.Message.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Message Parameter Position is defined correctly' { + [String]$Function.Parameters.Message.Attributes.Position | Should be '0' + } + It 'Does Message Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Message.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Message Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Message.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Message Parameter use advanced parameter Validation? ' { + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Message '{ + $function.Definition.Contains('.PARAMETER Message') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/Tests/WriteWarning.Functional.Tests.ps1 b/Private/Tests/WriteWarning.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Private/Tests/WriteWarning.Tests.ps1 b/Private/Tests/WriteWarning.Tests.ps1 new file mode 100644 index 00000000..0dac2fba --- /dev/null +++ b/Private/Tests/WriteWarning.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'WriteWarning Tests' { + + Context 'Parameters for WriteWarning'{ + + It 'Has a Parameter called Message' { + $Function.Parameters.Keys.Contains('Message') | Should Be 'True' + } + It 'Message Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Message.Attributes.Mandatory | Should be 'False' + } + It 'Message Parameter is of String Type' { + $Function.Parameters.Message.ParameterType.FullName | Should be 'System.String' + } + It 'Message Parameter is member of ParameterSets' { + [String]$Function.Parameters.Message.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Message Parameter Position is defined correctly' { + [String]$Function.Parameters.Message.Attributes.Position | Should be '0' + } + It 'Does Message Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Message.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Message Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Message.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Message Parameter use advanced parameter Validation? ' { + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Message.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Message '{ + $function.Definition.Contains('.PARAMETER Message') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Private/ValidateTimeZone.ps1 b/Private/ValidateTimeZone.ps1 new file mode 100644 index 00000000..bf27c520 --- /dev/null +++ b/Private/ValidateTimeZone.ps1 @@ -0,0 +1,24 @@ +function ValidateTimeZone { + +<# + .SYNOPSIS + Validates a timezone string. +#> + [CmdletBinding()] + [OutputType([System.String])] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [System.String] $TimeZone + ) + process { + try { + $TZ = [TimeZoneInfo]::FindSystemTimeZoneById($TimeZone) + return $TZ.StandardName; + } + catch [System.TimeZoneNotFoundException] { + throw $_; + } + } #end process + +} + diff --git a/Private/WriteVerbose.ps1 b/Private/WriteVerbose.ps1 new file mode 100644 index 00000000..198bec3c --- /dev/null +++ b/Private/WriteVerbose.ps1 @@ -0,0 +1,23 @@ +function WriteVerbose { + +<# + .SYNOPSIS + Wrapper around Write-Verbose that adds a timestamp and/or call stack information to the output. +#> + [CmdletBinding()] + param ( + [Parameter(ValueFromPipeline)] + [AllowNull()] + [System.String] $Message + ) + process { + + if (-not [System.String]::IsNullOrEmpty($Message)) { + $verboseMessage = GetFormattedMessage -Message $Message; + Write-Verbose -Message $verboseMessage; + } + + } + +} + diff --git a/Private/WriteWarning.ps1 b/Private/WriteWarning.ps1 new file mode 100644 index 00000000..642806ee --- /dev/null +++ b/Private/WriteWarning.ps1 @@ -0,0 +1,23 @@ +function WriteWarning { + +<# + .SYNOPSIS + Wrapper around Write-Warning that adds a timestamp and/or call stack information to the output. +#> + [CmdletBinding()] + param ( + [Parameter(ValueFromPipeline)] + [AllowNull()] + [System.String] $Message + ) + process { + + if (-not [System.String]::IsNullOrEmpty($Message)) { + $warningMessage = GetFormattedMessage -Message $Message; + Write-Warning -Message $warningMessage; + } + + } + +} + diff --git a/Public/Checkpoint/Checkpoint-Lab.ps1 b/Public/Checkpoint/Checkpoint-Lab.ps1 new file mode 100644 index 00000000..3ecd6c98 --- /dev/null +++ b/Public/Checkpoint/Checkpoint-Lab.ps1 @@ -0,0 +1,61 @@ +function Checkpoint-Lab { + +<# + .SYNOPSIS + Snapshots all lab VMs in their current configuration. + .DESCRIPTION + The Checkpoint-Lab creates a VM checkpoint of all the nodes defined in a PowerShell DSC configuration document. + When creating the snapshots, they will be created using the snapshot name specified. + + All virtual machines should be powered off when the snapshot is taken to ensure that the machine is in a + consistent state. If VMs are powered on, an error will be generated. You can override this behaviour by + specifying the -Force parameter. + + WARNING: If the -Force parameter is used, the virtual machine snapshot(s) may be in an inconsistent state. + .PARAMETER ConfigurationData + Specifies a PowerShell DSC configuration data hashtable or a path to an existing PowerShell DSC .psd1 + configuration document. + .PARAMETER SnapshotName + Specifies the virtual machine snapshot name that applied to each VM in the PowerShell DSC configuration + document. This name is used to restore a lab configuration. It can contain spaces, but is not recommended. + .PARAMETER Force + Forces virtual machine snapshots to be taken - even if there are any running virtual machines. + .LINK + Restore-Lab + Reset-Lab +#> + [CmdletBinding()] + param ( + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Snapshot name + [Parameter(Mandatory)] [Alias('Name')] + [System.String] $SnapshotName, + + ## Force snapshots if virtual machines are on + [System.Management.Automation.SwitchParameter] $Force + ) + process { + $nodes = $ConfigurationData.AllNodes | Where-Object { $_.NodeName -ne '*' } | ForEach-Object { + ResolveLabVMProperties -NodeName $_.NodeName -ConfigurationData $ConfigurationData; + }; + $runningNodes = Get-VM -Name $nodes.NodeDisplayName | Where-Object { $_.State -ne 'Off' } + if ($runningNodes -and $Force) { + NewLabVMSnapshot -Name $nodes.NodeDisplayName -SnapshotName $SnapshotName; + } + elseif ($runningNodes) { + foreach ($runningNode in $runningNodes) { + Write-Error -Message ($localized.CannotSnapshotNodeError -f $runningNode.Name); + } + } + else { + NewLabVMSnapshot -Name $nodes.NodeDisplayName -SnapshotName $SnapshotName; + } + } #end process + +} + diff --git a/Public/Checkpoint/Tests/Checkpoint-Lab.Functional.Tests.ps1 b/Public/Checkpoint/Tests/Checkpoint-Lab.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Checkpoint/Tests/Checkpoint-Lab.Tests.ps1 b/Public/Checkpoint/Tests/Checkpoint-Lab.Tests.ps1 new file mode 100644 index 00000000..a361fb9e --- /dev/null +++ b/Public/Checkpoint/Tests/Checkpoint-Lab.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'Checkpoint-Lab Tests' { + + Context 'Parameters for Checkpoint-Lab'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called SnapshotName' { + $Function.Parameters.Keys.Contains('SnapshotName') | Should Be 'True' + } + It 'SnapshotName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.SnapshotName.Attributes.Mandatory | Should be 'True' + } + It 'SnapshotName Parameter is of String Type' { + $Function.Parameters.SnapshotName.ParameterType.FullName | Should be 'System.String' + } + It 'SnapshotName Parameter is member of ParameterSets' { + [String]$Function.Parameters.SnapshotName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SnapshotName Parameter Position is defined correctly' { + [String]$Function.Parameters.SnapshotName.Attributes.Position | Should be '1' + } + It 'Does SnapshotName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SnapshotName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SnapshotName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SnapshotName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does SnapshotName Parameter use advanced parameter Validation? ' { + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SnapshotName '{ + $function.Definition.Contains('.PARAMETER SnapshotName') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Export/Export-LabHostConfiguration.ps1 b/Public/Export/Export-LabHostConfiguration.ps1 new file mode 100644 index 00000000..0b74a399 --- /dev/null +++ b/Public/Export/Export-LabHostConfiguration.ps1 @@ -0,0 +1,77 @@ +function Export-LabHostConfiguration { + +<# + .SYNOPSIS + Backs up the current lab host configuration. + .LINK + Import-LabHostConfiguration +#> + [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName='Path')] + [OutputType([System.IO.FileInfo])] + param ( + # Specifies the export path location. + [Parameter(Mandatory, ParameterSetName = 'Path', ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] [Alias("PSPath")] + [System.String] $Path, + + # Specifies a literal export location path. + [Parameter(Mandatory, ParameterSetName = 'LiteralPath', ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $LiteralPath, + + ## Do not overwrite an existing file + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $NoClobber + ) + process { + $now = [System.DateTime]::UtcNow; + $configuration = [PSCustomObject] @{ + Author = $env:USERNAME; + GenerationHost = $env:COMPUTERNAME; + GenerationDate = '{0} {1}' -f $now.ToShortDateString(), $now.ToString('hh:mm:ss'); + ModuleVersion = (Get-Module -Name $labDefaults.ModuleName).Version.ToString(); + HostDefaults = [PSCustomObject] (GetConfigurationData -Configuration Host); + VMDefaults = [PSCustomObject] (GetConfigurationData -Configuration VM); + CustomMedia = @([PSCustomObject] (GetConfigurationData -Configuration CustomMedia)); + } + + if ($PSCmdlet.ParameterSetName -eq 'Path') { + # Resolve any relative paths + $Path = $PSCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path); + } + else { + $Path = $PSCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath($LiteralPath); + } + + if ($NoClobber -and (Test-Path -Path $Path -PathType Leaf -ErrorAction SilentlyContinue)) { + $errorMessage = $localized.FileAlreadyExistsError -f $Path; + $ex = New-Object -TypeName System.InvalidOperationException -ArgumentList $errorMessage; + $errorCategory = [System.Management.Automation.ErrorCategory]::ResourceExists; + $errorRecord = New-Object System.Management.Automation.ErrorRecord $ex, 'FileExists', $errorCategory, $Path; + $PSCmdlet.WriteError($errorRecord); + } + else { + $verboseMessage = GetFormattedMessage -Message ($localized.ExportingConfiguration -f $labDefaults.ModuleName, $Path); + $operationMessage = $localized.ShouldProcessOperation -f 'Export', $Path; + $setContentParams = @{ + Path = $Path; + Value = ConvertTo-Json -InputObject $configuration -Depth 5; + Force = $true; + Confirm = $false; + } + if ($PSCmdlet.ShouldProcess($verboseMessage, $operationMessage, $localized.ShouldProcessActionConfirmation)) { + try { + ## Set-Content won't actually throw a terminating error?! + Set-Content @setContentParams -ErrorAction Stop; + Write-Output -InputObject (Get-Item -Path $Path); + } + catch { + throw $_; + } + } + } + + } #end process + +} + diff --git a/Public/Export/Tests/Export-LabHostConfiguration.Functional.Tests.ps1 b/Public/Export/Tests/Export-LabHostConfiguration.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Export/Tests/Export-LabHostConfiguration.Tests.ps1 b/Public/Export/Tests/Export-LabHostConfiguration.Tests.ps1 new file mode 100644 index 00000000..b003a78a --- /dev/null +++ b/Public/Export/Tests/Export-LabHostConfiguration.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'Export-LabHostConfiguration Tests' { + + Context 'Parameters for Export-LabHostConfiguration'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be 'Path' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '-2147483648' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called LiteralPath' { + $Function.Parameters.Keys.Contains('LiteralPath') | Should Be 'True' + } + It 'LiteralPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.LiteralPath.Attributes.Mandatory | Should be 'True' + } + It 'LiteralPath Parameter is of String Type' { + $Function.Parameters.LiteralPath.ParameterType.FullName | Should be 'System.String' + } + It 'LiteralPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.LiteralPath.ParameterSets.Keys | Should Be 'LiteralPath' + } + It 'LiteralPath Parameter Position is defined correctly' { + [String]$Function.Parameters.LiteralPath.Attributes.Position | Should be '-2147483648' + } + It 'Does LiteralPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.LiteralPath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does LiteralPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.LiteralPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does LiteralPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.LiteralPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.LiteralPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.LiteralPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.LiteralPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.LiteralPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for LiteralPath '{ + $function.Definition.Contains('.PARAMETER LiteralPath') | Should Be 'True' + } + It 'Has a Parameter called NoClobber' { + $Function.Parameters.Keys.Contains('NoClobber') | Should Be 'True' + } + It 'NoClobber Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.NoClobber.Attributes.Mandatory | Should be 'False' + } + It 'NoClobber Parameter is of SwitchParameter Type' { + $Function.Parameters.NoClobber.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'NoClobber Parameter is member of ParameterSets' { + [String]$Function.Parameters.NoClobber.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NoClobber Parameter Position is defined correctly' { + [String]$Function.Parameters.NoClobber.Attributes.Position | Should be '-2147483648' + } + It 'Does NoClobber Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NoClobber.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does NoClobber Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NoClobber.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does NoClobber Parameter use advanced parameter Validation? ' { + $Function.Parameters.NoClobber.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NoClobber.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NoClobber.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NoClobber.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NoClobber.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NoClobber '{ + $function.Definition.Contains('.PARAMETER NoClobber') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Get/Get-LabHostConfiguration.ps1 b/Public/Get/Get-LabHostConfiguration.ps1 new file mode 100644 index 00000000..691a38b4 --- /dev/null +++ b/Public/Get/Get-LabHostConfiguration.ps1 @@ -0,0 +1,30 @@ +function Get-LabHostConfiguration { + +<# + .SYNOPSIS + Retrieves the current lab host's configuration default values. + .LINK + Test-LabHostConfiguration + Start-LabHostConfiguration +#> + [CmdletBinding()] + [OutputType([System.Management.Automation.PSObject])] + param ( ) + process { + $labHostSetupConfiguation = GetLabHostSetupConfiguration; + foreach ($configuration in $labHostSetupConfiguation) { + $importDscResourceParams = @{ + ModuleName = $configuration.ModuleName; + ResourceName = $configuration.ResourceName; + Prefix = $configuration.Prefix; + UseDefault = $configuration.UseDefault; + } + ImportDscResource @importDscResourceParams; + $resource = GetDscResource -ResourceName $configuration.Prefix -Parameters $configuration.Parameters; + $resource['Resource'] = $configuration.ResourceName; + Write-Output -InputObject ([PSCustomObject] $resource); + } + } #end process + +} + diff --git a/Public/Get/Get-LabHostDefault.ps1 b/Public/Get/Get-LabHostDefault.ps1 new file mode 100644 index 00000000..d3054f26 --- /dev/null +++ b/Public/Get/Get-LabHostDefault.ps1 @@ -0,0 +1,22 @@ +function Get-LabHostDefault { + +<# + .SYNOPSIS + Gets the lab host's default settings. + .DESCRIPTION + The Get-LabHostDefault cmdlet returns the lab host's current settings. + .LINK + Set-LabHostDefault + Reset-LabHostDefault +#> + [CmdletBinding()] + [OutputType([System.Management.Automation.PSCustomObject])] + param ( ) + process { + + GetConfigurationData -Configuration Host; + + } #end process + +} + diff --git a/Public/Get/Get-LabHostDefaults.ps1 b/Public/Get/Get-LabHostDefaults.ps1 new file mode 100644 index 00000000..7f8d3226 --- /dev/null +++ b/Public/Get/Get-LabHostDefaults.ps1 @@ -0,0 +1,27 @@ +function Get-LabHostDefaults { + +<# + .SYNOPSIS + Gets the lab host's default settings. + .DESCRIPTION + The Get-LabHostDefault cmdlet returns the lab host's current settings. + .NOTES + Proxy function replacing alias to enable warning output. + .LINK + Set-LabHostDefault + Reset-LabHostDefault +#> + [CmdletBinding()] + [OutputType([System.Management.Automation.PSCustomObject])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')] + param ( ) + process { + + Write-Warning -Message ($localized.DeprecatedCommandWarning -f 'Get-LabHostDefaults','Get-LabHostDefault'); + Get-LabHostDefault @PSBoundParameters; + + + } #end process + +} + diff --git a/Public/Get/Get-LabImage.ps1 b/Public/Get/Get-LabImage.ps1 new file mode 100644 index 00000000..116f7457 --- /dev/null +++ b/Public/Get/Get-LabImage.ps1 @@ -0,0 +1,90 @@ +function Get-LabImage { + +<# + .SYNOPSIS + Gets master/parent disk image. + .DESCRIPTION + The Get-LabImage cmdlet returns current master/parent disk image properties. + .PARAMETER Id + Specifies the media Id of the image to return. If this parameter is not specified, all images are returned. + .PARAMETER ConfigurationData + Specifies a PowerShell DSC configuration data hashtable or a path to an existing PowerShell DSC .psd1 + configuration document that contains the required media definition. + .EXAMPLE + Get-LabImage + + Returns all current lab images on the host. + .EXAMPLE + Get-LabImage -Id 2012R2_x64_Standard_EN_Eval + + Returns the '2012R2_x64_Standard_EN_Eval' lab image properties, if available. +#> + [CmdletBinding()] + [OutputType([System.Management.Automation.PSCustomObject])] + param ( + [Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Id, + + ## Lab DSC configuration data + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + + $hostDefaults = GetConfigurationData -Configuration Host; + $parentVhdPath = ResolvePathEx -Path $hostDefaults.ParentVhdPath; + + if ($PSBoundParameters.ContainsKey('Id')) { + + ## We have an Id. so resolve that + try { + + $labMedia = ResolveLabMedia @PSBoundParameters; + } + catch { + + $labMedia = $null; + } + } + else { + ## Otherwise return all media + $labMedia = Get-LabMedia; + } + + foreach ($media in $labMedia) { + + $differencingVhdPath = '{0}.vhdx' -f $media.Id; + if ($media.MediaType -eq 'VHD') { + + $differencingVhdPath = $media.Filename; + } + + $imagePath = Join-Path -Path $parentVhdPath -ChildPath $differencingVhdPath; + if (Test-Path -Path $imagePath -PathType Leaf) { + + $imageFileInfo = Get-Item -Path $imagePath; + $diskImage = Get-DiskImage -ImagePath $imageFileInfo.FullName; + $labImage = [PSCustomObject] @{ + Id = $media.Id; + Attached = $diskImage.Attached; + ImagePath = $diskImage.ImagePath; + LogicalSectorSize = $diskImage.LogicalSectorSize; + BlockSize = $diskImage.BlockSize; + FileSize = $diskImage.FileSize; + Size = $diskImage.Size; + Generation = ($imagePath.Split('.')[-1]).ToUpper(); + } + + $labImage.PSObject.TypeNames.Insert(0, 'VirtualEngine.Lability.Image'); + Write-Output -InputObject $labImage; + } + + } #end foreach media + + } #end process + +} + diff --git a/Public/Get/Get-LabMedia.ps1 b/Public/Get/Get-LabMedia.ps1 new file mode 100644 index 00000000..36687d8c --- /dev/null +++ b/Public/Get/Get-LabMedia.ps1 @@ -0,0 +1,80 @@ +function Get-LabMedia { + +<# + .SYNOPSIS + Gets registered lab media. + .DESCRIPTION + The Get-LabMedia cmdlet retrieves all built-in and registered custom media. + .PARAMETER Id + Specifies the specific media Id to return. + .PARAMETER CustomOnly + Specifies that only registered custom media are returned. +#> + [CmdletBinding()] + [OutputType([System.Management.Automation.PSCustomObject])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')] + param ( + ## Media ID + [Parameter(ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $Id, + + ## Only return custom media + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $CustomOnly + ) + process { + + ## Retrieve built-in media + if (-not $CustomOnly) { + + $defaultMedia = GetConfigurationData -Configuration Media; + } + ## Retrieve custom media + $customMedia = @(GetConfigurationData -Configuration CustomMedia); + if (-not $customMedia) { + + $customMedia = @(); + } + + ## Are we looking for a specific media Id + if ($Id) { + + ## Return the custom media definition first (if it exists) + $media = $customMedia | Where-Object { $_.Id -eq $Id }; + if ((-not $media) -and (-not $CustomOnly)) { + + ## We didn't find a custom media entry, return a default entry (if it exists) + $media = $defaultMedia | Where-Object { $_.Id -eq $Id }; + } + } + else { + + ## Return all custom media + $media = $customMedia; + if (-not $CustomOnly) { + + foreach ($mediaEntry in $defaultMedia) { + + ## Determine whether the media is present in the custom media, i.e. make sure + ## we don't override a custom entry with the default one. + $defaultMediaEntry = $customMedia | Where-Object { $_.Id -eq $mediaEntry.Id } + ## If not, add it to the media array to return + if (-not $defaultMediaEntry) { + + $media += $mediaEntry; + } + } #end foreach default media + } #end if not custom only + } + + foreach ($mediaObject in $media) { + + $mediaObject.PSObject.TypeNames.Insert(0, 'VirtualEngine.Lability.Media'); + Write-Output -InputObject $mediaObject; + } + + } #end process + +} + diff --git a/Public/Get/Get-LabVM.ps1 b/Public/Get/Get-LabVM.ps1 new file mode 100644 index 00000000..7629e45e --- /dev/null +++ b/Public/Get/Get-LabVM.ps1 @@ -0,0 +1,55 @@ +function Get-LabVM { + +<# + .SYNOPSIS + Retrieves the current configuration of a VM. + .DESCRIPTION + Gets a virtual machine's configuration using the xVMHyperV DSC resource. +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + ## Specifies the lab virtual machine/node name. + [Parameter(ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String[]] $Name, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + + if (-not $Name) { + + # Return all nodes defined in the configuration + $Name = $ConfigurationData.AllNodes | Where-Object NodeName -ne '*' | ForEach-Object { $_.NodeName; } + } + + foreach ($nodeName in $Name) { + + $node = ResolveLabVMProperties -NodeName $nodeName -ConfigurationData $ConfigurationData; + $xVMParams = @{ + Name = $node.NodeDisplayName; + VhdPath = ResolveLabVMDiskPath -Name $node.NodeDisplayName;; + } + + try { + + ImportDscResource -ModuleName xHyper-V -ResourceName MSFT_xVMHyperV -Prefix VM; + $vm = GetDscResource -ResourceName VM -Parameters $xVMParams; + Write-Output -InputObject ([PSCustomObject] $vm); + } + catch { + + Write-Error -Message ($localized.CannotLocateNodeError -f $nodeName); + } + + } #end foreach node + + } #end process + +} + diff --git a/Public/Get/Get-LabVMDefault.ps1 b/Public/Get/Get-LabVMDefault.ps1 new file mode 100644 index 00000000..f5ab0669 --- /dev/null +++ b/Public/Get/Get-LabVMDefault.ps1 @@ -0,0 +1,21 @@ +function Get-LabVMDefault { + +<# + .SYNOPSIS + Gets the current lab virtual machine default settings. +#> + [CmdletBinding()] + [OutputType([System.Management.Automation.PSCustomObject])] + param ( ) + process { + + $vmDefaults = GetConfigurationData -Configuration VM; + + ## BootOrder property should not be exposed via the Get-LabVMDefault/Set-LabVMDefault + $vmDefaults.PSObject.Properties.Remove('BootOrder'); + return $vmDefaults; + + } + +} + diff --git a/Public/Get/Get-LabVMDefaults.ps1 b/Public/Get/Get-LabVMDefaults.ps1 new file mode 100644 index 00000000..223e4976 --- /dev/null +++ b/Public/Get/Get-LabVMDefaults.ps1 @@ -0,0 +1,21 @@ +function Get-LabVMDefaults { + +<# + .SYNOPSIS + Gets the current lab virtual machine default settings. + .NOTES + Proxy function replacing alias to enable warning output. +#> + [CmdletBinding()] + [OutputType([System.Management.Automation.PSCustomObject])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')] + param ( ) + process { + + Write-Warning -Message ($localized.DeprecatedCommandWarning -f 'Get-LabVMDefaults','Get-LabVMDefault'); + Get-LabVMDefault @PSBoundParameters; + + } + +} + diff --git a/Public/Get/Tests/Get-LabHostConfiguration.Functional.Tests.ps1 b/Public/Get/Tests/Get-LabHostConfiguration.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Get/Tests/Get-LabHostConfiguration.Tests.ps1 b/Public/Get/Tests/Get-LabHostConfiguration.Tests.ps1 new file mode 100644 index 00000000..ba37abc9 --- /dev/null +++ b/Public/Get/Tests/Get-LabHostConfiguration.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'Get-LabHostConfiguration Tests' { + + Context 'Parameters for Get-LabHostConfiguration'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Get/Tests/Get-LabHostDefault.Functional.Tests.ps1 b/Public/Get/Tests/Get-LabHostDefault.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Get/Tests/Get-LabHostDefault.Tests.ps1 b/Public/Get/Tests/Get-LabHostDefault.Tests.ps1 new file mode 100644 index 00000000..9bba41b4 --- /dev/null +++ b/Public/Get/Tests/Get-LabHostDefault.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'Get-LabHostDefault Tests' { + + Context 'Parameters for Get-LabHostDefault'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Get/Tests/Get-LabHostDefaults.Functional.Tests.ps1 b/Public/Get/Tests/Get-LabHostDefaults.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Get/Tests/Get-LabHostDefaults.Tests.ps1 b/Public/Get/Tests/Get-LabHostDefaults.Tests.ps1 new file mode 100644 index 00000000..7dc30c75 --- /dev/null +++ b/Public/Get/Tests/Get-LabHostDefaults.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'Get-LabHostDefaults Tests' { + + Context 'Parameters for Get-LabHostDefaults'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Get/Tests/Get-LabImage.Functional.Tests.ps1 b/Public/Get/Tests/Get-LabImage.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Get/Tests/Get-LabImage.Tests.ps1 b/Public/Get/Tests/Get-LabImage.Tests.ps1 new file mode 100644 index 00000000..16c2ef66 --- /dev/null +++ b/Public/Get/Tests/Get-LabImage.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'Get-LabImage Tests' { + + Context 'Parameters for Get-LabImage'{ + + It 'Has a Parameter called Id' { + $Function.Parameters.Keys.Contains('Id') | Should Be 'True' + } + It 'Id Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Id.Attributes.Mandatory | Should be 'False' + } + It 'Id Parameter is of String Type' { + $Function.Parameters.Id.ParameterType.FullName | Should be 'System.String' + } + It 'Id Parameter is member of ParameterSets' { + [String]$Function.Parameters.Id.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Id Parameter Position is defined correctly' { + [String]$Function.Parameters.Id.Attributes.Position | Should be '0' + } + It 'Does Id Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Id Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Id Parameter use advanced parameter Validation? ' { + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Id '{ + $function.Definition.Contains('.PARAMETER Id') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Get/Tests/Get-LabMedia.Functional.Tests.ps1 b/Public/Get/Tests/Get-LabMedia.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Get/Tests/Get-LabMedia.Tests.ps1 b/Public/Get/Tests/Get-LabMedia.Tests.ps1 new file mode 100644 index 00000000..5e67987c --- /dev/null +++ b/Public/Get/Tests/Get-LabMedia.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'Get-LabMedia Tests' { + + Context 'Parameters for Get-LabMedia'{ + + It 'Has a Parameter called Id' { + $Function.Parameters.Keys.Contains('Id') | Should Be 'True' + } + It 'Id Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Id.Attributes.Mandatory | Should be 'False' + } + It 'Id Parameter is of String Type' { + $Function.Parameters.Id.ParameterType.FullName | Should be 'System.String' + } + It 'Id Parameter is member of ParameterSets' { + [String]$Function.Parameters.Id.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Id Parameter Position is defined correctly' { + [String]$Function.Parameters.Id.Attributes.Position | Should be '0' + } + It 'Does Id Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Id Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Id Parameter use advanced parameter Validation? ' { + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Id '{ + $function.Definition.Contains('.PARAMETER Id') | Should Be 'True' + } + It 'Has a Parameter called CustomOnly' { + $Function.Parameters.Keys.Contains('CustomOnly') | Should Be 'True' + } + It 'CustomOnly Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CustomOnly.Attributes.Mandatory | Should be 'False' + } + It 'CustomOnly Parameter is of SwitchParameter Type' { + $Function.Parameters.CustomOnly.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'CustomOnly Parameter is member of ParameterSets' { + [String]$Function.Parameters.CustomOnly.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CustomOnly Parameter Position is defined correctly' { + [String]$Function.Parameters.CustomOnly.Attributes.Position | Should be '-2147483648' + } + It 'Does CustomOnly Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CustomOnly.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CustomOnly Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CustomOnly.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CustomOnly Parameter use advanced parameter Validation? ' { + $Function.Parameters.CustomOnly.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.CustomOnly.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.CustomOnly.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CustomOnly.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CustomOnly.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CustomOnly '{ + $function.Definition.Contains('.PARAMETER CustomOnly') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Get/Tests/Get-LabVM.Functional.Tests.ps1 b/Public/Get/Tests/Get-LabVM.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Get/Tests/Get-LabVM.Tests.ps1 b/Public/Get/Tests/Get-LabVM.Tests.ps1 new file mode 100644 index 00000000..a927f2e0 --- /dev/null +++ b/Public/Get/Tests/Get-LabVM.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'Get-LabVM Tests' { + + Context 'Parameters for Get-LabVM'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'False' + } + It 'Name Parameter is of String[] Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String[]' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Get/Tests/Get-LabVMDefault.Functional.Tests.ps1 b/Public/Get/Tests/Get-LabVMDefault.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Get/Tests/Get-LabVMDefault.Tests.ps1 b/Public/Get/Tests/Get-LabVMDefault.Tests.ps1 new file mode 100644 index 00000000..1b5b399f --- /dev/null +++ b/Public/Get/Tests/Get-LabVMDefault.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'Get-LabVMDefault Tests' { + + Context 'Parameters for Get-LabVMDefault'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Get/Tests/Get-LabVMDefaults.Functional.Tests.ps1 b/Public/Get/Tests/Get-LabVMDefaults.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Get/Tests/Get-LabVMDefaults.Tests.ps1 b/Public/Get/Tests/Get-LabVMDefaults.Tests.ps1 new file mode 100644 index 00000000..7bf3d989 --- /dev/null +++ b/Public/Get/Tests/Get-LabVMDefaults.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'Get-LabVMDefaults Tests' { + + Context 'Parameters for Get-LabVMDefaults'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Import/Import-LabHostConfiguration.ps1 b/Public/Import/Import-LabHostConfiguration.ps1 new file mode 100644 index 00000000..0d7edcea --- /dev/null +++ b/Public/Import/Import-LabHostConfiguration.ps1 @@ -0,0 +1,118 @@ +function Import-LabHostConfiguration { + +<# + .SYNOPSIS + Restores the lab host configuration from a backup. + .LINK + Export-LabHostConfiguration +#> + [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName='Path')] + [OutputType([System.Management.Automation.PSCustomObject])] + param ( + # Specifies the export path location. + [Parameter(Mandatory, ParameterSetName = 'Path', ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] [Alias("PSPath")] + [System.String] $Path, + + # Specifies a literal export location path. + [Parameter(Mandatory, ParameterSetName = 'LiteralPath', ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $LiteralPath, + + ## Restores only the lab host default settings + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Host, + + ## Restores only the lab VM default settings + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $VM, + + ## Restores only the lab custom media default settings + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Media + ) + process { + if ($PSCmdlet.ParameterSetName -eq 'Path') { + # Resolve any relative paths + $Path = $PSCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path); + } + else { + $Path = $PSCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath($LiteralPath); + } + + if (-not (Test-Path -Path $Path -PathType Leaf -ErrorAction SilentlyContinue)) { + $errorMessage = $localized.InvalidPathError -f 'Import', $Path; + $ex = New-Object -TypeName System.InvalidOperationException -ArgumentList $errorMessage; + $errorCategory = [System.Management.Automation.ErrorCategory]::ResourceUnavailable; + $errorRecord = New-Object System.Management.Automation.ErrorRecord $ex, 'FileNotFound', $errorCategory, $Path; + $PSCmdlet.WriteError($errorRecord); + return; + } + + WriteVerbose -Message ($localized.ImportingConfiguration -f $labDefaults.ModuleName, $Path); + $configurationDocument = Get-Content -Path $Path -Raw -ErrorAction Stop; + try { + $configuration = ConvertFrom-Json -InputObject $configurationDocument -ErrorAction Stop; + } + catch { + $errorMessage = $localized.InvalidConfigurationError -f $Path; + throw $errorMessage; + } + + if ((-not $PSBoundParameters.ContainsKey('Host')) -and + (-not $PSBoundParameters.ContainsKey('VM')) -and + (-not $PSBoundParameters.ContainsKey('Media'))) { + + ## Nothing specified to load 'em all! + $VM = $true; + $Host = $true; + $Media = $true; + } + + WriteVerbose -Message ($localized.ImportingConfigurationSettings -f $configuration.GenerationDate, $configuration.GenerationHost); + + if ($Host) { + $verboseMessage = GetFormattedMessage -Message ($localized.RestoringConfigurationSettings -f 'Host'); + $operationMessage = $localized.ShouldProcessOperation -f 'Import', 'Host'; + if ($PSCmdlet.ShouldProcess($verboseMessage, $operationMessage, $localized.ShouldProcessActionConfirmation)) { + [ref] $null = Reset-LabHostDefault -Confirm:$false; + $hostDefaultObject = $configuration.HostDefaults; + $hostDefaults = ConvertPSObjectToHashtable -InputObject $hostDefaultObject; + Set-LabHostDefault @hostDefaults -Confirm:$false; + WriteVerbose -Message ($localized.ConfigurationRestoreComplete -f 'Host'); + } + } #end if restore host defaults + + if ($Media) { + ## Restore media before VM defaults as VM defaults may reference custom media! + $verboseMessage = GetFormattedMessage -Message ($localized.RestoringConfigurationSettings -f 'Media'); + $operationMessage = $localized.ShouldProcessOperation -f 'Import', 'Media'; + if ($PSCmdlet.ShouldProcess($verboseMessage, $operationMessage, $localized.ShouldProcessActionConfirmation)) { + [ref] $null = Reset-LabMedia -Confirm:$false; + foreach ($mediaObject in $configuration.CustomMedia) { + $customMedia = ConvertPSObjectToHashtable -InputObject $mediaObject -IgnoreNullValues; + Write-Output (Register-LabMedia @customMedia -Force); + } + WriteVerbose -Message ($localized.ConfigurationRestoreComplete -f 'Media'); + } + } #end if restore custom media + + if ($VM) { + $verboseMessage = GetFormattedMessage -Message ($localized.RestoringConfigurationSettings -f 'VM'); + $operationMessage = $localized.ShouldProcessOperation -f 'Import', 'VM'; + if ($PSCmdlet.ShouldProcess($verboseMessage, $operationMessage, $localized.ShouldProcessActionConfirmation)) { + [ref] $null = Reset-LabVMDefault -Confirm:$false; + $vmDefaultObject = $configuration.VMDefaults; + $vmDefaults = ConvertPSObjectToHashtable -InputObject $vmDefaultObject; + ## Boot order is exposed externally + $vmDefaults.Remove('BootOrder'); + Set-LabVMDefault @vmDefaults -Confirm:$false; + WriteVerbose -Message ($localized.ConfigurationRestoreComplete -f 'VM'); + } + } #end if restore VM defaults + + } #end process + + +} + diff --git a/Public/Import/Tests/Import-LabHostConfiguration.Functional.Tests.ps1 b/Public/Import/Tests/Import-LabHostConfiguration.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Import/Tests/Import-LabHostConfiguration.Tests.ps1 b/Public/Import/Tests/Import-LabHostConfiguration.Tests.ps1 new file mode 100644 index 00000000..868e4343 --- /dev/null +++ b/Public/Import/Tests/Import-LabHostConfiguration.Tests.ps1 @@ -0,0 +1,190 @@ +Describe 'Import-LabHostConfiguration Tests' { + + Context 'Parameters for Import-LabHostConfiguration'{ + + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'True' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be 'Path' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '-2147483648' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called LiteralPath' { + $Function.Parameters.Keys.Contains('LiteralPath') | Should Be 'True' + } + It 'LiteralPath Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.LiteralPath.Attributes.Mandatory | Should be 'True' + } + It 'LiteralPath Parameter is of String Type' { + $Function.Parameters.LiteralPath.ParameterType.FullName | Should be 'System.String' + } + It 'LiteralPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.LiteralPath.ParameterSets.Keys | Should Be 'LiteralPath' + } + It 'LiteralPath Parameter Position is defined correctly' { + [String]$Function.Parameters.LiteralPath.Attributes.Position | Should be '-2147483648' + } + It 'Does LiteralPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.LiteralPath.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does LiteralPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.LiteralPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does LiteralPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.LiteralPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.LiteralPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.LiteralPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.LiteralPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.LiteralPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for LiteralPath '{ + $function.Definition.Contains('.PARAMETER LiteralPath') | Should Be 'True' + } + It 'Has a Parameter called Host' { + $Function.Parameters.Keys.Contains('Host') | Should Be 'True' + } + It 'Host Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Host.Attributes.Mandatory | Should be 'False' + } + It 'Host Parameter is of SwitchParameter Type' { + $Function.Parameters.Host.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Host Parameter is member of ParameterSets' { + [String]$Function.Parameters.Host.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Host Parameter Position is defined correctly' { + [String]$Function.Parameters.Host.Attributes.Position | Should be '-2147483648' + } + It 'Does Host Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Host.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Host Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Host.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Host Parameter use advanced parameter Validation? ' { + $Function.Parameters.Host.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Host.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Host.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Host.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Host.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Host '{ + $function.Definition.Contains('.PARAMETER Host') | Should Be 'True' + } + It 'Has a Parameter called VM' { + $Function.Parameters.Keys.Contains('VM') | Should Be 'True' + } + It 'VM Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.VM.Attributes.Mandatory | Should be 'False' + } + It 'VM Parameter is of SwitchParameter Type' { + $Function.Parameters.VM.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'VM Parameter is member of ParameterSets' { + [String]$Function.Parameters.VM.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'VM Parameter Position is defined correctly' { + [String]$Function.Parameters.VM.Attributes.Position | Should be '-2147483648' + } + It 'Does VM Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.VM.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does VM Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.VM.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does VM Parameter use advanced parameter Validation? ' { + $Function.Parameters.VM.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.VM.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.VM.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.VM.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.VM.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for VM '{ + $function.Definition.Contains('.PARAMETER VM') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'False' + } + It 'Media Parameter is of SwitchParameter Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '-2147483648' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Invoke/Invoke-LabResourceDownload.ps1 b/Public/Invoke/Invoke-LabResourceDownload.ps1 new file mode 100644 index 00000000..9eaa0a2b --- /dev/null +++ b/Public/Invoke/Invoke-LabResourceDownload.ps1 @@ -0,0 +1,205 @@ +function Invoke-LabResourceDownload { + +<# + .SYNOPSIS + Starts a download of all required lab resources. + .DESCRIPTION + When a lab configuration is started, Lability will attempt to download all the required media and resources. + + In some scenarios you many need to download lab resources in advance, e.g. where internet access is not + readily available or permitted. The `Invoke-LabResourceDownload` cmdlet can be used to manually download + all required resources or specific media/resources as needed. + .PARAMETER ConfigurationData + Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + .PARAMETER All + Specifies all media, custom and DSC resources should be downloaded. + .PARAMETER MediaId + Specifies the specific media IDs to download. + .PARAMETER ResourceId + Specifies the specific custom resource IDs to download. + .PARAMETER Media + Specifies all media IDs should be downloaded. + .PARAMETER Resources + Specifies all custom resource IDs should be downloaded. + .PARAMETER DSCResources + Specifies all defined DSC resources should be downloaded. + .PARAMETER Moduless + Specifies all defined PowerShell modules should be downloaded. + .PARAMETER Force + Forces a download of all resources, overwriting any existing resources. + .PARAMETER DestinationPath + Specifies the target destination path of downloaded custom resources (not media or DSC resources). + .EXAMPLE + Invoke-LabResourceDownload -ConfigurationData ~\Documents\MyLab.psd1 -All + + Downloads all required lab media, any custom resources and DSC resources defined in the 'MyLab.psd1' configuration. + .EXAMPLE + Invoke-LabResourceDownload -ConfigurationData ~\Documents\MyLab.psd1 -MediaId 'WIN10_x64_Enterprise_EN_Eval' + + Downloads only the 'WIN10_x64_Enterprise_EN_Eval' media. + .EXAMPLE + Invoke-LabResourceDownload -ConfigurationData ~\Documents\MyLab.psd1 -ResourceId 'MyCustomResource' + + Downloads only the 'MyCustomResource' resource defined in the 'MyLab.psd1' configuration. + .EXAMPLE + Invoke-LabResourceDownload -ConfigurationData ~\Documents\MyLab.psd1 -Media + + Downloads only the media defined in the 'MyLab.psd1' configuration. + .EXAMPLE + Invoke-LabResourceDownload -ConfigurationData ~\Documents\MyLab.psd1 -Resources -DSCResources + + Downloads only the custom file resources and DSC resources defined in the 'MyLab.psd1' configuration. +#> + [CmdletBinding(DefaultParameterSetName = 'All')] + param ( + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData = @{ }, + + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'All')] + [System.Management.Automation.SwitchParameter] $All, + + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'MediaId')] + [System.String[]] $MediaId, + + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'ResourceId')] + [System.String[]] $ResourceId, + + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'Media')] + [System.Management.Automation.SwitchParameter] $Media, + + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'Resources')] + [System.Management.Automation.SwitchParameter] $Resources, + + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'DSCResources')] + [System.Management.Automation.SwitchParameter] $DSCResources, + + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'Modules')] + [System.Management.Automation.SwitchParameter] $Modules, + + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'Resources')] + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'ResourceId')] + [ValidateNotNullOrEmpty()] + [System.String] $DestinationPath, + + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force + ) + begin { + + $hostDefaults = GetConfigurationData -Configuration Host; + if (-not $DestinationPath) { + $DestinationPath = $hostDefaults.ResourcePath; + } + + } + process { + + if ($PSCmdlet.ParameterSetName -in 'MediaId','Media','All') { + + if (-not $MediaId) { + + WriteVerbose ($Localized.DownloadingAllRequiredMedia); + $uniqueMediaIds = @(); + $ConfigurationData.AllNodes.Where({ $_.NodeName -ne '*' }) | ForEach-Object { + $id = (ResolveLabVMProperties -NodeName $_.NodeName -ConfigurationData $ConfigurationData).Media; + if ($uniqueMediaIds -notcontains $id) { $uniqueMediaIds += $id; } + } + $MediaId = $uniqueMediaIds; + } + + if ($MediaId) { + + foreach ($id in $MediaId) { + + $labMedia = ResolveLabMedia -ConfigurationData $ConfigurationData -Id $id; + InvokeLabMediaImageDownload -Media $labMedia -Force:$Force; + + WriteVerbose $Localized.DownloadingAllRequiredHotfixes; + if ($labMedia.Hotfixes.Count -gt 0) { + foreach ($hotfix in $labMedia.Hotfixes) { + InvokeLabMediaHotfixDownload -Id $hotfix.Id -Uri $hotfix.Uri; + } + } + else { + WriteVerbose ($localized.NoHotfixesSpecified); + } + } + + } + else { + WriteVerbose ($localized.NoMediaDefined); + } + + } #end if MediaId or MediaOnly + + if ($PSCmdlet.ParameterSetName -in 'ResourceId','Resources','All') { + + if (-not $ResourceId) { + + WriteVerbose ($Localized.DownloadingAllDefinedResources); + $ResourceId = $ConfigurationData.NonNodeData.$($labDefaults.ModuleName).Resource.Id; + } + + if (($ResourceId.Count -gt 0) -and (-not $MediaOnly)) { + + foreach ($id in $ResourceId) { + + $resource = ResolveLabResource -ConfigurationData $ConfigurationData -ResourceId $id; + if (($null -eq $resource.IsLocal) -or ($resource.IsLocal -eq $false)) { + + $fileName = $resource.Id; + if ($resource.Filename) { $fileName = $resource.Filename; } + $resourceDestinationPath = Join-Path -Path $DestinationPath -ChildPath $fileName; + $invokeResourceDownloadParams = @{ + DestinationPath = $resourceDestinationPath; + Uri = $resource.Uri; + Checksum = $resource.Checksum; + Force = $Force; + } + [ref] $null = InvokeResourceDownload @invokeResourceDownloadParams; + Write-Output (Get-Item -Path $resourceDestinationPath); + } + } + } + else { + + WriteVerbose ($localized.NoResourcesDefined); + } + + } #end if ResourceId or ResourceOnly + + if ($PSCmdlet.ParameterSetName -in 'DSCResources','All') { + + $dscResourceDefinitions = $ConfigurationData.NonNodeData.$($labDefaults.ModuleName).DSCResource; + if (($null -ne $dscResourceDefinitions) -and ($dscResourceDefinitions.Count -gt 0)) { + + ## Invokes download of DSC resource modules into the module cache + WriteVerbose ($Localized.DownloadingAllDSCResources); + InvokeModuleCacheDownload -Module $dscResourceDefinitions -Force:$Force; + } + else { + WriteVerbose ($localized.NoDSCResourcesDefined); + } + } #end if DSC resource + + if ($PSCmdlet.ParameterSetName -in 'Modules','All') { + + $moduleDefinitions = $ConfigurationData.NonNodeData.$($labDefaults.ModuleName).Module; + if (($null -ne $moduleDefinitions) -and ($moduleDefinitions.Count -gt 0)) { + + ## Invokes download of PowerShell modules into the module cache + WriteVerbose ($Localized.DownloadingAllPowerShellModules); + InvokeModuleCacheDownload -Module $moduleDefinitions -Force:$Force; + } + else { + WriteVerbose ($localized.NoPowerShellModulesDefined); + } + + } #end PowerShell module + + } #end process + +} + diff --git a/Public/Invoke/Tests/Invoke-LabResourceDownload.Functional.Tests.ps1 b/Public/Invoke/Tests/Invoke-LabResourceDownload.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Invoke/Tests/Invoke-LabResourceDownload.Tests.ps1 b/Public/Invoke/Tests/Invoke-LabResourceDownload.Tests.ps1 new file mode 100644 index 00000000..b977bbed --- /dev/null +++ b/Public/Invoke/Tests/Invoke-LabResourceDownload.Tests.ps1 @@ -0,0 +1,345 @@ +Describe 'Invoke-LabResourceDownload Tests' { + + Context 'Parameters for Invoke-LabResourceDownload'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '-2147483648' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called All' { + $Function.Parameters.Keys.Contains('All') | Should Be 'True' + } + It 'All Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.All.Attributes.Mandatory | Should be 'False' + } + It 'All Parameter is of SwitchParameter Type' { + $Function.Parameters.All.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'All Parameter is member of ParameterSets' { + [String]$Function.Parameters.All.ParameterSets.Keys | Should Be 'All' + } + It 'All Parameter Position is defined correctly' { + [String]$Function.Parameters.All.Attributes.Position | Should be '-2147483648' + } + It 'Does All Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.All.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does All Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.All.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does All Parameter use advanced parameter Validation? ' { + $Function.Parameters.All.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.All.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.All.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.All.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.All.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for All '{ + $function.Definition.Contains('.PARAMETER All') | Should Be 'True' + } + It 'Has a Parameter called MediaId' { + $Function.Parameters.Keys.Contains('MediaId') | Should Be 'True' + } + It 'MediaId Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MediaId.Attributes.Mandatory | Should be 'False' + } + It 'MediaId Parameter is of String[] Type' { + $Function.Parameters.MediaId.ParameterType.FullName | Should be 'System.String[]' + } + It 'MediaId Parameter is member of ParameterSets' { + [String]$Function.Parameters.MediaId.ParameterSets.Keys | Should Be 'MediaId' + } + It 'MediaId Parameter Position is defined correctly' { + [String]$Function.Parameters.MediaId.Attributes.Position | Should be '-2147483648' + } + It 'Does MediaId Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MediaId.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MediaId Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MediaId.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MediaId Parameter use advanced parameter Validation? ' { + $Function.Parameters.MediaId.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MediaId.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MediaId.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MediaId.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MediaId.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MediaId '{ + $function.Definition.Contains('.PARAMETER MediaId') | Should Be 'True' + } + It 'Has a Parameter called ResourceId' { + $Function.Parameters.Keys.Contains('ResourceId') | Should Be 'True' + } + It 'ResourceId Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ResourceId.Attributes.Mandatory | Should be 'False' + } + It 'ResourceId Parameter is of String[] Type' { + $Function.Parameters.ResourceId.ParameterType.FullName | Should be 'System.String[]' + } + It 'ResourceId Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceId.ParameterSets.Keys | Should Be 'ResourceId' + } + It 'ResourceId Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceId.Attributes.Position | Should be '-2147483648' + } + It 'Does ResourceId Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceId.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourceId Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceId.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ResourceId Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceId '{ + $function.Definition.Contains('.PARAMETER ResourceId') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'False' + } + It 'Media Parameter is of SwitchParameter Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be 'Media' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '-2147483648' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called Resources' { + $Function.Parameters.Keys.Contains('Resources') | Should Be 'True' + } + It 'Resources Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Resources.Attributes.Mandatory | Should be 'False' + } + It 'Resources Parameter is of SwitchParameter Type' { + $Function.Parameters.Resources.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Resources Parameter is member of ParameterSets' { + [String]$Function.Parameters.Resources.ParameterSets.Keys | Should Be 'Resources' + } + It 'Resources Parameter Position is defined correctly' { + [String]$Function.Parameters.Resources.Attributes.Position | Should be '-2147483648' + } + It 'Does Resources Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Resources.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Resources Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Resources.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Resources Parameter use advanced parameter Validation? ' { + $Function.Parameters.Resources.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Resources.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Resources.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Resources.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Resources.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Resources '{ + $function.Definition.Contains('.PARAMETER Resources') | Should Be 'True' + } + It 'Has a Parameter called DSCResources' { + $Function.Parameters.Keys.Contains('DSCResources') | Should Be 'True' + } + It 'DSCResources Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.DSCResources.Attributes.Mandatory | Should be 'False' + } + It 'DSCResources Parameter is of SwitchParameter Type' { + $Function.Parameters.DSCResources.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'DSCResources Parameter is member of ParameterSets' { + [String]$Function.Parameters.DSCResources.ParameterSets.Keys | Should Be 'DSCResources' + } + It 'DSCResources Parameter Position is defined correctly' { + [String]$Function.Parameters.DSCResources.Attributes.Position | Should be '-2147483648' + } + It 'Does DSCResources Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DSCResources.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DSCResources Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DSCResources.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DSCResources Parameter use advanced parameter Validation? ' { + $Function.Parameters.DSCResources.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.DSCResources.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DSCResources.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DSCResources.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DSCResources.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DSCResources '{ + $function.Definition.Contains('.PARAMETER DSCResources') | Should Be 'True' + } + It 'Has a Parameter called Modules' { + $Function.Parameters.Keys.Contains('Modules') | Should Be 'True' + } + It 'Modules Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Modules.Attributes.Mandatory | Should be 'False' + } + It 'Modules Parameter is of SwitchParameter Type' { + $Function.Parameters.Modules.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Modules Parameter is member of ParameterSets' { + [String]$Function.Parameters.Modules.ParameterSets.Keys | Should Be 'Modules' + } + It 'Modules Parameter Position is defined correctly' { + [String]$Function.Parameters.Modules.Attributes.Position | Should be '-2147483648' + } + It 'Does Modules Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Modules.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Modules Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Modules.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Modules Parameter use advanced parameter Validation? ' { + $Function.Parameters.Modules.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Modules.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Modules.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Modules.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Modules.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Modules '{ + $function.Definition.Contains('.PARAMETER Modules') | Should Be 'True' + } + It 'Has a Parameter called DestinationPath' { + $Function.Parameters.Keys.Contains('DestinationPath') | Should Be 'True' + } + It 'DestinationPath Parameter is Identified as Mandatory being False False' { + [String]$Function.Parameters.DestinationPath.Attributes.Mandatory | Should be 'False False' + } + It 'DestinationPath Parameter is of String Type' { + $Function.Parameters.DestinationPath.ParameterType.FullName | Should be 'System.String' + } + It 'DestinationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DestinationPath.ParameterSets.Keys | Should Be 'ResourceId Resources' + } + It 'DestinationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DestinationPath.Attributes.Position | Should be '-2147483648 -2147483648' + } + It 'Does DestinationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipeline | Should be 'False False' + } + It 'Does DestinationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DestinationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True True' + } + It 'Does DestinationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DestinationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DestinationPath '{ + $function.Definition.Contains('.PARAMETER DestinationPath') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/New/New-LabImage.ps1 b/Public/New/New-LabImage.ps1 new file mode 100644 index 00000000..ea660694 --- /dev/null +++ b/Public/New/New-LabImage.ps1 @@ -0,0 +1,203 @@ +function New-LabImage { + +<# + .SYNOPSIS + Creates a new master/parent lab image. + .DESCRIPTION + The New-LabImage cmdlet starts the creation of a lab VHD(X) master image from the specified media Id. + + Lability will automatically create lab images as required. If there is a need to manally recreate an image, + then the New-LabImage cmdlet can be used. + .PARAMETER Id + Specifies the media Id of the image to create. + .PARAMETER ConfigurationData + Specifies a PowerShell DSC configuration data hashtable or a path to an existing PowerShell DSC .psd1 + configuration document that contains the required media definition. + .PARAMETER Force + Specifies that any existing image should be overwritten. + .EXAMPLE + New-LabImage -Id 2012R2_x64_Standard_EN_Eval + + Creates the VHD(X) image from the '2012R2_x64_Standard_EN_Eval' media Id. + .EXAMPLE + New-LabImage -Id 2012R2_x64_Standard_EN_Eval -Force + + Creates the VHD(X) image from the '2012R2_x64_Standard_EN_Eval' media Id, overwriting an existing image with the same name. + .LINK + Get-LabMedia + Get-LabImage +#> + [CmdletBinding(SupportsShouldProcess)] + [OutputType([System.Management.Automation.PSCustomObject])] + param ( + ## Lab media Id + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Id, + + ## Lab DSC configuration data + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Force the re(creation) of the master/parent image + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force + ) + process { + + ## Download media if required.. + [ref] $null = $PSBoundParameters.Remove('Force'); + [ref] $null = $PSBoundParameters.Remove('WhatIf'); + [ref] $null = $PSBoundParameters.Remove('Confirm'); + + if ((Test-LabImage @PSBoundParameters) -and $Force) { + + $image = Get-LabImage @PSBoundParameters; + WriteVerbose ($localized.RemovingDiskImage -f $image.ImagePath); + [ref] $null = Remove-Item -Path $image.ImagePath -Force -ErrorAction Stop; + } + elseif (Test-LabImage @PSBoundParameters) { + + throw ($localized.ImageAlreadyExistsError -f $Id); + } + + $media = ResolveLabMedia @PSBoundParameters; + $mediaFileInfo = InvokeLabMediaImageDownload -Media $media; + $hostDefaults = GetConfigurationData -Configuration Host; + + if ($media.MediaType -eq 'VHD') { + + WriteVerbose ($localized.ImportingExistingDiskImage -f $media.Description); + $imageName = $media.Filename; + $imagePath = Join-Path -Path $hostDefaults.ParentVhdPath -ChildPath $imageName; + } #end if VHD + else { + + ## Create VHDX + if ($media.CustomData.PartitionStyle) { + + ## Custom partition style has been defined so use that + $partitionStyle = $media.CustomData.PartitionStyle; + } + elseif ($media.Architecture -eq 'x86') { + + ## Otherwise default to MBR for x86 media + $partitionStyle = 'MBR'; + } + else { + + $partitionStyle = 'GPT'; + } + + WriteVerbose ($localized.CreatingDiskImage -f $media.Description); + $imageName = '{0}.vhdx' -f $Id; + $imagePath = Join-Path -Path $hostDefaults.ParentVhdPath -ChildPath $imageName; + + ## Apply WIM (ExpandWindowsImage) and add specified features + $expandWindowsImageParams = @{ + MediaPath = $mediaFileInfo.FullName; + PartitionStyle = $partitionStyle; + } + + ## Determine whether we're using the WIM image index or image name. This permits + ## specifying an integer image index in a media's 'ImageName' property. + [System.Int32] $wimImageIndex = $null; + if ([System.Int32]::TryParse($media.ImageName, [ref] $wimImageIndex)) { + + $expandWindowsImageParams['WimImageIndex'] = $wimImageIndex; + } + else { + + if ([System.String]::IsNullOrEmpty($media.ImageName)) { + throw ($localized.ImageNameRequiredError -f 'ImageName'); + } + + $expandWindowsImageParams['WimImageName'] = $media.ImageName; + } + + $imageCreationFailed = $false; + + try { + + ## Create disk image and refresh PSDrives + $newDiskImageParams = @{ + Path = $imagePath; + PartitionStyle = $partitionStyle; + Passthru = $true; + Force = $true; + ErrorAction = 'Stop'; + } + $image = NewDiskImage @newDiskImageParams; + [ref] $null = Get-PSDrive; + + $expandWindowsImageParams['Vhd'] = $image; + + if ($media.CustomData.SourcePath) { + + $expandWindowsImageParams['SourcePath'] = $media.CustomData.SourcePath; + } + if ($media.CustomData.WimPath) { + + $expandWindowsImageParams['WimPath'] = $media.CustomData.WimPath; + } + if ($media.CustomData.WindowsOptionalFeature) { + + $expandWindowsImageParams['WindowsOptionalFeature'] = $media.CustomData.WindowsOptionalFeature; + } + if ($media.CustomData.PackagePath) { + + $expandWindowsImageParams['PackagePath'] = $media.CustomData.PackagePath; + } + if ($media.CustomData.Package) { + + $expandWindowsImageParams['Package'] = $media.CustomData.Package; + } + if ($media.CustomData.PackageLocale) { + + $expandWindowsImageParams['PackageLocale'] = $media.CustomData.PackageLocale; + } + + ExpandWindowsImage @expandWindowsImageParams; + + ## Apply hotfixes (AddDiskImageHotfix) + $addDiskImageHotfixParams = @{ + Id = $Id; + Vhd = $image; + PartitionStyle = $partitionStyle; + } + if ($PSBoundParameters.ContainsKey('ConfigurationData')) { + $addDiskImageHotfixParams['ConfigurationData'] = $ConfigurationData; + } + AddDiskImageHotfix @addDiskImageHotfixParams; + + ## Configure boot volume (SetDiskImageBootVolume) + SetDiskImageBootVolume -Vhd $image -PartitionStyle $partitionStyle; + + } + catch { + + ## Have to ensure VHDX is dismounted before we can delete! + $imageCreationFailed = $true; + Write-Error -Message $_; + } + finally { + + ## Dismount VHDX + Dismount-VHD -Path $imagePath; + } + + if ($imageCreationFailed -eq $true) { + + WriteWarning ($localized.RemovingIncompleteImageWarning -f $imagePath); + Remove-Item -Path $imagePath -Force; + } + } #end if ISO/WIM + + return (Get-LabImage $PSBoundParameters); + + } #end process + +} + diff --git a/Public/New/New-LabVM.ps1 b/Public/New/New-LabVM.ps1 new file mode 100644 index 00000000..da496fb0 --- /dev/null +++ b/Public/New/New-LabVM.ps1 @@ -0,0 +1,204 @@ +function New-LabVM { + +<# + .SYNOPSIS + Creates a simple bare-metal virtual machine. + .DESCRIPTION + The New-LabVM cmdlet creates a bare virtual machine using the specified media. No bootstrap or DSC configuration is applied. + + NOTE: The mandatory -MediaId parameter is dynamic and is not displayed in the help syntax output. + + If optional values are not specified, the virtual machine default settings are applied. To list the current default settings run the `Get-LabVMDefault` command. + + NOTE: If a specified virtual switch cannot be found, an Internal virtual switch will automatically be created. To use any other virtual switch configuration, ensure the virtual switch is created in advance. + .LINK + Register-LabMedia + Unregister-LabMedia + Get-LabVMDefault + Set-LabVMDefault +#> + [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'PSCredential')] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingUserNameAndPassWordParams','')] + param ( + ## Specifies the virtual machine name. + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String[]] $Name, + + ## Default virtual machine startup memory (bytes). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateRange(536870912, 1099511627776)] + [System.Int64] $StartupMemory, + + ## Default virtual machine miniumum dynamic memory allocation (bytes). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateRange(536870912, 1099511627776)] + [System.Int64] $MinimumMemory, + + ## Default virtual machine maximum dynamic memory allocation (bytes). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateRange(536870912, 1099511627776)] + [System.Int64] $MaximumMemory, + + ## Default virtual machine processor count. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateRange(1, 4)] + [System.Int32] $ProcessorCount, + + # Input Locale + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^([a-z]{2,2}-[a-z]{2,2})|(\d{4,4}:\d{8,8})$')] + [System.String] $InputLocale, + + # System Locale + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^[a-z]{2,2}-[a-z]{2,2}$')] + [System.String] $SystemLocale, + + # User Locale + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^[a-z]{2,2}-[a-z]{2,2}$')] + [System.String] $UserLocale, + + # UI Language + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^[a-z]{2,2}-[a-z]{2,2}$')] + [System.String] $UILanguage, + + # Timezone + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Timezone, + + # Registered Owner + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $RegisteredOwner, + + # Registered Organization + [Parameter(ValueFromPipelineByPropertyName)] [Alias('RegisteredOrganisation')] + [ValidateNotNullOrEmpty()] + [System.String] $RegisteredOrganization, + + ## Local administrator password of the VM. The username is NOT used. + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'PSCredential')] + [ValidateNotNullOrEmpty()] + [System.Management.Automation.PSCredential] + [System.Management.Automation.CredentialAttribute()] + $Credential = (& $credentialCheckScriptBlock), + + ## Local administrator password of the VM. + [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'Password')] + [ValidateNotNullOrEmpty()] + [System.Security.SecureString] $Password, + + ## Virtual machine switch name(s). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String[]] $SwitchName, + + ## Virtual machine MAC address(es). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String[]] $MACAddress, + + ## Enable Secure boot status + [Parameter(ValueFromPipelineByPropertyName)] + [System.Boolean] $SecureBoot, + + ## Enable Guest Integration Services + [Parameter(ValueFromPipelineByPropertyName)] + [System.Boolean] $GuestIntegrationServices, + + ## Custom data + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.Collections.Hashtable] $CustomData, + + ## Skip creating baseline snapshots + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $NoSnapshot + ) + DynamicParam { + + ## Adds a dynamic -MediaId parameter that returns the available media Ids + $parameterAttribute = New-Object -TypeName 'System.Management.Automation.ParameterAttribute'; + $parameterAttribute.ParameterSetName = '__AllParameterSets'; + $parameterAttribute.Mandatory = $true; + $attributeCollection = New-Object -TypeName 'System.Collections.ObjectModel.Collection[System.Attribute]'; + $attributeCollection.Add($parameterAttribute); + $mediaIds = (Get-LabMedia).Id; + $validateSetAttribute = New-Object -TypeName 'System.Management.Automation.ValidateSetAttribute' -ArgumentList $mediaIds; + $attributeCollection.Add($validateSetAttribute); + $runtimeParameter = New-Object -TypeName 'System.Management.Automation.RuntimeDefinedParameter' -ArgumentList @('MediaId', [System.String], $attributeCollection); + $runtimeParameterDictionary = New-Object -TypeName 'System.Management.Automation.RuntimeDefinedParameterDictionary'; + $runtimeParameterDictionary.Add('MediaId', $runtimeParameter); + return $runtimeParameterDictionary; + } + begin { + + ## If we have only a secure string, create a PSCredential + if ($PSCmdlet.ParameterSetName -eq 'Password') { + $Credential = New-Object -TypeName 'System.Management.Automation.PSCredential' -ArgumentList 'LocalAdministrator', $Password; + } + if (-not $Credential) { throw ($localized.CannotProcessCommandError -f 'Credential'); } + elseif ($Credential.Password.Length -eq 0) { throw ($localized.CannotBindArgumentError -f 'Password'); } + + } #end begin + process { + + ## Skeleton configuration node + $configurationNode = @{ } + + if ($CustomData) { + + ## Add all -CustomData keys/values to the skeleton configuration + foreach ($key in $CustomData.Keys) { + + $configurationNode[$key] = $CustomData.$key; + } + } + + ## Explicitly defined parameters override any -CustomData + $parameterNames = @('StartupMemory','MinimumMemory','MaximumMemory','SwitchName','Timezone','UILanguage','MACAddress', + 'ProcessorCount','InputLocale','SystemLocale','UserLocale','RegisteredOwner','RegisteredOrganization','SecureBoot') + foreach ($key in $parameterNames) { + + if ($PSBoundParameters.ContainsKey($key)) { + + $configurationNode[$key] = $PSBoundParameters.$key; + } + } + + ## Ensure the specified MediaId is applied after any CustomData media entry! + $configurationNode['Media'] = $PSBoundParameters.MediaId; + + $currentNodeCount = 0; + foreach ($vmName in $Name) { + + ## Update the node name before creating the VM + $configurationNode['NodeName'] = $vmName; + $shouldProcessMessage = $localized.PerformingOperationOnTarget -f 'New-LabVM', $vmName; + $verboseProcessMessage = GetFormattedMessage -Message ($localized.CreatingQuickVM -f $vmName, $PSBoundParameters.MediaId); + if ($PSCmdlet.ShouldProcess($verboseProcessMessage, $shouldProcessMessage, $localized.ShouldProcessWarning)) { + + $currentNodeCount++; + [System.Int32] $percentComplete = (($currentNodeCount / $Name.Count) * 100) - 1; + $activity = $localized.ConfiguringNode -f $vmName; + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + + $configurationData = @{ AllNodes = @( $configurationNode ) }; + NewLabVM -Name $vmName -ConfigurationData $configurationData -Credential $Credential -NoSnapshot:$NoSnapshot -IsQuickVM; + } + + } #end foreach name + + if (-not [System.String]::IsNullOrEmpty($activity)) { + + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + } + + } #end process + +} + diff --git a/Public/New/Tests/New-LabImage.Functional.Tests.ps1 b/Public/New/Tests/New-LabImage.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/New/Tests/New-LabImage.Tests.ps1 b/Public/New/Tests/New-LabImage.Tests.ps1 new file mode 100644 index 00000000..e271a609 --- /dev/null +++ b/Public/New/Tests/New-LabImage.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'New-LabImage Tests' { + + Context 'Parameters for New-LabImage'{ + + It 'Has a Parameter called Id' { + $Function.Parameters.Keys.Contains('Id') | Should Be 'True' + } + It 'Id Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Id.Attributes.Mandatory | Should be 'True' + } + It 'Id Parameter is of String Type' { + $Function.Parameters.Id.ParameterType.FullName | Should be 'System.String' + } + It 'Id Parameter is member of ParameterSets' { + [String]$Function.Parameters.Id.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Id Parameter Position is defined correctly' { + [String]$Function.Parameters.Id.Attributes.Position | Should be '0' + } + It 'Does Id Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Id Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Id Parameter use advanced parameter Validation? ' { + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Id '{ + $function.Definition.Contains('.PARAMETER Id') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/New/Tests/New-LabVM.Functional.Tests.ps1 b/Public/New/Tests/New-LabVM.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/New/Tests/New-LabVM.Tests.ps1 b/Public/New/Tests/New-LabVM.Tests.ps1 new file mode 100644 index 00000000..6288d4ff --- /dev/null +++ b/Public/New/Tests/New-LabVM.Tests.ps1 @@ -0,0 +1,686 @@ +Describe 'New-LabVM Tests' { + + Context 'Parameters for New-LabVM'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String[] Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String[]' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '-2147483648' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called StartupMemory' { + $Function.Parameters.Keys.Contains('StartupMemory') | Should Be 'True' + } + It 'StartupMemory Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.StartupMemory.Attributes.Mandatory | Should be 'False' + } + It 'StartupMemory Parameter is of Int64 Type' { + $Function.Parameters.StartupMemory.ParameterType.FullName | Should be 'System.Int64' + } + It 'StartupMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.StartupMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'StartupMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.StartupMemory.Attributes.Position | Should be '-2147483648' + } + It 'Does StartupMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does StartupMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does StartupMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'True' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for StartupMemory '{ + $function.Definition.Contains('.PARAMETER StartupMemory') | Should Be 'True' + } + It 'Has a Parameter called MinimumMemory' { + $Function.Parameters.Keys.Contains('MinimumMemory') | Should Be 'True' + } + It 'MinimumMemory Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MinimumMemory.Attributes.Mandatory | Should be 'False' + } + It 'MinimumMemory Parameter is of Int64 Type' { + $Function.Parameters.MinimumMemory.ParameterType.FullName | Should be 'System.Int64' + } + It 'MinimumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MinimumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumMemory.Attributes.Position | Should be '-2147483648' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MinimumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'True' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumMemory '{ + $function.Definition.Contains('.PARAMETER MinimumMemory') | Should Be 'True' + } + It 'Has a Parameter called MaximumMemory' { + $Function.Parameters.Keys.Contains('MaximumMemory') | Should Be 'True' + } + It 'MaximumMemory Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MaximumMemory.Attributes.Mandatory | Should be 'False' + } + It 'MaximumMemory Parameter is of Int64 Type' { + $Function.Parameters.MaximumMemory.ParameterType.FullName | Should be 'System.Int64' + } + It 'MaximumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MaximumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MaximumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MaximumMemory.Attributes.Position | Should be '-2147483648' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MaximumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'True' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MaximumMemory '{ + $function.Definition.Contains('.PARAMETER MaximumMemory') | Should Be 'True' + } + It 'Has a Parameter called ProcessorCount' { + $Function.Parameters.Keys.Contains('ProcessorCount') | Should Be 'True' + } + It 'ProcessorCount Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ProcessorCount.Attributes.Mandatory | Should be 'False' + } + It 'ProcessorCount Parameter is of Int32 Type' { + $Function.Parameters.ProcessorCount.ParameterType.FullName | Should be 'System.Int32' + } + It 'ProcessorCount Parameter is member of ParameterSets' { + [String]$Function.Parameters.ProcessorCount.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ProcessorCount Parameter Position is defined correctly' { + [String]$Function.Parameters.ProcessorCount.Attributes.Position | Should be '-2147483648' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ProcessorCount Parameter use advanced parameter Validation? ' { + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'True' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ProcessorCount '{ + $function.Definition.Contains('.PARAMETER ProcessorCount') | Should Be 'True' + } + It 'Has a Parameter called InputLocale' { + $Function.Parameters.Keys.Contains('InputLocale') | Should Be 'True' + } + It 'InputLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.InputLocale.Attributes.Mandatory | Should be 'False' + } + It 'InputLocale Parameter is of String Type' { + $Function.Parameters.InputLocale.ParameterType.FullName | Should be 'System.String' + } + It 'InputLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.InputLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'InputLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.InputLocale.Attributes.Position | Should be '-2147483648' + } + It 'Does InputLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.InputLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does InputLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.InputLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does InputLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for InputLocale '{ + $function.Definition.Contains('.PARAMETER InputLocale') | Should Be 'True' + } + It 'Has a Parameter called SystemLocale' { + $Function.Parameters.Keys.Contains('SystemLocale') | Should Be 'True' + } + It 'SystemLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SystemLocale.Attributes.Mandatory | Should be 'False' + } + It 'SystemLocale Parameter is of String Type' { + $Function.Parameters.SystemLocale.ParameterType.FullName | Should be 'System.String' + } + It 'SystemLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.SystemLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SystemLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.SystemLocale.Attributes.Position | Should be '-2147483648' + } + It 'Does SystemLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SystemLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SystemLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SystemLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SystemLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for SystemLocale '{ + $function.Definition.Contains('.PARAMETER SystemLocale') | Should Be 'True' + } + It 'Has a Parameter called UserLocale' { + $Function.Parameters.Keys.Contains('UserLocale') | Should Be 'True' + } + It 'UserLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.UserLocale.Attributes.Mandatory | Should be 'False' + } + It 'UserLocale Parameter is of String Type' { + $Function.Parameters.UserLocale.ParameterType.FullName | Should be 'System.String' + } + It 'UserLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.UserLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'UserLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.UserLocale.Attributes.Position | Should be '-2147483648' + } + It 'Does UserLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.UserLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does UserLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.UserLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does UserLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for UserLocale '{ + $function.Definition.Contains('.PARAMETER UserLocale') | Should Be 'True' + } + It 'Has a Parameter called UILanguage' { + $Function.Parameters.Keys.Contains('UILanguage') | Should Be 'True' + } + It 'UILanguage Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.UILanguage.Attributes.Mandatory | Should be 'False' + } + It 'UILanguage Parameter is of String Type' { + $Function.Parameters.UILanguage.ParameterType.FullName | Should be 'System.String' + } + It 'UILanguage Parameter is member of ParameterSets' { + [String]$Function.Parameters.UILanguage.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'UILanguage Parameter Position is defined correctly' { + [String]$Function.Parameters.UILanguage.Attributes.Position | Should be '-2147483648' + } + It 'Does UILanguage Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.UILanguage.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does UILanguage Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.UILanguage.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does UILanguage Parameter use advanced parameter Validation? ' { + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for UILanguage '{ + $function.Definition.Contains('.PARAMETER UILanguage') | Should Be 'True' + } + It 'Has a Parameter called Timezone' { + $Function.Parameters.Keys.Contains('Timezone') | Should Be 'True' + } + It 'Timezone Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Timezone.Attributes.Mandatory | Should be 'False' + } + It 'Timezone Parameter is of String Type' { + $Function.Parameters.Timezone.ParameterType.FullName | Should be 'System.String' + } + It 'Timezone Parameter is member of ParameterSets' { + [String]$Function.Parameters.Timezone.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Timezone Parameter Position is defined correctly' { + [String]$Function.Parameters.Timezone.Attributes.Position | Should be '-2147483648' + } + It 'Does Timezone Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Timezone.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Timezone Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Timezone.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Timezone Parameter use advanced parameter Validation? ' { + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Timezone '{ + $function.Definition.Contains('.PARAMETER Timezone') | Should Be 'True' + } + It 'Has a Parameter called RegisteredOwner' { + $Function.Parameters.Keys.Contains('RegisteredOwner') | Should Be 'True' + } + It 'RegisteredOwner Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RegisteredOwner.Attributes.Mandatory | Should be 'False' + } + It 'RegisteredOwner Parameter is of String Type' { + $Function.Parameters.RegisteredOwner.ParameterType.FullName | Should be 'System.String' + } + It 'RegisteredOwner Parameter is member of ParameterSets' { + [String]$Function.Parameters.RegisteredOwner.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RegisteredOwner Parameter Position is defined correctly' { + [String]$Function.Parameters.RegisteredOwner.Attributes.Position | Should be '-2147483648' + } + It 'Does RegisteredOwner Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RegisteredOwner.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RegisteredOwner Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RegisteredOwner.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RegisteredOwner Parameter use advanced parameter Validation? ' { + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RegisteredOwner '{ + $function.Definition.Contains('.PARAMETER RegisteredOwner') | Should Be 'True' + } + It 'Has a Parameter called RegisteredOrganization' { + $Function.Parameters.Keys.Contains('RegisteredOrganization') | Should Be 'True' + } + It 'RegisteredOrganization Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.Mandatory | Should be 'False' + } + It 'RegisteredOrganization Parameter is of String Type' { + $Function.Parameters.RegisteredOrganization.ParameterType.FullName | Should be 'System.String' + } + It 'RegisteredOrganization Parameter is member of ParameterSets' { + [String]$Function.Parameters.RegisteredOrganization.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RegisteredOrganization Parameter Position is defined correctly' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.Position | Should be '-2147483648' + } + It 'Does RegisteredOrganization Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RegisteredOrganization Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RegisteredOrganization Parameter use advanced parameter Validation? ' { + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RegisteredOrganization '{ + $function.Definition.Contains('.PARAMETER RegisteredOrganization') | Should Be 'True' + } + It 'Has a Parameter called Credential' { + $Function.Parameters.Keys.Contains('Credential') | Should Be 'True' + } + It 'Credential Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Credential.Attributes.Mandatory | Should be 'False' + } + It 'Credential Parameter is of PSCredential Type' { + $Function.Parameters.Credential.ParameterType.FullName | Should be 'System.Management.Automation.PSCredential' + } + It 'Credential Parameter is member of ParameterSets' { + [String]$Function.Parameters.Credential.ParameterSets.Keys | Should Be 'PSCredential' + } + It 'Credential Parameter Position is defined correctly' { + [String]$Function.Parameters.Credential.Attributes.Position | Should be '-2147483648' + } + It 'Does Credential Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Credential Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Credential Parameter use advanced parameter Validation? ' { + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Credential '{ + $function.Definition.Contains('.PARAMETER Credential') | Should Be 'True' + } + It 'Has a Parameter called Password' { + $Function.Parameters.Keys.Contains('Password') | Should Be 'True' + } + It 'Password Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Password.Attributes.Mandatory | Should be 'True' + } + It 'Password Parameter is of SecureString Type' { + $Function.Parameters.Password.ParameterType.FullName | Should be 'System.Security.SecureString' + } + It 'Password Parameter is member of ParameterSets' { + [String]$Function.Parameters.Password.ParameterSets.Keys | Should Be 'Password' + } + It 'Password Parameter Position is defined correctly' { + [String]$Function.Parameters.Password.Attributes.Position | Should be '-2147483648' + } + It 'Does Password Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Password.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Password Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Password.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Password Parameter use advanced parameter Validation? ' { + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Password '{ + $function.Definition.Contains('.PARAMETER Password') | Should Be 'True' + } + It 'Has a Parameter called SwitchName' { + $Function.Parameters.Keys.Contains('SwitchName') | Should Be 'True' + } + It 'SwitchName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SwitchName.Attributes.Mandatory | Should be 'False' + } + It 'SwitchName Parameter is of String[] Type' { + $Function.Parameters.SwitchName.ParameterType.FullName | Should be 'System.String[]' + } + It 'SwitchName Parameter is member of ParameterSets' { + [String]$Function.Parameters.SwitchName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SwitchName Parameter Position is defined correctly' { + [String]$Function.Parameters.SwitchName.Attributes.Position | Should be '-2147483648' + } + It 'Does SwitchName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SwitchName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SwitchName Parameter use advanced parameter Validation? ' { + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SwitchName '{ + $function.Definition.Contains('.PARAMETER SwitchName') | Should Be 'True' + } + It 'Has a Parameter called MACAddress' { + $Function.Parameters.Keys.Contains('MACAddress') | Should Be 'True' + } + It 'MACAddress Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MACAddress.Attributes.Mandatory | Should be 'False' + } + It 'MACAddress Parameter is of String[] Type' { + $Function.Parameters.MACAddress.ParameterType.FullName | Should be 'System.String[]' + } + It 'MACAddress Parameter is member of ParameterSets' { + [String]$Function.Parameters.MACAddress.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MACAddress Parameter Position is defined correctly' { + [String]$Function.Parameters.MACAddress.Attributes.Position | Should be '-2147483648' + } + It 'Does MACAddress Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MACAddress.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MACAddress Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MACAddress.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MACAddress Parameter use advanced parameter Validation? ' { + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MACAddress.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MACAddress '{ + $function.Definition.Contains('.PARAMETER MACAddress') | Should Be 'True' + } + It 'Has a Parameter called SecureBoot' { + $Function.Parameters.Keys.Contains('SecureBoot') | Should Be 'True' + } + It 'SecureBoot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SecureBoot.Attributes.Mandatory | Should be 'False' + } + It 'SecureBoot Parameter is of Boolean Type' { + $Function.Parameters.SecureBoot.ParameterType.FullName | Should be 'System.Boolean' + } + It 'SecureBoot Parameter is member of ParameterSets' { + [String]$Function.Parameters.SecureBoot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SecureBoot Parameter Position is defined correctly' { + [String]$Function.Parameters.SecureBoot.Attributes.Position | Should be '-2147483648' + } + It 'Does SecureBoot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SecureBoot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SecureBoot Parameter use advanced parameter Validation? ' { + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SecureBoot '{ + $function.Definition.Contains('.PARAMETER SecureBoot') | Should Be 'True' + } + It 'Has a Parameter called GuestIntegrationServices' { + $Function.Parameters.Keys.Contains('GuestIntegrationServices') | Should Be 'True' + } + It 'GuestIntegrationServices Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Mandatory | Should be 'False' + } + It 'GuestIntegrationServices Parameter is of Boolean Type' { + $Function.Parameters.GuestIntegrationServices.ParameterType.FullName | Should be 'System.Boolean' + } + It 'GuestIntegrationServices Parameter is member of ParameterSets' { + [String]$Function.Parameters.GuestIntegrationServices.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'GuestIntegrationServices Parameter Position is defined correctly' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Position | Should be '-2147483648' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does GuestIntegrationServices Parameter use advanced parameter Validation? ' { + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for GuestIntegrationServices '{ + $function.Definition.Contains('.PARAMETER GuestIntegrationServices') | Should Be 'True' + } + It 'Has a Parameter called CustomData' { + $Function.Parameters.Keys.Contains('CustomData') | Should Be 'True' + } + It 'CustomData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CustomData.Attributes.Mandatory | Should be 'False' + } + It 'CustomData Parameter is of Hashtable Type' { + $Function.Parameters.CustomData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'CustomData Parameter is member of ParameterSets' { + [String]$Function.Parameters.CustomData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CustomData Parameter Position is defined correctly' { + [String]$Function.Parameters.CustomData.Attributes.Position | Should be '-2147483648' + } + It 'Does CustomData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CustomData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CustomData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CustomData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CustomData Parameter use advanced parameter Validation? ' { + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CustomData '{ + $function.Definition.Contains('.PARAMETER CustomData') | Should Be 'True' + } + It 'Has a Parameter called NoSnapshot' { + $Function.Parameters.Keys.Contains('NoSnapshot') | Should Be 'True' + } + It 'NoSnapshot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.NoSnapshot.Attributes.Mandatory | Should be 'False' + } + It 'NoSnapshot Parameter is of SwitchParameter Type' { + $Function.Parameters.NoSnapshot.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'NoSnapshot Parameter is member of ParameterSets' { + [String]$Function.Parameters.NoSnapshot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NoSnapshot Parameter Position is defined correctly' { + [String]$Function.Parameters.NoSnapshot.Attributes.Position | Should be '-2147483648' + } + It 'Does NoSnapshot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NoSnapshot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does NoSnapshot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NoSnapshot.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does NoSnapshot Parameter use advanced parameter Validation? ' { + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NoSnapshot '{ + $function.Definition.Contains('.PARAMETER NoSnapshot') | Should Be 'True' + } + It 'Has a Parameter called MediaId' { + $Function.Parameters.Keys.Contains('MediaId') | Should Be 'True' + } + It 'MediaId Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MediaId.Attributes.Mandatory | Should be 'True' + } + It 'MediaId Parameter is of String Type' { + $Function.Parameters.MediaId.ParameterType.FullName | Should be 'System.String' + } + It 'MediaId Parameter is member of ParameterSets' { + [String]$Function.Parameters.MediaId.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MediaId Parameter Position is defined correctly' { + [String]$Function.Parameters.MediaId.Attributes.Position | Should be '-2147483648' + } + It 'Does MediaId Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MediaId.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MediaId Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MediaId.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does MediaId Parameter use advanced parameter Validation? ' { + $Function.Parameters.MediaId.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MediaId.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MediaId.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MediaId.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MediaId.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MediaId '{ + $function.Definition.Contains('.PARAMETER MediaId') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Register/Register-LabMedia.ps1 b/Public/Register/Register-LabMedia.ps1 new file mode 100644 index 00000000..12fe8da3 --- /dev/null +++ b/Public/Register/Register-LabMedia.ps1 @@ -0,0 +1,146 @@ +function Register-LabMedia { + +<# + .SYNOPSIS + Registers a custom media entry. + .DESCRIPTION + The Register-LabMedia cmdlet allows adding custom media to the host's configuration. This circumvents the requirement of having to define custom media entries in the DSC configuration document (.psd1). + + You can use the Register-LabMedia cmdlet to override the default media entries, e.g. you have the media hosted internally or you wish to replace the built-in media with your own implementation. + + To override a built-in media entry, specify the same media Id with the -Force switch. + .LINK + Get-LabMedia + Unregister-LabMedia +#> + [CmdletBinding()] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')] + param ( + ## Specifies the media Id to register. You can override the built-in media if required. + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [System.String] $Id, + + ## Specifies the media's type. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateSet('VHD','ISO','WIM')] + [System.String] $MediaType, + + ## Specifies the source Uri (http/https/file) of the media. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.Uri] $Uri, + + ## Specifies the architecture of the media. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [ValidateSet('x64','x86')] + [System.String] $Architecture, + + ## Specifies a description of the media. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Description, + + ## Specifies the image name containing the target WIM image. You can specify integer values. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ImageName, + + ## Specifies the local filename of the locally cached resource file. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Filename, + + ## Specifies the MD5 checksum of the resource file. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Checksum, + + ## Specifies custom data for the media. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.Collections.Hashtable] $CustomData, + + ## Specifies additional Windows hotfixes to install post deployment. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.Collections.Hashtable[]] $Hotfixes, + + ## Specifies the media type. Linux VHD(X)s do not inject resources. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet('Windows','Linux')] + [System.String] $OperatingSystem = 'Windows', + + ## Specifies that an exiting media entry should be overwritten. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force + ) + process { + + ## Validate Linux VM media type is VHD + if (($OperatingSystem -eq 'Linux') -and ($MediaType -ne 'VHD')) { + + throw ($localized.InvalidOSMediaTypeError -f $MediaType, $OperatingSystem); + } + + ## Validate ImageName when media type is ISO/WIM + if (($MediaType -eq 'ISO') -or ($MediaType -eq 'WIM')) { + + if (-not $PSBoundParameters.ContainsKey('ImageName')) { + + throw ($localized.ImageNameRequiredError -f '-ImageName'); + } + } + + ## Resolve the media Id to see if it's already been used + $media = ResolveLabMedia -Id $Id -ErrorAction SilentlyContinue; + if ($media -and (-not $Force)) { + + throw ($localized.MediaAlreadyRegisteredError -f $Id, '-Force'); + } + + ## Get the custom media list (not the built in media) + $existingCustomMedia = @(GetConfigurationData -Configuration CustomMedia); + if (-not $existingCustomMedia) { + + $existingCustomMedia = @(); + } + + $customMedia = [PSCustomObject] @{ + Id = $Id; + Filename = $Filename; + Description = $Description; + Architecture = $Architecture; + ImageName = $ImageName; + MediaType = $MediaType; + OperatingSystem = $OperatingSystem; + Uri = $Uri; + Checksum = $Checksum; + CustomData = $CustomData; + Hotfixes = $Hotfixes; + } + + $hasExistingMediaEntry = $false; + for ($i = 0; $i -lt $existingCustomMedia.Count; $i++) { + + if ($existingCustomMedia[$i].Id -eq $Id) { + + WriteVerbose ($localized.OverwritingCustomMediaEntry -f $Id); + $hasExistingMediaEntry = $true; + $existingCustomMedia[$i] = $customMedia; + } + } + + if (-not $hasExistingMediaEntry) { + + ## Add it to the array + WriteVerbose ($localized.AddingCustomMediaEntry -f $Id); + $existingCustomMedia += $customMedia; + } + + WriteVerbose ($localized.SavingConfiguration -f $Id); + SetConfigurationData -Configuration CustomMedia -InputObject @($existingCustomMedia); + return $customMedia; + + } #end process + +} + diff --git a/Public/Register/Tests/Register-LabMedia.Functional.Tests.ps1 b/Public/Register/Tests/Register-LabMedia.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Register/Tests/Register-LabMedia.Tests.ps1 b/Public/Register/Tests/Register-LabMedia.Tests.ps1 new file mode 100644 index 00000000..440aebe9 --- /dev/null +++ b/Public/Register/Tests/Register-LabMedia.Tests.ps1 @@ -0,0 +1,407 @@ +Describe 'Register-LabMedia Tests' { + + Context 'Parameters for Register-LabMedia'{ + + It 'Has a Parameter called Id' { + $Function.Parameters.Keys.Contains('Id') | Should Be 'True' + } + It 'Id Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Id.Attributes.Mandatory | Should be 'True' + } + It 'Id Parameter is of String Type' { + $Function.Parameters.Id.ParameterType.FullName | Should be 'System.String' + } + It 'Id Parameter is member of ParameterSets' { + [String]$Function.Parameters.Id.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Id Parameter Position is defined correctly' { + [String]$Function.Parameters.Id.Attributes.Position | Should be '0' + } + It 'Does Id Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Id Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Id Parameter use advanced parameter Validation? ' { + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Id '{ + $function.Definition.Contains('.PARAMETER Id') | Should Be 'True' + } + It 'Has a Parameter called MediaType' { + $Function.Parameters.Keys.Contains('MediaType') | Should Be 'True' + } + It 'MediaType Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.MediaType.Attributes.Mandatory | Should be 'True' + } + It 'MediaType Parameter is of String Type' { + $Function.Parameters.MediaType.ParameterType.FullName | Should be 'System.String' + } + It 'MediaType Parameter is member of ParameterSets' { + [String]$Function.Parameters.MediaType.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MediaType Parameter Position is defined correctly' { + [String]$Function.Parameters.MediaType.Attributes.Position | Should be '1' + } + It 'Does MediaType Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MediaType.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MediaType Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MediaType.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MediaType Parameter use advanced parameter Validation? ' { + $Function.Parameters.MediaType.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MediaType.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MediaType.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MediaType.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.MediaType.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MediaType '{ + $function.Definition.Contains('.PARAMETER MediaType') | Should Be 'True' + } + It 'Has a Parameter called Uri' { + $Function.Parameters.Keys.Contains('Uri') | Should Be 'True' + } + It 'Uri Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Uri.Attributes.Mandatory | Should be 'True' + } + It 'Uri Parameter is of Uri Type' { + $Function.Parameters.Uri.ParameterType.FullName | Should be 'System.Uri' + } + It 'Uri Parameter is member of ParameterSets' { + [String]$Function.Parameters.Uri.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Uri Parameter Position is defined correctly' { + [String]$Function.Parameters.Uri.Attributes.Position | Should be '2' + } + It 'Does Uri Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Uri Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Uri.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Uri Parameter use advanced parameter Validation? ' { + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Uri.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Uri '{ + $function.Definition.Contains('.PARAMETER Uri') | Should Be 'True' + } + It 'Has a Parameter called Architecture' { + $Function.Parameters.Keys.Contains('Architecture') | Should Be 'True' + } + It 'Architecture Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Architecture.Attributes.Mandatory | Should be 'True' + } + It 'Architecture Parameter is of String Type' { + $Function.Parameters.Architecture.ParameterType.FullName | Should be 'System.String' + } + It 'Architecture Parameter is member of ParameterSets' { + [String]$Function.Parameters.Architecture.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Architecture Parameter Position is defined correctly' { + [String]$Function.Parameters.Architecture.Attributes.Position | Should be '3' + } + It 'Does Architecture Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Architecture.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Architecture Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Architecture.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Architecture Parameter use advanced parameter Validation? ' { + $Function.Parameters.Architecture.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Architecture.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Architecture.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Architecture.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Architecture.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Architecture '{ + $function.Definition.Contains('.PARAMETER Architecture') | Should Be 'True' + } + It 'Has a Parameter called Description' { + $Function.Parameters.Keys.Contains('Description') | Should Be 'True' + } + It 'Description Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Description.Attributes.Mandatory | Should be 'False' + } + It 'Description Parameter is of String Type' { + $Function.Parameters.Description.ParameterType.FullName | Should be 'System.String' + } + It 'Description Parameter is member of ParameterSets' { + [String]$Function.Parameters.Description.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Description Parameter Position is defined correctly' { + [String]$Function.Parameters.Description.Attributes.Position | Should be '4' + } + It 'Does Description Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Description.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Description Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Description.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Description Parameter use advanced parameter Validation? ' { + $Function.Parameters.Description.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Description.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Description.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Description.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Description.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Description '{ + $function.Definition.Contains('.PARAMETER Description') | Should Be 'True' + } + It 'Has a Parameter called ImageName' { + $Function.Parameters.Keys.Contains('ImageName') | Should Be 'True' + } + It 'ImageName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ImageName.Attributes.Mandatory | Should be 'False' + } + It 'ImageName Parameter is of String Type' { + $Function.Parameters.ImageName.ParameterType.FullName | Should be 'System.String' + } + It 'ImageName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ImageName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ImageName Parameter Position is defined correctly' { + [String]$Function.Parameters.ImageName.Attributes.Position | Should be '5' + } + It 'Does ImageName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ImageName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ImageName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ImageName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ImageName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ImageName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ImageName '{ + $function.Definition.Contains('.PARAMETER ImageName') | Should Be 'True' + } + It 'Has a Parameter called Filename' { + $Function.Parameters.Keys.Contains('Filename') | Should Be 'True' + } + It 'Filename Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Filename.Attributes.Mandatory | Should be 'False' + } + It 'Filename Parameter is of String Type' { + $Function.Parameters.Filename.ParameterType.FullName | Should be 'System.String' + } + It 'Filename Parameter is member of ParameterSets' { + [String]$Function.Parameters.Filename.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Filename Parameter Position is defined correctly' { + [String]$Function.Parameters.Filename.Attributes.Position | Should be '6' + } + It 'Does Filename Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Filename.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Filename Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Filename.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Filename Parameter use advanced parameter Validation? ' { + $Function.Parameters.Filename.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Filename.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Filename.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Filename.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Filename.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Filename '{ + $function.Definition.Contains('.PARAMETER Filename') | Should Be 'True' + } + It 'Has a Parameter called Checksum' { + $Function.Parameters.Keys.Contains('Checksum') | Should Be 'True' + } + It 'Checksum Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Checksum.Attributes.Mandatory | Should be 'False' + } + It 'Checksum Parameter is of String Type' { + $Function.Parameters.Checksum.ParameterType.FullName | Should be 'System.String' + } + It 'Checksum Parameter is member of ParameterSets' { + [String]$Function.Parameters.Checksum.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Checksum Parameter Position is defined correctly' { + [String]$Function.Parameters.Checksum.Attributes.Position | Should be '7' + } + It 'Does Checksum Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Checksum Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Checksum.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Checksum Parameter use advanced parameter Validation? ' { + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Checksum.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Checksum '{ + $function.Definition.Contains('.PARAMETER Checksum') | Should Be 'True' + } + It 'Has a Parameter called CustomData' { + $Function.Parameters.Keys.Contains('CustomData') | Should Be 'True' + } + It 'CustomData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CustomData.Attributes.Mandatory | Should be 'False' + } + It 'CustomData Parameter is of Hashtable Type' { + $Function.Parameters.CustomData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'CustomData Parameter is member of ParameterSets' { + [String]$Function.Parameters.CustomData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CustomData Parameter Position is defined correctly' { + [String]$Function.Parameters.CustomData.Attributes.Position | Should be '8' + } + It 'Does CustomData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CustomData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CustomData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CustomData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CustomData Parameter use advanced parameter Validation? ' { + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CustomData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CustomData '{ + $function.Definition.Contains('.PARAMETER CustomData') | Should Be 'True' + } + It 'Has a Parameter called Hotfixes' { + $Function.Parameters.Keys.Contains('Hotfixes') | Should Be 'True' + } + It 'Hotfixes Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Hotfixes.Attributes.Mandatory | Should be 'False' + } + It 'Hotfixes Parameter is of Hashtable[] Type' { + $Function.Parameters.Hotfixes.ParameterType.FullName | Should be 'System.Collections.Hashtable[]' + } + It 'Hotfixes Parameter is member of ParameterSets' { + [String]$Function.Parameters.Hotfixes.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Hotfixes Parameter Position is defined correctly' { + [String]$Function.Parameters.Hotfixes.Attributes.Position | Should be '9' + } + It 'Does Hotfixes Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Hotfixes.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Hotfixes Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Hotfixes.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Hotfixes Parameter use advanced parameter Validation? ' { + $Function.Parameters.Hotfixes.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Hotfixes.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.Hotfixes.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Hotfixes.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Hotfixes.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Hotfixes '{ + $function.Definition.Contains('.PARAMETER Hotfixes') | Should Be 'True' + } + It 'Has a Parameter called OperatingSystem' { + $Function.Parameters.Keys.Contains('OperatingSystem') | Should Be 'True' + } + It 'OperatingSystem Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.OperatingSystem.Attributes.Mandatory | Should be 'False' + } + It 'OperatingSystem Parameter is of String Type' { + $Function.Parameters.OperatingSystem.ParameterType.FullName | Should be 'System.String' + } + It 'OperatingSystem Parameter is member of ParameterSets' { + [String]$Function.Parameters.OperatingSystem.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'OperatingSystem Parameter Position is defined correctly' { + [String]$Function.Parameters.OperatingSystem.Attributes.Position | Should be '10' + } + It 'Does OperatingSystem Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.OperatingSystem.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does OperatingSystem Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.OperatingSystem.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does OperatingSystem Parameter use advanced parameter Validation? ' { + $Function.Parameters.OperatingSystem.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.OperatingSystem.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.OperatingSystem.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.OperatingSystem.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.OperatingSystem.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for OperatingSystem '{ + $function.Definition.Contains('.PARAMETER OperatingSystem') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Remove/Remove-LabConfiguration.ps1 b/Public/Remove/Remove-LabConfiguration.ps1 new file mode 100644 index 00000000..2b41dddb --- /dev/null +++ b/Public/Remove/Remove-LabConfiguration.ps1 @@ -0,0 +1,57 @@ +function Remove-LabConfiguration { + +<# + .SYNOPSIS + Removes all VMs and associated snapshots of all nodes defined in a PowerShell DSC configuration document. + .DESCRIPTION + The Remove-LabConfiguration removes all virtual machines that have a corresponding NodeName defined in the + AllNode array of the PowerShell DSC configuration document. + + WARNING: ALL EXISTING VIRTUAL MACHINE DATA WILL BE LOST WHEN VIRTUAL MACHINES ARE REMOVED. + + By default, associated virtual machine switches are not removed as they may be used by other virtual + machines or lab configurations. If you wish to remove any virtual switche defined in the PowerShell DSC + configuration document, specify the -RemoveSwitch parameter. + .PARAMETER ConfigurationData + Specifies a PowerShell DSC configuration data hashtable or a path to an existing PowerShell DSC .psd1 + configuration document used to remove existing virtual machines. One virtual machine is removed per node + defined in the AllNodes array. + .PARAMETER RemoveSwitch + Specifies that any connected virtual switch should also be removed when the virtual machine is removed. + .LINK + about_ConfigurationData + Start-LabConfiguration +#> + [CmdletBinding(SupportsShouldProcess)] + param ( + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Include removal of virtual switch(es). By default virtual switches are not removed. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $RemoveSwitch + ) + process { + WriteVerbose $localized.StartedLabConfiguration; + $nodes = $ConfigurationData.AllNodes | Where-Object { $_.NodeName -ne '*' }; + $currentNodeCount = 0; + foreach ($node in $nodes) { + $currentNodeCount++; + $nodeProperties = ResolveLabVMProperties -NodeName $node.NodeName -ConfigurationData $ConfigurationData; + [System.Int16] $percentComplete = (($currentNodeCount / $nodes.Count) * 100) - 1; + $activity = $localized.ConfiguringNode -f $nodeProperties.NodeDisplayName; + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + ##TODO: Should this not ensure that VMs are powered off + if ($PSCmdlet.ShouldProcess($nodeProperties.NodeDisplayName, 'RemoveLabVM')) { + RemoveLabVM -Name $node.NodeName -ConfigurationData $ConfigurationData -RemoveSwitch:$RemoveSwitch -Confirm:$false; + } + } + Write-Progress -Id 42 -Activity $activity -Completed; + WriteVerbose $localized.FinishedLabConfiguration; + } #end process + +} + diff --git a/Public/Remove/Remove-LabVM.ps1 b/Public/Remove/Remove-LabVM.ps1 new file mode 100644 index 00000000..395995e3 --- /dev/null +++ b/Public/Remove/Remove-LabVM.ps1 @@ -0,0 +1,58 @@ +function Remove-LabVM { + +<# + .SYNOPSIS + Removes a bare-metal virtual machine and differencing VHD(X). + .DESCRIPTION + The Remove-LabVM cmdlet removes a virtual machine and it's VHD(X) file. +#> + [CmdletBinding(SupportsShouldProcess)] + param ( + ## Virtual machine name + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String[]] $Name, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + + $currentNodeCount = 0; + foreach ($vmName in $Name) { + + $shouldProcessMessage = $localized.PerformingOperationOnTarget -f 'Remove-LabVM', $vmName; + $verboseProcessMessage = GetFormattedMessage -Message ($localized.RemovingVM -f $vmName); + if ($PSCmdlet.ShouldProcess($verboseProcessMessage, $shouldProcessMessage, $localized.ShouldProcessWarning)) { + + $currentNodeCount++; + [System.Int32] $percentComplete = (($currentNodeCount / $Name.Count) * 100) - 1; + $activity = $localized.ConfiguringNode -f $vmName; + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + + ## Create a skeleton config data if one wasn't supplied + if (-not $PSBoundParameters.ContainsKey('ConfigurationData')) { + + $configurationData = @{ + AllNodes = @( + @{ NodeName = $vmName; } + ) + }; + } + + RemoveLabVM -Name $vmName -ConfigurationData $configurationData; + } #end if should process + } #end foreach VM + + if (-not [System.String]::IsNullOrEmpty($activity)) { + + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + } + + } #end process + +} + diff --git a/Public/Remove/Tests/Remove-LabConfiguration.Functional.Tests.ps1 b/Public/Remove/Tests/Remove-LabConfiguration.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Remove/Tests/Remove-LabConfiguration.Tests.ps1 b/Public/Remove/Tests/Remove-LabConfiguration.Tests.ps1 new file mode 100644 index 00000000..f31cb8b1 --- /dev/null +++ b/Public/Remove/Tests/Remove-LabConfiguration.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'Remove-LabConfiguration Tests' { + + Context 'Parameters for Remove-LabConfiguration'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called RemoveSwitch' { + $Function.Parameters.Keys.Contains('RemoveSwitch') | Should Be 'True' + } + It 'RemoveSwitch Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RemoveSwitch.Attributes.Mandatory | Should be 'False' + } + It 'RemoveSwitch Parameter is of SwitchParameter Type' { + $Function.Parameters.RemoveSwitch.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'RemoveSwitch Parameter is member of ParameterSets' { + [String]$Function.Parameters.RemoveSwitch.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RemoveSwitch Parameter Position is defined correctly' { + [String]$Function.Parameters.RemoveSwitch.Attributes.Position | Should be '-2147483648' + } + It 'Does RemoveSwitch Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RemoveSwitch.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RemoveSwitch Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RemoveSwitch.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RemoveSwitch Parameter use advanced parameter Validation? ' { + $Function.Parameters.RemoveSwitch.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RemoveSwitch.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RemoveSwitch.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RemoveSwitch.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RemoveSwitch.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RemoveSwitch '{ + $function.Definition.Contains('.PARAMETER RemoveSwitch') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Remove/Tests/Remove-LabVM.Functional.Tests.ps1 b/Public/Remove/Tests/Remove-LabVM.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Remove/Tests/Remove-LabVM.Tests.ps1 b/Public/Remove/Tests/Remove-LabVM.Tests.ps1 new file mode 100644 index 00000000..a68cd91f --- /dev/null +++ b/Public/Remove/Tests/Remove-LabVM.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'Remove-LabVM Tests' { + + Context 'Parameters for Remove-LabVM'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String[] Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String[]' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Reset/Reset-Lab.ps1 b/Public/Reset/Reset-Lab.ps1 new file mode 100644 index 00000000..06562f6e --- /dev/null +++ b/Public/Reset/Reset-Lab.ps1 @@ -0,0 +1,40 @@ +function Reset-Lab { + +<# + .SYNOPSIS + Reverts all VMs in a lab back to their initial configuration. + .DESCRIPTION + The Reset-Lab cmdlet will reset all the nodes defined in a PowerShell DSC configuration document, back to their + initial state. If virtual machines are powered on, they will automatically be powered off when restoring the + snapshot. + + When virtual machines are created - before they are powered on - a baseline snapshot is created. This snapshot + is taken before the Sysprep process has been run and/or any PowerShell DSC configuration has been applied. + + WARNING: You will lose all changes to all virtual machines that have not been committed via another snapshot. + .PARAMETER ConfigurationData + Specifies a PowerShell DSC configuration data hashtable or a path to an existing PowerShell DSC .psd1 + configuration document. + .LINK + Checkpoint-Lab + .NOTES + This cmdlet uses the baseline snapshot snapshot created by the Start-LabConfiguration cmdlet. If the baseline + was not created or the baseline snapshot does not exist, the lab VMs can be recreated with the + Start-LabConfiguration -Force. +#> + [CmdletBinding()] + param ( + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + ## Revert to Base/Lab snapshots... + $snapshotName = $localized.BaselineSnapshotName -f $labDefaults.ModuleName; + Restore-Lab -ConfigurationData $ConfigurationData -SnapshotName $snapshotName -Force; + } #end process + +} + diff --git a/Public/Reset/Reset-LabHostDefault.ps1 b/Public/Reset/Reset-LabHostDefault.ps1 new file mode 100644 index 00000000..247a7aa8 --- /dev/null +++ b/Public/Reset/Reset-LabHostDefault.ps1 @@ -0,0 +1,24 @@ +function Reset-LabHostDefault { + +<# + .SYNOPSIS + Resets lab host default settings to default. + .DESCRIPTION + The Reset-LabHostDefault cmdlet resets the lab host's settings to default values. + .LINK + Get-LabHostDefault + Set-LabHostDefault +#> + [CmdletBinding(SupportsShouldProcess)] + [OutputType([System.Management.Automation.PSCustomObject])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + param ( ) + process { + + RemoveConfigurationData -Configuration Host; + Get-LabHostDefault; + + } #end process + +} + diff --git a/Public/Reset/Reset-LabHostDefaults.ps1 b/Public/Reset/Reset-LabHostDefaults.ps1 new file mode 100644 index 00000000..bc420e8f --- /dev/null +++ b/Public/Reset/Reset-LabHostDefaults.ps1 @@ -0,0 +1,27 @@ +function Reset-LabHostDefaults { + +<# + .SYNOPSIS + Resets lab host default settings to default. + .DESCRIPTION + The Reset-LabHostDefault cmdlet resets the lab host's settings to default values. + .NOTES + Proxy function replacing alias to enable warning output. + .LINK + Get-LabHostDefault + Set-LabHostDefault +#> + [CmdletBinding(SupportsShouldProcess)] + [OutputType([System.Management.Automation.PSCustomObject])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + param ( ) + process { + + Write-Warning -Message ($localized.DeprecatedCommandWarning -f 'Reset-LabHostDefaults','Reset-LabHostDefault'); + Reset-LabHostDefault @PSBoundParameters; + + } #end process + +} + diff --git a/Public/Reset/Reset-LabMedia.ps1 b/Public/Reset/Reset-LabMedia.ps1 new file mode 100644 index 00000000..4a351dcc --- /dev/null +++ b/Public/Reset/Reset-LabMedia.ps1 @@ -0,0 +1,22 @@ +function Reset-LabMedia { + +<# + .SYNOPSIS + Reset the lab media entries to default settings. + .DESCRIPTION + The Reset-LabMedia removes all custom media entries, reverting them to default values. +#> + [CmdletBinding(SupportsShouldProcess)] + [OutputType([System.Management.Automation.PSCustomObject])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + param ( ) + process { + + RemoveConfigurationData -Configuration CustomMedia; + Get-Labmedia; + + } + +} + diff --git a/Public/Reset/Reset-LabVM.ps1 b/Public/Reset/Reset-LabVM.ps1 new file mode 100644 index 00000000..9cf1dec7 --- /dev/null +++ b/Public/Reset/Reset-LabVM.ps1 @@ -0,0 +1,82 @@ +function Reset-LabVM { + +<# + .SYNOPSIS + Recreates a lab virtual machine. + .DESCRIPTION + The Reset-LabVM cmdlet deletes and recreates a lab virtual machine, reapplying the MOF. + + To revert a single VM to a previous state, use the Restore-VMSnapshot cmdlet. To revert an entire lab environment, use the Restore-Lab cmdlet. +#> + [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'PSCredential')] + param ( + ## Specifies the lab virtual machine/node name. + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String[]] $Name, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Local administrator password of the virtual machine. The username is NOT used. + [Parameter(ParameterSetName = 'PSCredential', ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.Management.Automation.PSCredential] + [System.Management.Automation.CredentialAttribute()] + $Credential = (& $credentialCheckScriptBlock), + + ## Local administrator password of the virtual machine. + [Parameter(Mandatory, ParameterSetName = 'Password', ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.Security.SecureString] $Password, + + ## Directory path containing the virtual machines' .mof file(s). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Path = (GetLabHostDSCConfigurationPath), + + ## Skip creation of the initial baseline snapshot. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $NoSnapshot + ) + begin { + + ## If we have only a secure string, create a PSCredential + if ($PSCmdlet.ParameterSetName -eq 'Password') { + $Credential = New-Object -TypeName 'System.Management.Automation.PSCredential' -ArgumentList 'LocalAdministrator', $Password; + } + if (-not $Credential) { throw ($localized.CannotProcessCommandError -f 'Credential'); } + elseif ($Credential.Password.Length -eq 0) { throw ($localized.CannotBindArgumentError -f 'Password'); } + + } + process { + + $currentNodeCount = 0; + foreach ($vmName in $Name) { + + $shouldProcessMessage = $localized.PerformingOperationOnTarget -f 'Reset-LabVM', $vmName; + $verboseProcessMessage = GetFormattedMessage -Message ($localized.ResettingVM -f $vmName); + if ($PSCmdlet.ShouldProcess($verboseProcessMessage, $shouldProcessMessage, $localized.ShouldProcessWarning)) { + + $currentNodeCount++; + [System.Int32] $percentComplete = (($currentNodeCount / $Name.Count) * 100) - 1; + $activity = $localized.ConfiguringNode -f $vmName; + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + + RemoveLabVM -Name $vmName -ConfigurationData $ConfigurationData; + NewLabVM -Name $vmName -ConfigurationData $ConfigurationData -Path $Path -NoSnapshot:$NoSnapshot -Credential $Credential; + + } #end if should process + } #end foreach VMd + + if (-not [System.String]::IsNullOrEmpty($activity)) { + + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + } + + } #end process + +} + diff --git a/Public/Reset/Reset-LabVMDefault.ps1 b/Public/Reset/Reset-LabVMDefault.ps1 new file mode 100644 index 00000000..4d60eb54 --- /dev/null +++ b/Public/Reset/Reset-LabVMDefault.ps1 @@ -0,0 +1,19 @@ +function Reset-LabVMDefault { + +<# + .SYNOPSIS + Reset the current lab virtual machine default settings back to defaults. +#> + [CmdletBinding(SupportsShouldProcess)] + [OutputType([System.Management.Automation.PSCustomObject])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + param ( ) + process { + + RemoveConfigurationData -Configuration VM; + Get-LabVMDefault; + + } + +} + diff --git a/Public/Reset/Reset-LabVMDefaults.ps1 b/Public/Reset/Reset-LabVMDefaults.ps1 new file mode 100644 index 00000000..c8d9605b --- /dev/null +++ b/Public/Reset/Reset-LabVMDefaults.ps1 @@ -0,0 +1,22 @@ +function Reset-LabVMDefaults { + +<# + .SYNOPSIS + Reset the current lab virtual machine default settings back to defaults. + .NOTES + Proxy function replacing alias to enable warning output. +#> + [CmdletBinding(SupportsShouldProcess)] + [OutputType([System.Management.Automation.PSCustomObject])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + param ( ) + process { + + Write-Warning -Message ($localized.DeprecatedCommandWarning -f 'Reset-LabVMDefaults','Reset-LabVMDefault'); + Reset-LabVMDefault @PSBoundParameters; + + } + +} + diff --git a/Public/Reset/Tests/Reset-Lab.Functional.Tests.ps1 b/Public/Reset/Tests/Reset-Lab.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Reset/Tests/Reset-Lab.Tests.ps1 b/Public/Reset/Tests/Reset-Lab.Tests.ps1 new file mode 100644 index 00000000..bf144e42 --- /dev/null +++ b/Public/Reset/Tests/Reset-Lab.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'Reset-Lab Tests' { + + Context 'Parameters for Reset-Lab'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Reset/Tests/Reset-LabHostDefault.Functional.Tests.ps1 b/Public/Reset/Tests/Reset-LabHostDefault.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Reset/Tests/Reset-LabHostDefault.Tests.ps1 b/Public/Reset/Tests/Reset-LabHostDefault.Tests.ps1 new file mode 100644 index 00000000..241598b5 --- /dev/null +++ b/Public/Reset/Tests/Reset-LabHostDefault.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'Reset-LabHostDefault Tests' { + + Context 'Parameters for Reset-LabHostDefault'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Reset/Tests/Reset-LabHostDefaults.Functional.Tests.ps1 b/Public/Reset/Tests/Reset-LabHostDefaults.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Reset/Tests/Reset-LabHostDefaults.Tests.ps1 b/Public/Reset/Tests/Reset-LabHostDefaults.Tests.ps1 new file mode 100644 index 00000000..bea40b7f --- /dev/null +++ b/Public/Reset/Tests/Reset-LabHostDefaults.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'Reset-LabHostDefaults Tests' { + + Context 'Parameters for Reset-LabHostDefaults'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Reset/Tests/Reset-LabMedia.Functional.Tests.ps1 b/Public/Reset/Tests/Reset-LabMedia.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Reset/Tests/Reset-LabMedia.Tests.ps1 b/Public/Reset/Tests/Reset-LabMedia.Tests.ps1 new file mode 100644 index 00000000..e5e478e2 --- /dev/null +++ b/Public/Reset/Tests/Reset-LabMedia.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'Reset-LabMedia Tests' { + + Context 'Parameters for Reset-LabMedia'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Reset/Tests/Reset-LabVM.Functional.Tests.ps1 b/Public/Reset/Tests/Reset-LabVM.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Reset/Tests/Reset-LabVM.Tests.ps1 b/Public/Reset/Tests/Reset-LabVM.Tests.ps1 new file mode 100644 index 00000000..cf033160 --- /dev/null +++ b/Public/Reset/Tests/Reset-LabVM.Tests.ps1 @@ -0,0 +1,221 @@ +Describe 'Reset-LabVM Tests' { + + Context 'Parameters for Reset-LabVM'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'True' + } + It 'Name Parameter is of String[] Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String[]' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '-2147483648' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '-2147483648' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called Credential' { + $Function.Parameters.Keys.Contains('Credential') | Should Be 'True' + } + It 'Credential Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Credential.Attributes.Mandatory | Should be 'False' + } + It 'Credential Parameter is of PSCredential Type' { + $Function.Parameters.Credential.ParameterType.FullName | Should be 'System.Management.Automation.PSCredential' + } + It 'Credential Parameter is member of ParameterSets' { + [String]$Function.Parameters.Credential.ParameterSets.Keys | Should Be 'PSCredential' + } + It 'Credential Parameter Position is defined correctly' { + [String]$Function.Parameters.Credential.Attributes.Position | Should be '-2147483648' + } + It 'Does Credential Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Credential Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Credential Parameter use advanced parameter Validation? ' { + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Credential '{ + $function.Definition.Contains('.PARAMETER Credential') | Should Be 'True' + } + It 'Has a Parameter called Password' { + $Function.Parameters.Keys.Contains('Password') | Should Be 'True' + } + It 'Password Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Password.Attributes.Mandatory | Should be 'True' + } + It 'Password Parameter is of SecureString Type' { + $Function.Parameters.Password.ParameterType.FullName | Should be 'System.Security.SecureString' + } + It 'Password Parameter is member of ParameterSets' { + [String]$Function.Parameters.Password.ParameterSets.Keys | Should Be 'Password' + } + It 'Password Parameter Position is defined correctly' { + [String]$Function.Parameters.Password.Attributes.Position | Should be '-2147483648' + } + It 'Does Password Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Password.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Password Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Password.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Password Parameter use advanced parameter Validation? ' { + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Password '{ + $function.Definition.Contains('.PARAMETER Password') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'False' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '-2147483648' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called NoSnapshot' { + $Function.Parameters.Keys.Contains('NoSnapshot') | Should Be 'True' + } + It 'NoSnapshot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.NoSnapshot.Attributes.Mandatory | Should be 'False' + } + It 'NoSnapshot Parameter is of SwitchParameter Type' { + $Function.Parameters.NoSnapshot.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'NoSnapshot Parameter is member of ParameterSets' { + [String]$Function.Parameters.NoSnapshot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NoSnapshot Parameter Position is defined correctly' { + [String]$Function.Parameters.NoSnapshot.Attributes.Position | Should be '-2147483648' + } + It 'Does NoSnapshot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NoSnapshot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does NoSnapshot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NoSnapshot.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does NoSnapshot Parameter use advanced parameter Validation? ' { + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NoSnapshot '{ + $function.Definition.Contains('.PARAMETER NoSnapshot') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Reset/Tests/Reset-LabVMDefault.Functional.Tests.ps1 b/Public/Reset/Tests/Reset-LabVMDefault.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Reset/Tests/Reset-LabVMDefault.Tests.ps1 b/Public/Reset/Tests/Reset-LabVMDefault.Tests.ps1 new file mode 100644 index 00000000..ed9c903c --- /dev/null +++ b/Public/Reset/Tests/Reset-LabVMDefault.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'Reset-LabVMDefault Tests' { + + Context 'Parameters for Reset-LabVMDefault'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Reset/Tests/Reset-LabVMDefaults.Functional.Tests.ps1 b/Public/Reset/Tests/Reset-LabVMDefaults.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Reset/Tests/Reset-LabVMDefaults.Tests.ps1 b/Public/Reset/Tests/Reset-LabVMDefaults.Tests.ps1 new file mode 100644 index 00000000..51826c15 --- /dev/null +++ b/Public/Reset/Tests/Reset-LabVMDefaults.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'Reset-LabVMDefaults Tests' { + + Context 'Parameters for Reset-LabVMDefaults'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Restore/Restore-Lab.ps1 b/Public/Restore/Restore-Lab.ps1 new file mode 100644 index 00000000..a97ca940 --- /dev/null +++ b/Public/Restore/Restore-Lab.ps1 @@ -0,0 +1,89 @@ +function Restore-Lab { + +<# + .SYNOPSIS + Restores all lab VMs to a previous configuration. + .DESCRIPTION + The Restore-Lab reverts all the nodes defined in a PowerShell DSC configuration document, back to a + previously captured configuration. + + When creating the snapshots, they are created using a snapshot name. To restore a lab to a previous + configuration, you must supply the same snapshot name. + + All virtual machines should be powered off when the snapshots are restored. If VMs are powered on, + an error will be generated. You can override this behaviour by specifying the -Force parameter. + + WARNING: If the -Force parameter is used, running virtual machines will be powered off automatically. + .PARAMETER ConfigurationData + Specifies a PowerShell DSC configuration data hashtable or a path to an existing PowerShell DSC .psd1 + configuration document. + .PARAMETER SnapshotName + Specifies the virtual machine snapshot name to be restored. You must use the same snapshot name used when + creating the snapshot with the Checkpoint-Lab cmdlet. + .PARAMETER Force + Forces virtual machine snapshots to be restored - even if there are any running virtual machines. + .LINK + Checkpoint-Lab + Reset-Lab +#> + [CmdletBinding()] + param ( + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Snapshot name + [Parameter(Mandatory)] [Alias('Name')] + [System.String] $SnapshotName, + + ## Force snapshots if virtual machines are on + [System.Management.Automation.SwitchParameter] $Force + ) + process { + $nodes = @(); + $ConfigurationData.AllNodes | + Where-Object { $_.NodeName -ne '*' } | + ForEach-Object { + $nodes += ResolveLabVMProperties -NodeName $_.NodeName -ConfigurationData $ConfigurationData; + }; + $runningNodes = $nodes | ForEach-Object { + Get-VM -Name $_.NodeDisplayName } | + Where-Object { $_.State -ne 'Off' } + + $currentNodeCount = 0; + if ($runningNodes -and $Force) { + $nodes | Sort-Object { $_.BootOrder } | + ForEach-Object { + $currentNodeCount++; + [System.Int32] $percentComplete = ($currentNodeCount / $nodes.Count) * 100; + $activity = $localized.ConfiguringNode -f $_.NodeDisplayName; + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + WriteVerbose ($localized.RestoringVirtualMachineSnapshot -f $_.NodeDisplayName, $SnapshotName); + + GetLabVMSnapshot -Name $_.NodeDisplayName -SnapshotName $SnapshotName | Restore-VMSnapshot; + } + } + elseif ($runningNodes) { + foreach ($runningNode in $runningNodes) { + Write-Error -Message ($localized.CannotSnapshotNodeError -f $runningNode.NodeDisplayName); + } + } + else { + $nodes | Sort-Object { $_.BootOrder } | + ForEach-Object { + $currentNodeCount++; + [System.Int32] $percentComplete = ($currentNodeCount / $nodes.Count) * 100; + $activity = $localized.ConfiguringNode -f $_.NodeDisplayName; + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + WriteVerbose ($localized.RestoringVirtualMachineSnapshot -f $_.NodeDisplayName, $SnapshotName); + + GetLabVMSnapshot -Name $_.NodeDisplayName -SnapshotName $SnapshotName | Restore-VMSnapshot -Confirm:$false; + } + } + Write-Progress -Id 42 -Activity $activity -Completed; + } #end process + +} + diff --git a/Public/Restore/Tests/Restore-Lab.Functional.Tests.ps1 b/Public/Restore/Tests/Restore-Lab.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Restore/Tests/Restore-Lab.Tests.ps1 b/Public/Restore/Tests/Restore-Lab.Tests.ps1 new file mode 100644 index 00000000..538e79b5 --- /dev/null +++ b/Public/Restore/Tests/Restore-Lab.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'Restore-Lab Tests' { + + Context 'Parameters for Restore-Lab'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called SnapshotName' { + $Function.Parameters.Keys.Contains('SnapshotName') | Should Be 'True' + } + It 'SnapshotName Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.SnapshotName.Attributes.Mandatory | Should be 'True' + } + It 'SnapshotName Parameter is of String Type' { + $Function.Parameters.SnapshotName.ParameterType.FullName | Should be 'System.String' + } + It 'SnapshotName Parameter is member of ParameterSets' { + [String]$Function.Parameters.SnapshotName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SnapshotName Parameter Position is defined correctly' { + [String]$Function.Parameters.SnapshotName.Attributes.Position | Should be '1' + } + It 'Does SnapshotName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SnapshotName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SnapshotName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SnapshotName.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does SnapshotName Parameter use advanced parameter Validation? ' { + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SnapshotName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SnapshotName '{ + $function.Definition.Contains('.PARAMETER SnapshotName') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Set/Set-LabHostDefault.ps1 b/Public/Set/Set-LabHostDefault.ps1 new file mode 100644 index 00000000..e89140f1 --- /dev/null +++ b/Public/Set/Set-LabHostDefault.ps1 @@ -0,0 +1,122 @@ +function Set-LabHostDefault { + +<# + .SYNOPSIS + Sets the lab host's default settings. + .DESCRIPTION + The Set-LabHostDefault cmdlet sets one or more lab host default settings. + .LINK + Get-LabHostDefault + Reset-LabHostDefault +#> + [CmdletBinding(SupportsShouldProcess)] + [OutputType([System.Management.Automation.PSCustomObject])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + param ( + ## Lab host .mof configuration document search path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ConfigurationPath, + + ## Lab host Media/ISO storage location/path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $IsoPath, + + ## Lab host parent/master VHD(X) storage location/path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ParentVhdPath, + + ## Lab host virtual machine differencing VHD(X) storage location/path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $DifferencingVhdPath, + + ## Lab module storage location/path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ModuleCachePath, + + ## Lab custom resource storage location/path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ResourcePath, + + ## Lab host DSC resource share name (for SMB Pull Server). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ResourceShareName, + + ## Lab host media hotfix storage location/path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $HotfixPath, + + ## Disable local caching of file-based ISO and WIM files. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $DisableLocalFileCaching, + + ## Enable call stack logging in verbose output + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $EnableCallStackLogging, + + ## Custom DISM/ADK path + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $DismPath + ) + process { + + $hostDefaults = GetConfigurationData -Configuration Host; + + $resolvablePaths = @( + 'IsoPath', + 'ParentVhdPath', + 'DifferencingVhdPath', + 'ResourcePath', + 'HotfixPath', + 'UpdatePath', + 'ConfigurationPath', + 'ModuleCachePath' + ) + foreach ($path in $resolvablePaths) { + if ($PSBoundParameters.ContainsKey($path)) { + $resolvedPath = ResolvePathEx -Path $PSBoundParameters[$path]; + if (-not ((Test-Path -Path $resolvedPath -PathType Container -IsValid) -and (Test-Path -Path (Split-Path -Path $resolvedPath -Qualifier))) ) { + throw ($localized.InvalidPathError -f $resolvedPath, $PSBoundParameters[$path]); + } + else { + $hostDefaults.$path = $resolvedPath.Trim('\'); + } + } + } + + if ($PSBoundParameters.ContainsKey('ResourceShareName')) { + + $hostDefaults.ResourceShareName = $ResourceShareName; + } + if ($PSBoundParameters.ContainsKey('DisableLocalFileCaching')) { + + $hostDefaults.DisableLocalFileCaching = $DisableLocalFileCaching.ToBool(); + } + if ($PSBoundParameters.ContainsKey('EnableCallStackLogging')) { + + ## Set the global script variable read by WriteVerbose + $script:labDefaults.CallStackLogging = $EnableCallStackLogging; + $hostDefaults.EnableCallStackLogging = $EnableCallStackLogging.ToBool(); + } + if ($PSBoundParameters.ContainsKey('DismPath')) { + + $hostDefaults.DismPath = ResolveDismPath -Path $DismPath; + WriteWarning -Message ($localized.DismSessionRestartWarning); + } + + SetConfigurationData -Configuration Host -InputObject $hostDefaults; + ImportDismModule; + + return $hostDefaults; + + } #end process + +} + diff --git a/Public/Set/Set-LabHostDefaults.ps1 b/Public/Set/Set-LabHostDefaults.ps1 new file mode 100644 index 00000000..e2e57484 --- /dev/null +++ b/Public/Set/Set-LabHostDefaults.ps1 @@ -0,0 +1,79 @@ +function Set-LabHostDefaults { + +<# + .SYNOPSIS + Sets the lab host's default settings. + .DESCRIPTION + The Set-LabHostDefault cmdlet sets one or more lab host default settings. + .NOTES + Proxy function replacing alias to enable warning output. + .LINK + Get-LabHostDefault + Reset-LabHostDefault +#> + [CmdletBinding(SupportsShouldProcess)] + [OutputType([System.Management.Automation.PSCustomObject])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + param ( + ## Lab host .mof configuration document search path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ConfigurationPath, + + ## Lab host Media/ISO storage location/path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $IsoPath, + + ## Lab host parent/master VHD(X) storage location/path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ParentVhdPath, + + ## Lab host virtual machine differencing VHD(X) storage location/path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $DifferencingVhdPath, + + ## Lab module storage location/path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ModuleCachePath, + + ## Lab custom resource storage location/path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ResourcePath, + + ## Lab host DSC resource share name (for SMB Pull Server). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ResourceShareName, + + ## Lab host media hotfix storage location/path. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $HotfixPath, + + ## Disable local caching of file-based ISO and WIM files. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $DisableLocalFileCaching, + + ## Enable call stack logging in verbose output + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $EnableCallStackLogging, + + ## Custom DISM/ADK path + [Parameter(ValueFromPipelineByPropertyName)] + [System.String] $DismPath + ) + process { + + Write-Warning -Message ($localized.DeprecatedCommandWarning -f 'Set-LabHostDefaults','Set-LabHostDefault'); + Set-LabHostDefault @PSBoundParameters; + + } + +} + diff --git a/Public/Set/Set-LabVMDefault.ps1 b/Public/Set/Set-LabVMDefault.ps1 new file mode 100644 index 00000000..60b33188 --- /dev/null +++ b/Public/Set/Set-LabVMDefault.ps1 @@ -0,0 +1,198 @@ +function Set-LabVMDefault { + +<# + .SYNOPSIS + Sets the lab virtual machine default settings. +#> + [CmdletBinding(SupportsShouldProcess)] + [OutputType([System.Management.Automation.PSCustomObject])] + param ( + ## Default virtual machine startup memory (bytes). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateRange(536870912, 1099511627776)] + [System.Int64] $StartupMemory, + + ## Default virtual machine miniumum dynamic memory allocation (bytes). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateRange(536870912, 1099511627776)] + [System.Int64] $MinimumMemory, + + ## Default virtual machine maximum dynamic memory allocation (bytes). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateRange(536870912, 1099511627776)] + [System.Int64] $MaximumMemory, + + ## Default virtual machine processor count. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateRange(1, 4)] + [System.Int32] $ProcessorCount, + + ## Default virtual machine media Id. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Media, + + ## Lab host internal switch name. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $SwitchName, + + # Input Locale + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^([a-z]{2,2}-[a-z]{2,2})|(\d{4,4}:\d{8,8})$')] + [System.String] $InputLocale, + + # System Locale + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^[a-z]{2,2}-[a-z]{2,2}$')] + [System.String] $SystemLocale, + + # User Locale + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^[a-z]{2,2}-[a-z]{2,2}$')] + [System.String] $UserLocale, + + # UI Language + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^[a-z]{2,2}-[a-z]{2,2}$')] + [System.String] $UILanguage, + + # Timezone + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Timezone, + + # Registered Owner + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $RegisteredOwner, + + # Registered Organization + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] [Alias('RegisteredOrganisation')] $RegisteredOrganization, + + ## Client PFX certificate bundle used to encrypt DSC credentials + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.String] $ClientCertificatePath, + + ## Client certificate's issuing Root Certificate Authority (CA) certificate + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.String] $RootCertificatePath, + + ## Boot delay/pause between VM operations + [Parameter(ValueFromPipelineByPropertyName)] + [System.UInt16] $BootDelay, + + ## Secure boot status. Could be a SwitchParameter but boolean is more explicit? + [Parameter(ValueFromPipelineByPropertyName)] + [System.Boolean] $SecureBoot, + + ## Custom bootstrap order + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet('ConfigurationFirst','ConfigurationOnly','Disabled','MediaFirst','MediaOnly')] + [System.String] $CustomBootstrapOrder = 'MediaFirst', + + ## Enable Guest Integration Services + [Parameter(ValueFromPipelineByPropertyName)] + [System.Boolean] $GuestIntegrationServices + ) + process { + + $vmDefaults = GetConfigurationData -Configuration VM; + + if ($PSBoundParameters.ContainsKey('StartupMemory')) { + $vmDefaults.StartupMemory = $StartupMemory; + } + if ($PSBoundParameters.ContainsKey('MinimumMemory')) { + $vmDefaults.MinimumMemory = $MinimumMemory; + } + if ($PSBoundParameters.ContainsKey('MaximumMemory')) { + $vmDefaults.MaximumMemory = $MaximumMemory; + } + if ($PSBoundParameters.ContainsKey('ProcessorCount')) { + $vmDefaults.ProcessorCount = $ProcessorCount; + } + if ($PSBoundParameters.ContainsKey('Media')) { + ## ResolveLabMedia will throw if media cannot be resolved + $labMedia = ResolveLabMedia -Id $Media; + $vmDefaults.Media = $labMedia.Id; + } + if ($PSBoundParameters.ContainsKey('SwitchName')) { + $vmDefaults.SwitchName = $SwitchName; + } + if ($PSBoundParameters.ContainsKey('Timezone')) { + $vmDefaults.Timezone = ValidateTimeZone -TimeZone $Timezone; + } + if ($PSBoundParameters.ContainsKey('UILanguage')) { + $vmDefaults.UILanguage = $UILanguage; + } + if ($PSBoundParameters.ContainsKey('InputLocale')) { + $vmDefaults.InputLocale = $InputLocale; + } + if ($PSBoundParameters.ContainsKey('SystemLocale')) { + $vmDefaults.SystemLocale = $SystemLocale; + } + if ($PSBoundParameters.ContainsKey('UserLocale')) { + $vmDefaults.UserLocale = $UserLocale; + } + if ($PSBoundParameters.ContainsKey('RegisteredOwner')) { + $vmDefaults.RegisteredOwner = $RegisteredOwner; + } + if ($PSBoundParameters.ContainsKey('RegisteredOrganization')) { + $vmDefaults.RegisteredOrganization = $RegisteredOrganization; + } + if ($PSBoundParameters.ContainsKey('ClientCertificatePath')) { + if (-not [System.String]::IsNullOrWhitespace($ClientCertificatePath)) { + $ClientCertificatePath = [System.Environment]::ExpandEnvironmentVariables($ClientCertificatePath); + if (-not (Test-Path -Path $ClientCertificatePath -Type Leaf)) { + throw ($localized.CannotFindCertificateError -f 'Client', $ClientCertificatePath); + } + } + $vmDefaults.ClientCertificatePath = $ClientCertificatePath; + } + if ($PSBoundParameters.ContainsKey('RootCertificatePath')) { + if (-not [System.String]::IsNullOrWhitespace($RootCertificatePath)) { + $RootCertificatePath = [System.Environment]::ExpandEnvironmentVariables($RootCertificatePath); + if (-not (Test-Path -Path $RootCertificatePath -Type Leaf)) { + throw ($localized.CannotFindCertificateError -f 'Root', $RootCertificatePath); + } + } + $vmDefaults.RootCertificatePath = $RootCertificatePath; + } + if ($PSBoundParameters.ContainsKey('BootDelay')) { + $vmDefaults.BootDelay = $BootDelay; + } + if ($PSBoundParameters.ContainsKey('CustomBootstrapOrder')) { + $vmDefaults.CustomBootstrapOrder = $CustomBootstrapOrder; + } + if ($PSBoundParameters.ContainsKey('SecureBoot')) { + $vmDefaults.SecureBoot = $SecureBoot; + } + if ($PSBoundParameters.ContainsKey('GuestIntegrationServices')) { + $vmDefaults.GuestIntegrationServices = $GuestIntegrationServices; + } + + if ($vmDefaults.StartupMemory -lt $vmDefaults.MinimumMemory) { + throw ($localized.StartMemLessThanMinMemError -f $vmDefaults.StartupMemory, $vmDefaults.MinimumMemory); + } + elseif ($vmDefaults.StartupMemory -gt $vmDefaults.MaximumMemory) { + throw ($localized.StartMemGreaterThanMaxMemError -f $vmDefaults.StartupMemory, $vmDefaults.MaximumMemory); + } + + $shouldProcessMessage = $localized.PerformingOperationOnTarget -f 'Set-LabVMDefault', $vmName; + $verboseProcessMessage = $localized.SettingVMDefaults; + if ($PSCmdlet.ShouldProcess($verboseProcessMessage, $shouldProcessMessage, $localized.ShouldProcessWarning)) { + SetConfigurationData -Configuration VM -InputObject $vmDefaults; + } + + ## BootOrder property should not be exposed via the Get-LabVMDefault/Set-LabVMDefault + $vmDefaults.PSObject.Properties.Remove('BootOrder'); + return $vmDefaults; + + } + +} + diff --git a/Public/Set/Set-LabVMDefaults.ps1 b/Public/Set/Set-LabVMDefaults.ps1 new file mode 100644 index 00000000..d517a9b3 --- /dev/null +++ b/Public/Set/Set-LabVMDefaults.ps1 @@ -0,0 +1,114 @@ +function Set-LabVMDefaults { + +<# + .SYNOPSIS + Sets the lab virtual machine default settings. + .NOTES + Proxy function replacing alias to enable warning output. +#> + [CmdletBinding(SupportsShouldProcess)] + [OutputType([System.Management.Automation.PSCustomObject])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess','')] + param ( + ## Default virtual machine startup memory (bytes). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateRange(536870912, 1099511627776)] + [System.Int64] $StartupMemory, + + ## Default virtual machine miniumum dynamic memory allocation (bytes). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateRange(536870912, 1099511627776)] + [System.Int64] $MinimumMemory, + + ## Default virtual machine maximum dynamic memory allocation (bytes). + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateRange(536870912, 1099511627776)] + [System.Int64] $MaximumMemory, + + ## Default virtual machine processor count. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateRange(1, 4)] + [System.Int32] $ProcessorCount, + + ## Default virtual machine media Id. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Media, + + ## Lab host internal switch name. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $SwitchName, + + # Input Locale + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^([a-z]{2,2}-[a-z]{2,2})|(\d{4,4}:\d{8,8})$')] + [System.String] $InputLocale, + + # System Locale + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^[a-z]{2,2}-[a-z]{2,2}$')] + [System.String] $SystemLocale, + + # User Locale + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^[a-z]{2,2}-[a-z]{2,2}$')] + [System.String] $UserLocale, + + # UI Language + [Parameter(ValueFromPipelineByPropertyName)] + [ValidatePattern('^[a-z]{2,2}-[a-z]{2,2}$')] + [System.String] $UILanguage, + + # Timezone + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Timezone, + + # Registered Owner + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $RegisteredOwner, + + # Registered Organization + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] [Alias('RegisteredOrganisation')] $RegisteredOrganization, + + ## Client PFX certificate bundle used to encrypt DSC credentials + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.String] $ClientCertificatePath, + + ## Client certificate's issuing Root Certificate Authority (CA) certificate + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNull()] + [System.String] $RootCertificatePath, + + ## Boot delay/pause between VM operations + [Parameter(ValueFromPipelineByPropertyName)] + [System.UInt16] $BootDelay, + + ## Secure boot status. Could be a SwitchParameter but boolean is more explicit? + [Parameter(ValueFromPipelineByPropertyName)] + [System.Boolean] $SecureBoot, + + ## Custom bootstrap order + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet('ConfigurationFirst','ConfigurationOnly','Disabled','MediaFirst','MediaOnly')] + [System.String] $CustomBootstrapOrder = 'MediaFirst', + + ## Enable Guest Integration Services + [Parameter(ValueFromPipelineByPropertyName)] + [System.Boolean] $GuestIntegrationServices + ) + process { + + Write-Warning -Message ($localized.DeprecatedCommandWarning -f 'Set-LabVMDefaults','Set-LabVMDefault'); + Set-LabVMDefault @PSBoundParameters; + + } + +} + diff --git a/Public/Set/Tests/Set-LabHostDefault.Functional.Tests.ps1 b/Public/Set/Tests/Set-LabHostDefault.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Set/Tests/Set-LabHostDefault.Tests.ps1 b/Public/Set/Tests/Set-LabHostDefault.Tests.ps1 new file mode 100644 index 00000000..5086f249 --- /dev/null +++ b/Public/Set/Tests/Set-LabHostDefault.Tests.ps1 @@ -0,0 +1,376 @@ +Describe 'Set-LabHostDefault Tests' { + + Context 'Parameters for Set-LabHostDefault'{ + + It 'Has a Parameter called ConfigurationPath' { + $Function.Parameters.Keys.Contains('ConfigurationPath') | Should Be 'True' + } + It 'ConfigurationPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationPath.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationPath Parameter is of String Type' { + $Function.Parameters.ConfigurationPath.ParameterType.FullName | Should be 'System.String' + } + It 'ConfigurationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationPath.Attributes.Position | Should be '0' + } + It 'Does ConfigurationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ConfigurationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationPath '{ + $function.Definition.Contains('.PARAMETER ConfigurationPath') | Should Be 'True' + } + It 'Has a Parameter called IsoPath' { + $Function.Parameters.Keys.Contains('IsoPath') | Should Be 'True' + } + It 'IsoPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.IsoPath.Attributes.Mandatory | Should be 'False' + } + It 'IsoPath Parameter is of String Type' { + $Function.Parameters.IsoPath.ParameterType.FullName | Should be 'System.String' + } + It 'IsoPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.IsoPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'IsoPath Parameter Position is defined correctly' { + [String]$Function.Parameters.IsoPath.Attributes.Position | Should be '1' + } + It 'Does IsoPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.IsoPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does IsoPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.IsoPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does IsoPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.IsoPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.IsoPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.IsoPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.IsoPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.IsoPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for IsoPath '{ + $function.Definition.Contains('.PARAMETER IsoPath') | Should Be 'True' + } + It 'Has a Parameter called ParentVhdPath' { + $Function.Parameters.Keys.Contains('ParentVhdPath') | Should Be 'True' + } + It 'ParentVhdPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ParentVhdPath.Attributes.Mandatory | Should be 'False' + } + It 'ParentVhdPath Parameter is of String Type' { + $Function.Parameters.ParentVhdPath.ParameterType.FullName | Should be 'System.String' + } + It 'ParentVhdPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ParentVhdPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ParentVhdPath Parameter Position is defined correctly' { + [String]$Function.Parameters.ParentVhdPath.Attributes.Position | Should be '2' + } + It 'Does ParentVhdPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ParentVhdPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ParentVhdPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ParentVhdPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ParentVhdPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ParentVhdPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ParentVhdPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ParentVhdPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ParentVhdPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ParentVhdPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ParentVhdPath '{ + $function.Definition.Contains('.PARAMETER ParentVhdPath') | Should Be 'True' + } + It 'Has a Parameter called DifferencingVhdPath' { + $Function.Parameters.Keys.Contains('DifferencingVhdPath') | Should Be 'True' + } + It 'DifferencingVhdPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.DifferencingVhdPath.Attributes.Mandatory | Should be 'False' + } + It 'DifferencingVhdPath Parameter is of String Type' { + $Function.Parameters.DifferencingVhdPath.ParameterType.FullName | Should be 'System.String' + } + It 'DifferencingVhdPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DifferencingVhdPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DifferencingVhdPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DifferencingVhdPath.Attributes.Position | Should be '3' + } + It 'Does DifferencingVhdPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DifferencingVhdPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DifferencingVhdPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DifferencingVhdPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DifferencingVhdPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DifferencingVhdPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DifferencingVhdPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DifferencingVhdPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DifferencingVhdPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DifferencingVhdPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DifferencingVhdPath '{ + $function.Definition.Contains('.PARAMETER DifferencingVhdPath') | Should Be 'True' + } + It 'Has a Parameter called ModuleCachePath' { + $Function.Parameters.Keys.Contains('ModuleCachePath') | Should Be 'True' + } + It 'ModuleCachePath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ModuleCachePath.Attributes.Mandatory | Should be 'False' + } + It 'ModuleCachePath Parameter is of String Type' { + $Function.Parameters.ModuleCachePath.ParameterType.FullName | Should be 'System.String' + } + It 'ModuleCachePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ModuleCachePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ModuleCachePath Parameter Position is defined correctly' { + [String]$Function.Parameters.ModuleCachePath.Attributes.Position | Should be '4' + } + It 'Does ModuleCachePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ModuleCachePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ModuleCachePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ModuleCachePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ModuleCachePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ModuleCachePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ModuleCachePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ModuleCachePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ModuleCachePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ModuleCachePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ModuleCachePath '{ + $function.Definition.Contains('.PARAMETER ModuleCachePath') | Should Be 'True' + } + It 'Has a Parameter called ResourcePath' { + $Function.Parameters.Keys.Contains('ResourcePath') | Should Be 'True' + } + It 'ResourcePath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ResourcePath.Attributes.Mandatory | Should be 'False' + } + It 'ResourcePath Parameter is of String Type' { + $Function.Parameters.ResourcePath.ParameterType.FullName | Should be 'System.String' + } + It 'ResourcePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourcePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourcePath Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourcePath.Attributes.Position | Should be '5' + } + It 'Does ResourcePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourcePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourcePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourcePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ResourcePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourcePath '{ + $function.Definition.Contains('.PARAMETER ResourcePath') | Should Be 'True' + } + It 'Has a Parameter called ResourceShareName' { + $Function.Parameters.Keys.Contains('ResourceShareName') | Should Be 'True' + } + It 'ResourceShareName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ResourceShareName.Attributes.Mandatory | Should be 'False' + } + It 'ResourceShareName Parameter is of String Type' { + $Function.Parameters.ResourceShareName.ParameterType.FullName | Should be 'System.String' + } + It 'ResourceShareName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceShareName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourceShareName Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceShareName.Attributes.Position | Should be '6' + } + It 'Does ResourceShareName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceShareName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourceShareName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceShareName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ResourceShareName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceShareName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ResourceShareName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceShareName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceShareName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceShareName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceShareName '{ + $function.Definition.Contains('.PARAMETER ResourceShareName') | Should Be 'True' + } + It 'Has a Parameter called HotfixPath' { + $Function.Parameters.Keys.Contains('HotfixPath') | Should Be 'True' + } + It 'HotfixPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.HotfixPath.Attributes.Mandatory | Should be 'False' + } + It 'HotfixPath Parameter is of String Type' { + $Function.Parameters.HotfixPath.ParameterType.FullName | Should be 'System.String' + } + It 'HotfixPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.HotfixPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'HotfixPath Parameter Position is defined correctly' { + [String]$Function.Parameters.HotfixPath.Attributes.Position | Should be '7' + } + It 'Does HotfixPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.HotfixPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does HotfixPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.HotfixPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does HotfixPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.HotfixPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.HotfixPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.HotfixPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.HotfixPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.HotfixPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for HotfixPath '{ + $function.Definition.Contains('.PARAMETER HotfixPath') | Should Be 'True' + } + It 'Has a Parameter called DisableLocalFileCaching' { + $Function.Parameters.Keys.Contains('DisableLocalFileCaching') | Should Be 'True' + } + It 'DisableLocalFileCaching Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.DisableLocalFileCaching.Attributes.Mandatory | Should be 'False' + } + It 'DisableLocalFileCaching Parameter is of SwitchParameter Type' { + $Function.Parameters.DisableLocalFileCaching.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'DisableLocalFileCaching Parameter is member of ParameterSets' { + [String]$Function.Parameters.DisableLocalFileCaching.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DisableLocalFileCaching Parameter Position is defined correctly' { + [String]$Function.Parameters.DisableLocalFileCaching.Attributes.Position | Should be '-2147483648' + } + It 'Does DisableLocalFileCaching Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DisableLocalFileCaching.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DisableLocalFileCaching Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DisableLocalFileCaching.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DisableLocalFileCaching Parameter use advanced parameter Validation? ' { + $Function.Parameters.DisableLocalFileCaching.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.DisableLocalFileCaching.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DisableLocalFileCaching.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DisableLocalFileCaching.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DisableLocalFileCaching.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DisableLocalFileCaching '{ + $function.Definition.Contains('.PARAMETER DisableLocalFileCaching') | Should Be 'True' + } + It 'Has a Parameter called EnableCallStackLogging' { + $Function.Parameters.Keys.Contains('EnableCallStackLogging') | Should Be 'True' + } + It 'EnableCallStackLogging Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.EnableCallStackLogging.Attributes.Mandatory | Should be 'False' + } + It 'EnableCallStackLogging Parameter is of SwitchParameter Type' { + $Function.Parameters.EnableCallStackLogging.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'EnableCallStackLogging Parameter is member of ParameterSets' { + [String]$Function.Parameters.EnableCallStackLogging.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'EnableCallStackLogging Parameter Position is defined correctly' { + [String]$Function.Parameters.EnableCallStackLogging.Attributes.Position | Should be '-2147483648' + } + It 'Does EnableCallStackLogging Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.EnableCallStackLogging.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does EnableCallStackLogging Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.EnableCallStackLogging.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does EnableCallStackLogging Parameter use advanced parameter Validation? ' { + $Function.Parameters.EnableCallStackLogging.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.EnableCallStackLogging.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.EnableCallStackLogging.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.EnableCallStackLogging.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.EnableCallStackLogging.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for EnableCallStackLogging '{ + $function.Definition.Contains('.PARAMETER EnableCallStackLogging') | Should Be 'True' + } + It 'Has a Parameter called DismPath' { + $Function.Parameters.Keys.Contains('DismPath') | Should Be 'True' + } + It 'DismPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.DismPath.Attributes.Mandatory | Should be 'False' + } + It 'DismPath Parameter is of String Type' { + $Function.Parameters.DismPath.ParameterType.FullName | Should be 'System.String' + } + It 'DismPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DismPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DismPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DismPath.Attributes.Position | Should be '8' + } + It 'Does DismPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DismPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DismPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DismPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DismPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DismPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.DismPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DismPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DismPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DismPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DismPath '{ + $function.Definition.Contains('.PARAMETER DismPath') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Set/Tests/Set-LabHostDefaults.Functional.Tests.ps1 b/Public/Set/Tests/Set-LabHostDefaults.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Set/Tests/Set-LabHostDefaults.Tests.ps1 b/Public/Set/Tests/Set-LabHostDefaults.Tests.ps1 new file mode 100644 index 00000000..ea5aa26b --- /dev/null +++ b/Public/Set/Tests/Set-LabHostDefaults.Tests.ps1 @@ -0,0 +1,376 @@ +Describe 'Set-LabHostDefaults Tests' { + + Context 'Parameters for Set-LabHostDefaults'{ + + It 'Has a Parameter called ConfigurationPath' { + $Function.Parameters.Keys.Contains('ConfigurationPath') | Should Be 'True' + } + It 'ConfigurationPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationPath.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationPath Parameter is of String Type' { + $Function.Parameters.ConfigurationPath.ParameterType.FullName | Should be 'System.String' + } + It 'ConfigurationPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationPath Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationPath.Attributes.Position | Should be '0' + } + It 'Does ConfigurationPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ConfigurationPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationPath '{ + $function.Definition.Contains('.PARAMETER ConfigurationPath') | Should Be 'True' + } + It 'Has a Parameter called IsoPath' { + $Function.Parameters.Keys.Contains('IsoPath') | Should Be 'True' + } + It 'IsoPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.IsoPath.Attributes.Mandatory | Should be 'False' + } + It 'IsoPath Parameter is of String Type' { + $Function.Parameters.IsoPath.ParameterType.FullName | Should be 'System.String' + } + It 'IsoPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.IsoPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'IsoPath Parameter Position is defined correctly' { + [String]$Function.Parameters.IsoPath.Attributes.Position | Should be '1' + } + It 'Does IsoPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.IsoPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does IsoPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.IsoPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does IsoPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.IsoPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.IsoPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.IsoPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.IsoPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.IsoPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for IsoPath '{ + $function.Definition.Contains('.PARAMETER IsoPath') | Should Be 'True' + } + It 'Has a Parameter called ParentVhdPath' { + $Function.Parameters.Keys.Contains('ParentVhdPath') | Should Be 'True' + } + It 'ParentVhdPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ParentVhdPath.Attributes.Mandatory | Should be 'False' + } + It 'ParentVhdPath Parameter is of String Type' { + $Function.Parameters.ParentVhdPath.ParameterType.FullName | Should be 'System.String' + } + It 'ParentVhdPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ParentVhdPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ParentVhdPath Parameter Position is defined correctly' { + [String]$Function.Parameters.ParentVhdPath.Attributes.Position | Should be '2' + } + It 'Does ParentVhdPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ParentVhdPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ParentVhdPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ParentVhdPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ParentVhdPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ParentVhdPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ParentVhdPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ParentVhdPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ParentVhdPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ParentVhdPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ParentVhdPath '{ + $function.Definition.Contains('.PARAMETER ParentVhdPath') | Should Be 'True' + } + It 'Has a Parameter called DifferencingVhdPath' { + $Function.Parameters.Keys.Contains('DifferencingVhdPath') | Should Be 'True' + } + It 'DifferencingVhdPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.DifferencingVhdPath.Attributes.Mandatory | Should be 'False' + } + It 'DifferencingVhdPath Parameter is of String Type' { + $Function.Parameters.DifferencingVhdPath.ParameterType.FullName | Should be 'System.String' + } + It 'DifferencingVhdPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DifferencingVhdPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DifferencingVhdPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DifferencingVhdPath.Attributes.Position | Should be '3' + } + It 'Does DifferencingVhdPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DifferencingVhdPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DifferencingVhdPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DifferencingVhdPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DifferencingVhdPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DifferencingVhdPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.DifferencingVhdPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DifferencingVhdPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DifferencingVhdPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DifferencingVhdPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DifferencingVhdPath '{ + $function.Definition.Contains('.PARAMETER DifferencingVhdPath') | Should Be 'True' + } + It 'Has a Parameter called ModuleCachePath' { + $Function.Parameters.Keys.Contains('ModuleCachePath') | Should Be 'True' + } + It 'ModuleCachePath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ModuleCachePath.Attributes.Mandatory | Should be 'False' + } + It 'ModuleCachePath Parameter is of String Type' { + $Function.Parameters.ModuleCachePath.ParameterType.FullName | Should be 'System.String' + } + It 'ModuleCachePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ModuleCachePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ModuleCachePath Parameter Position is defined correctly' { + [String]$Function.Parameters.ModuleCachePath.Attributes.Position | Should be '4' + } + It 'Does ModuleCachePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ModuleCachePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ModuleCachePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ModuleCachePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ModuleCachePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ModuleCachePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ModuleCachePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ModuleCachePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ModuleCachePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ModuleCachePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ModuleCachePath '{ + $function.Definition.Contains('.PARAMETER ModuleCachePath') | Should Be 'True' + } + It 'Has a Parameter called ResourcePath' { + $Function.Parameters.Keys.Contains('ResourcePath') | Should Be 'True' + } + It 'ResourcePath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ResourcePath.Attributes.Mandatory | Should be 'False' + } + It 'ResourcePath Parameter is of String Type' { + $Function.Parameters.ResourcePath.ParameterType.FullName | Should be 'System.String' + } + It 'ResourcePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourcePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourcePath Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourcePath.Attributes.Position | Should be '5' + } + It 'Does ResourcePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourcePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourcePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourcePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ResourcePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourcePath '{ + $function.Definition.Contains('.PARAMETER ResourcePath') | Should Be 'True' + } + It 'Has a Parameter called ResourceShareName' { + $Function.Parameters.Keys.Contains('ResourceShareName') | Should Be 'True' + } + It 'ResourceShareName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ResourceShareName.Attributes.Mandatory | Should be 'False' + } + It 'ResourceShareName Parameter is of String Type' { + $Function.Parameters.ResourceShareName.ParameterType.FullName | Should be 'System.String' + } + It 'ResourceShareName Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceShareName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourceShareName Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceShareName.Attributes.Position | Should be '6' + } + It 'Does ResourceShareName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceShareName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourceShareName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceShareName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ResourceShareName Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceShareName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ResourceShareName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceShareName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceShareName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceShareName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceShareName '{ + $function.Definition.Contains('.PARAMETER ResourceShareName') | Should Be 'True' + } + It 'Has a Parameter called HotfixPath' { + $Function.Parameters.Keys.Contains('HotfixPath') | Should Be 'True' + } + It 'HotfixPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.HotfixPath.Attributes.Mandatory | Should be 'False' + } + It 'HotfixPath Parameter is of String Type' { + $Function.Parameters.HotfixPath.ParameterType.FullName | Should be 'System.String' + } + It 'HotfixPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.HotfixPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'HotfixPath Parameter Position is defined correctly' { + [String]$Function.Parameters.HotfixPath.Attributes.Position | Should be '7' + } + It 'Does HotfixPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.HotfixPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does HotfixPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.HotfixPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does HotfixPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.HotfixPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.HotfixPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.HotfixPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.HotfixPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.HotfixPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for HotfixPath '{ + $function.Definition.Contains('.PARAMETER HotfixPath') | Should Be 'True' + } + It 'Has a Parameter called DisableLocalFileCaching' { + $Function.Parameters.Keys.Contains('DisableLocalFileCaching') | Should Be 'True' + } + It 'DisableLocalFileCaching Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.DisableLocalFileCaching.Attributes.Mandatory | Should be 'False' + } + It 'DisableLocalFileCaching Parameter is of SwitchParameter Type' { + $Function.Parameters.DisableLocalFileCaching.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'DisableLocalFileCaching Parameter is member of ParameterSets' { + [String]$Function.Parameters.DisableLocalFileCaching.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DisableLocalFileCaching Parameter Position is defined correctly' { + [String]$Function.Parameters.DisableLocalFileCaching.Attributes.Position | Should be '-2147483648' + } + It 'Does DisableLocalFileCaching Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DisableLocalFileCaching.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DisableLocalFileCaching Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DisableLocalFileCaching.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DisableLocalFileCaching Parameter use advanced parameter Validation? ' { + $Function.Parameters.DisableLocalFileCaching.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.DisableLocalFileCaching.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DisableLocalFileCaching.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DisableLocalFileCaching.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DisableLocalFileCaching.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DisableLocalFileCaching '{ + $function.Definition.Contains('.PARAMETER DisableLocalFileCaching') | Should Be 'True' + } + It 'Has a Parameter called EnableCallStackLogging' { + $Function.Parameters.Keys.Contains('EnableCallStackLogging') | Should Be 'True' + } + It 'EnableCallStackLogging Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.EnableCallStackLogging.Attributes.Mandatory | Should be 'False' + } + It 'EnableCallStackLogging Parameter is of SwitchParameter Type' { + $Function.Parameters.EnableCallStackLogging.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'EnableCallStackLogging Parameter is member of ParameterSets' { + [String]$Function.Parameters.EnableCallStackLogging.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'EnableCallStackLogging Parameter Position is defined correctly' { + [String]$Function.Parameters.EnableCallStackLogging.Attributes.Position | Should be '-2147483648' + } + It 'Does EnableCallStackLogging Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.EnableCallStackLogging.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does EnableCallStackLogging Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.EnableCallStackLogging.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does EnableCallStackLogging Parameter use advanced parameter Validation? ' { + $Function.Parameters.EnableCallStackLogging.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.EnableCallStackLogging.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.EnableCallStackLogging.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.EnableCallStackLogging.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.EnableCallStackLogging.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for EnableCallStackLogging '{ + $function.Definition.Contains('.PARAMETER EnableCallStackLogging') | Should Be 'True' + } + It 'Has a Parameter called DismPath' { + $Function.Parameters.Keys.Contains('DismPath') | Should Be 'True' + } + It 'DismPath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.DismPath.Attributes.Mandatory | Should be 'False' + } + It 'DismPath Parameter is of String Type' { + $Function.Parameters.DismPath.ParameterType.FullName | Should be 'System.String' + } + It 'DismPath Parameter is member of ParameterSets' { + [String]$Function.Parameters.DismPath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'DismPath Parameter Position is defined correctly' { + [String]$Function.Parameters.DismPath.Attributes.Position | Should be '8' + } + It 'Does DismPath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.DismPath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does DismPath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.DismPath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does DismPath Parameter use advanced parameter Validation? ' { + $Function.Parameters.DismPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.DismPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.DismPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.DismPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.DismPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for DismPath '{ + $function.Definition.Contains('.PARAMETER DismPath') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Set/Tests/Set-LabVMDefault.Functional.Tests.ps1 b/Public/Set/Tests/Set-LabVMDefault.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Set/Tests/Set-LabVMDefault.Tests.ps1 b/Public/Set/Tests/Set-LabVMDefault.Tests.ps1 new file mode 100644 index 00000000..9ebec5cf --- /dev/null +++ b/Public/Set/Tests/Set-LabVMDefault.Tests.ps1 @@ -0,0 +1,624 @@ +Describe 'Set-LabVMDefault Tests' { + + Context 'Parameters for Set-LabVMDefault'{ + + It 'Has a Parameter called StartupMemory' { + $Function.Parameters.Keys.Contains('StartupMemory') | Should Be 'True' + } + It 'StartupMemory Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.StartupMemory.Attributes.Mandatory | Should be 'False' + } + It 'StartupMemory Parameter is of Int64 Type' { + $Function.Parameters.StartupMemory.ParameterType.FullName | Should be 'System.Int64' + } + It 'StartupMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.StartupMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'StartupMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.StartupMemory.Attributes.Position | Should be '0' + } + It 'Does StartupMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does StartupMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does StartupMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'True' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for StartupMemory '{ + $function.Definition.Contains('.PARAMETER StartupMemory') | Should Be 'True' + } + It 'Has a Parameter called MinimumMemory' { + $Function.Parameters.Keys.Contains('MinimumMemory') | Should Be 'True' + } + It 'MinimumMemory Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MinimumMemory.Attributes.Mandatory | Should be 'False' + } + It 'MinimumMemory Parameter is of Int64 Type' { + $Function.Parameters.MinimumMemory.ParameterType.FullName | Should be 'System.Int64' + } + It 'MinimumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MinimumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumMemory.Attributes.Position | Should be '1' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MinimumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'True' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumMemory '{ + $function.Definition.Contains('.PARAMETER MinimumMemory') | Should Be 'True' + } + It 'Has a Parameter called MaximumMemory' { + $Function.Parameters.Keys.Contains('MaximumMemory') | Should Be 'True' + } + It 'MaximumMemory Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MaximumMemory.Attributes.Mandatory | Should be 'False' + } + It 'MaximumMemory Parameter is of Int64 Type' { + $Function.Parameters.MaximumMemory.ParameterType.FullName | Should be 'System.Int64' + } + It 'MaximumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MaximumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MaximumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MaximumMemory.Attributes.Position | Should be '2' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MaximumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'True' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MaximumMemory '{ + $function.Definition.Contains('.PARAMETER MaximumMemory') | Should Be 'True' + } + It 'Has a Parameter called ProcessorCount' { + $Function.Parameters.Keys.Contains('ProcessorCount') | Should Be 'True' + } + It 'ProcessorCount Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ProcessorCount.Attributes.Mandatory | Should be 'False' + } + It 'ProcessorCount Parameter is of Int32 Type' { + $Function.Parameters.ProcessorCount.ParameterType.FullName | Should be 'System.Int32' + } + It 'ProcessorCount Parameter is member of ParameterSets' { + [String]$Function.Parameters.ProcessorCount.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ProcessorCount Parameter Position is defined correctly' { + [String]$Function.Parameters.ProcessorCount.Attributes.Position | Should be '3' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ProcessorCount Parameter use advanced parameter Validation? ' { + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'True' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ProcessorCount '{ + $function.Definition.Contains('.PARAMETER ProcessorCount') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'False' + } + It 'Media Parameter is of String Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.String' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '4' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called SwitchName' { + $Function.Parameters.Keys.Contains('SwitchName') | Should Be 'True' + } + It 'SwitchName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SwitchName.Attributes.Mandatory | Should be 'False' + } + It 'SwitchName Parameter is of String Type' { + $Function.Parameters.SwitchName.ParameterType.FullName | Should be 'System.String' + } + It 'SwitchName Parameter is member of ParameterSets' { + [String]$Function.Parameters.SwitchName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SwitchName Parameter Position is defined correctly' { + [String]$Function.Parameters.SwitchName.Attributes.Position | Should be '5' + } + It 'Does SwitchName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SwitchName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SwitchName Parameter use advanced parameter Validation? ' { + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SwitchName '{ + $function.Definition.Contains('.PARAMETER SwitchName') | Should Be 'True' + } + It 'Has a Parameter called InputLocale' { + $Function.Parameters.Keys.Contains('InputLocale') | Should Be 'True' + } + It 'InputLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.InputLocale.Attributes.Mandatory | Should be 'False' + } + It 'InputLocale Parameter is of String Type' { + $Function.Parameters.InputLocale.ParameterType.FullName | Should be 'System.String' + } + It 'InputLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.InputLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'InputLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.InputLocale.Attributes.Position | Should be '6' + } + It 'Does InputLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.InputLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does InputLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.InputLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does InputLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for InputLocale '{ + $function.Definition.Contains('.PARAMETER InputLocale') | Should Be 'True' + } + It 'Has a Parameter called SystemLocale' { + $Function.Parameters.Keys.Contains('SystemLocale') | Should Be 'True' + } + It 'SystemLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SystemLocale.Attributes.Mandatory | Should be 'False' + } + It 'SystemLocale Parameter is of String Type' { + $Function.Parameters.SystemLocale.ParameterType.FullName | Should be 'System.String' + } + It 'SystemLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.SystemLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SystemLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.SystemLocale.Attributes.Position | Should be '7' + } + It 'Does SystemLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SystemLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SystemLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SystemLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SystemLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for SystemLocale '{ + $function.Definition.Contains('.PARAMETER SystemLocale') | Should Be 'True' + } + It 'Has a Parameter called UserLocale' { + $Function.Parameters.Keys.Contains('UserLocale') | Should Be 'True' + } + It 'UserLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.UserLocale.Attributes.Mandatory | Should be 'False' + } + It 'UserLocale Parameter is of String Type' { + $Function.Parameters.UserLocale.ParameterType.FullName | Should be 'System.String' + } + It 'UserLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.UserLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'UserLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.UserLocale.Attributes.Position | Should be '8' + } + It 'Does UserLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.UserLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does UserLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.UserLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does UserLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for UserLocale '{ + $function.Definition.Contains('.PARAMETER UserLocale') | Should Be 'True' + } + It 'Has a Parameter called UILanguage' { + $Function.Parameters.Keys.Contains('UILanguage') | Should Be 'True' + } + It 'UILanguage Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.UILanguage.Attributes.Mandatory | Should be 'False' + } + It 'UILanguage Parameter is of String Type' { + $Function.Parameters.UILanguage.ParameterType.FullName | Should be 'System.String' + } + It 'UILanguage Parameter is member of ParameterSets' { + [String]$Function.Parameters.UILanguage.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'UILanguage Parameter Position is defined correctly' { + [String]$Function.Parameters.UILanguage.Attributes.Position | Should be '9' + } + It 'Does UILanguage Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.UILanguage.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does UILanguage Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.UILanguage.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does UILanguage Parameter use advanced parameter Validation? ' { + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for UILanguage '{ + $function.Definition.Contains('.PARAMETER UILanguage') | Should Be 'True' + } + It 'Has a Parameter called Timezone' { + $Function.Parameters.Keys.Contains('Timezone') | Should Be 'True' + } + It 'Timezone Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Timezone.Attributes.Mandatory | Should be 'False' + } + It 'Timezone Parameter is of String Type' { + $Function.Parameters.Timezone.ParameterType.FullName | Should be 'System.String' + } + It 'Timezone Parameter is member of ParameterSets' { + [String]$Function.Parameters.Timezone.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Timezone Parameter Position is defined correctly' { + [String]$Function.Parameters.Timezone.Attributes.Position | Should be '10' + } + It 'Does Timezone Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Timezone.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Timezone Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Timezone.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Timezone Parameter use advanced parameter Validation? ' { + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Timezone '{ + $function.Definition.Contains('.PARAMETER Timezone') | Should Be 'True' + } + It 'Has a Parameter called RegisteredOwner' { + $Function.Parameters.Keys.Contains('RegisteredOwner') | Should Be 'True' + } + It 'RegisteredOwner Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RegisteredOwner.Attributes.Mandatory | Should be 'False' + } + It 'RegisteredOwner Parameter is of String Type' { + $Function.Parameters.RegisteredOwner.ParameterType.FullName | Should be 'System.String' + } + It 'RegisteredOwner Parameter is member of ParameterSets' { + [String]$Function.Parameters.RegisteredOwner.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RegisteredOwner Parameter Position is defined correctly' { + [String]$Function.Parameters.RegisteredOwner.Attributes.Position | Should be '11' + } + It 'Does RegisteredOwner Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RegisteredOwner.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RegisteredOwner Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RegisteredOwner.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RegisteredOwner Parameter use advanced parameter Validation? ' { + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RegisteredOwner '{ + $function.Definition.Contains('.PARAMETER RegisteredOwner') | Should Be 'True' + } + It 'Has a Parameter called RegisteredOrganization' { + $Function.Parameters.Keys.Contains('RegisteredOrganization') | Should Be 'True' + } + It 'RegisteredOrganization Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.Mandatory | Should be 'False' + } + It 'RegisteredOrganization Parameter is of String Type' { + $Function.Parameters.RegisteredOrganization.ParameterType.FullName | Should be 'System.String' + } + It 'RegisteredOrganization Parameter is member of ParameterSets' { + [String]$Function.Parameters.RegisteredOrganization.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RegisteredOrganization Parameter Position is defined correctly' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.Position | Should be '12' + } + It 'Does RegisteredOrganization Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RegisteredOrganization Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RegisteredOrganization Parameter use advanced parameter Validation? ' { + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RegisteredOrganization '{ + $function.Definition.Contains('.PARAMETER RegisteredOrganization') | Should Be 'True' + } + It 'Has a Parameter called ClientCertificatePath' { + $Function.Parameters.Keys.Contains('ClientCertificatePath') | Should Be 'True' + } + It 'ClientCertificatePath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ClientCertificatePath.Attributes.Mandatory | Should be 'False' + } + It 'ClientCertificatePath Parameter is of String Type' { + $Function.Parameters.ClientCertificatePath.ParameterType.FullName | Should be 'System.String' + } + It 'ClientCertificatePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ClientCertificatePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ClientCertificatePath Parameter Position is defined correctly' { + [String]$Function.Parameters.ClientCertificatePath.Attributes.Position | Should be '13' + } + It 'Does ClientCertificatePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ClientCertificatePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ClientCertificatePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ClientCertificatePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ClientCertificatePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ClientCertificatePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ClientCertificatePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.ClientCertificatePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ClientCertificatePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ClientCertificatePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ClientCertificatePath '{ + $function.Definition.Contains('.PARAMETER ClientCertificatePath') | Should Be 'True' + } + It 'Has a Parameter called RootCertificatePath' { + $Function.Parameters.Keys.Contains('RootCertificatePath') | Should Be 'True' + } + It 'RootCertificatePath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RootCertificatePath.Attributes.Mandatory | Should be 'False' + } + It 'RootCertificatePath Parameter is of String Type' { + $Function.Parameters.RootCertificatePath.ParameterType.FullName | Should be 'System.String' + } + It 'RootCertificatePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.RootCertificatePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RootCertificatePath Parameter Position is defined correctly' { + [String]$Function.Parameters.RootCertificatePath.Attributes.Position | Should be '14' + } + It 'Does RootCertificatePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RootCertificatePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RootCertificatePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RootCertificatePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RootCertificatePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.RootCertificatePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RootCertificatePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.RootCertificatePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RootCertificatePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RootCertificatePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RootCertificatePath '{ + $function.Definition.Contains('.PARAMETER RootCertificatePath') | Should Be 'True' + } + It 'Has a Parameter called BootDelay' { + $Function.Parameters.Keys.Contains('BootDelay') | Should Be 'True' + } + It 'BootDelay Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.BootDelay.Attributes.Mandatory | Should be 'False' + } + It 'BootDelay Parameter is of UInt16 Type' { + $Function.Parameters.BootDelay.ParameterType.FullName | Should be 'System.UInt16' + } + It 'BootDelay Parameter is member of ParameterSets' { + [String]$Function.Parameters.BootDelay.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'BootDelay Parameter Position is defined correctly' { + [String]$Function.Parameters.BootDelay.Attributes.Position | Should be '15' + } + It 'Does BootDelay Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.BootDelay.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does BootDelay Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.BootDelay.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does BootDelay Parameter use advanced parameter Validation? ' { + $Function.Parameters.BootDelay.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.BootDelay.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.BootDelay.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.BootDelay.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.BootDelay.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for BootDelay '{ + $function.Definition.Contains('.PARAMETER BootDelay') | Should Be 'True' + } + It 'Has a Parameter called SecureBoot' { + $Function.Parameters.Keys.Contains('SecureBoot') | Should Be 'True' + } + It 'SecureBoot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SecureBoot.Attributes.Mandatory | Should be 'False' + } + It 'SecureBoot Parameter is of Boolean Type' { + $Function.Parameters.SecureBoot.ParameterType.FullName | Should be 'System.Boolean' + } + It 'SecureBoot Parameter is member of ParameterSets' { + [String]$Function.Parameters.SecureBoot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SecureBoot Parameter Position is defined correctly' { + [String]$Function.Parameters.SecureBoot.Attributes.Position | Should be '16' + } + It 'Does SecureBoot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SecureBoot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SecureBoot Parameter use advanced parameter Validation? ' { + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SecureBoot '{ + $function.Definition.Contains('.PARAMETER SecureBoot') | Should Be 'True' + } + It 'Has a Parameter called CustomBootstrapOrder' { + $Function.Parameters.Keys.Contains('CustomBootstrapOrder') | Should Be 'True' + } + It 'CustomBootstrapOrder Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CustomBootstrapOrder.Attributes.Mandatory | Should be 'False' + } + It 'CustomBootstrapOrder Parameter is of String Type' { + $Function.Parameters.CustomBootstrapOrder.ParameterType.FullName | Should be 'System.String' + } + It 'CustomBootstrapOrder Parameter is member of ParameterSets' { + [String]$Function.Parameters.CustomBootstrapOrder.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CustomBootstrapOrder Parameter Position is defined correctly' { + [String]$Function.Parameters.CustomBootstrapOrder.Attributes.Position | Should be '17' + } + It 'Does CustomBootstrapOrder Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CustomBootstrapOrder.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CustomBootstrapOrder Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CustomBootstrapOrder.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CustomBootstrapOrder Parameter use advanced parameter Validation? ' { + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CustomBootstrapOrder '{ + $function.Definition.Contains('.PARAMETER CustomBootstrapOrder') | Should Be 'True' + } + It 'Has a Parameter called GuestIntegrationServices' { + $Function.Parameters.Keys.Contains('GuestIntegrationServices') | Should Be 'True' + } + It 'GuestIntegrationServices Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Mandatory | Should be 'False' + } + It 'GuestIntegrationServices Parameter is of Boolean Type' { + $Function.Parameters.GuestIntegrationServices.ParameterType.FullName | Should be 'System.Boolean' + } + It 'GuestIntegrationServices Parameter is member of ParameterSets' { + [String]$Function.Parameters.GuestIntegrationServices.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'GuestIntegrationServices Parameter Position is defined correctly' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Position | Should be '18' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does GuestIntegrationServices Parameter use advanced parameter Validation? ' { + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for GuestIntegrationServices '{ + $function.Definition.Contains('.PARAMETER GuestIntegrationServices') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Set/Tests/Set-LabVMDefaults.Functional.Tests.ps1 b/Public/Set/Tests/Set-LabVMDefaults.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Set/Tests/Set-LabVMDefaults.Tests.ps1 b/Public/Set/Tests/Set-LabVMDefaults.Tests.ps1 new file mode 100644 index 00000000..fa2cc7bd --- /dev/null +++ b/Public/Set/Tests/Set-LabVMDefaults.Tests.ps1 @@ -0,0 +1,624 @@ +Describe 'Set-LabVMDefaults Tests' { + + Context 'Parameters for Set-LabVMDefaults'{ + + It 'Has a Parameter called StartupMemory' { + $Function.Parameters.Keys.Contains('StartupMemory') | Should Be 'True' + } + It 'StartupMemory Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.StartupMemory.Attributes.Mandatory | Should be 'False' + } + It 'StartupMemory Parameter is of Int64 Type' { + $Function.Parameters.StartupMemory.ParameterType.FullName | Should be 'System.Int64' + } + It 'StartupMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.StartupMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'StartupMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.StartupMemory.Attributes.Position | Should be '0' + } + It 'Does StartupMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does StartupMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.StartupMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does StartupMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'True' + $Function.Parameters.StartupMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for StartupMemory '{ + $function.Definition.Contains('.PARAMETER StartupMemory') | Should Be 'True' + } + It 'Has a Parameter called MinimumMemory' { + $Function.Parameters.Keys.Contains('MinimumMemory') | Should Be 'True' + } + It 'MinimumMemory Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MinimumMemory.Attributes.Mandatory | Should be 'False' + } + It 'MinimumMemory Parameter is of Int64 Type' { + $Function.Parameters.MinimumMemory.ParameterType.FullName | Should be 'System.Int64' + } + It 'MinimumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MinimumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MinimumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MinimumMemory.Attributes.Position | Should be '1' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MinimumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MinimumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MinimumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'True' + $Function.Parameters.MinimumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MinimumMemory '{ + $function.Definition.Contains('.PARAMETER MinimumMemory') | Should Be 'True' + } + It 'Has a Parameter called MaximumMemory' { + $Function.Parameters.Keys.Contains('MaximumMemory') | Should Be 'True' + } + It 'MaximumMemory Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.MaximumMemory.Attributes.Mandatory | Should be 'False' + } + It 'MaximumMemory Parameter is of Int64 Type' { + $Function.Parameters.MaximumMemory.ParameterType.FullName | Should be 'System.Int64' + } + It 'MaximumMemory Parameter is member of ParameterSets' { + [String]$Function.Parameters.MaximumMemory.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'MaximumMemory Parameter Position is defined correctly' { + [String]$Function.Parameters.MaximumMemory.Attributes.Position | Should be '2' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does MaximumMemory Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.MaximumMemory.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does MaximumMemory Parameter use advanced parameter Validation? ' { + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'True' + $Function.Parameters.MaximumMemory.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for MaximumMemory '{ + $function.Definition.Contains('.PARAMETER MaximumMemory') | Should Be 'True' + } + It 'Has a Parameter called ProcessorCount' { + $Function.Parameters.Keys.Contains('ProcessorCount') | Should Be 'True' + } + It 'ProcessorCount Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ProcessorCount.Attributes.Mandatory | Should be 'False' + } + It 'ProcessorCount Parameter is of Int32 Type' { + $Function.Parameters.ProcessorCount.ParameterType.FullName | Should be 'System.Int32' + } + It 'ProcessorCount Parameter is member of ParameterSets' { + [String]$Function.Parameters.ProcessorCount.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ProcessorCount Parameter Position is defined correctly' { + [String]$Function.Parameters.ProcessorCount.Attributes.Position | Should be '3' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ProcessorCount Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ProcessorCount.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ProcessorCount Parameter use advanced parameter Validation? ' { + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'True' + $Function.Parameters.ProcessorCount.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ProcessorCount '{ + $function.Definition.Contains('.PARAMETER ProcessorCount') | Should Be 'True' + } + It 'Has a Parameter called Media' { + $Function.Parameters.Keys.Contains('Media') | Should Be 'True' + } + It 'Media Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Media.Attributes.Mandatory | Should be 'False' + } + It 'Media Parameter is of String Type' { + $Function.Parameters.Media.ParameterType.FullName | Should be 'System.String' + } + It 'Media Parameter is member of ParameterSets' { + [String]$Function.Parameters.Media.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Media Parameter Position is defined correctly' { + [String]$Function.Parameters.Media.Attributes.Position | Should be '4' + } + It 'Does Media Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Media Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Media.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Media Parameter use advanced parameter Validation? ' { + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Media.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Media '{ + $function.Definition.Contains('.PARAMETER Media') | Should Be 'True' + } + It 'Has a Parameter called SwitchName' { + $Function.Parameters.Keys.Contains('SwitchName') | Should Be 'True' + } + It 'SwitchName Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SwitchName.Attributes.Mandatory | Should be 'False' + } + It 'SwitchName Parameter is of String Type' { + $Function.Parameters.SwitchName.ParameterType.FullName | Should be 'System.String' + } + It 'SwitchName Parameter is member of ParameterSets' { + [String]$Function.Parameters.SwitchName.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SwitchName Parameter Position is defined correctly' { + [String]$Function.Parameters.SwitchName.Attributes.Position | Should be '5' + } + It 'Does SwitchName Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SwitchName Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SwitchName.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SwitchName Parameter use advanced parameter Validation? ' { + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SwitchName.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SwitchName '{ + $function.Definition.Contains('.PARAMETER SwitchName') | Should Be 'True' + } + It 'Has a Parameter called InputLocale' { + $Function.Parameters.Keys.Contains('InputLocale') | Should Be 'True' + } + It 'InputLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.InputLocale.Attributes.Mandatory | Should be 'False' + } + It 'InputLocale Parameter is of String Type' { + $Function.Parameters.InputLocale.ParameterType.FullName | Should be 'System.String' + } + It 'InputLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.InputLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'InputLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.InputLocale.Attributes.Position | Should be '6' + } + It 'Does InputLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.InputLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does InputLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.InputLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does InputLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.InputLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for InputLocale '{ + $function.Definition.Contains('.PARAMETER InputLocale') | Should Be 'True' + } + It 'Has a Parameter called SystemLocale' { + $Function.Parameters.Keys.Contains('SystemLocale') | Should Be 'True' + } + It 'SystemLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SystemLocale.Attributes.Mandatory | Should be 'False' + } + It 'SystemLocale Parameter is of String Type' { + $Function.Parameters.SystemLocale.ParameterType.FullName | Should be 'System.String' + } + It 'SystemLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.SystemLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SystemLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.SystemLocale.Attributes.Position | Should be '7' + } + It 'Does SystemLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SystemLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SystemLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SystemLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SystemLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SystemLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for SystemLocale '{ + $function.Definition.Contains('.PARAMETER SystemLocale') | Should Be 'True' + } + It 'Has a Parameter called UserLocale' { + $Function.Parameters.Keys.Contains('UserLocale') | Should Be 'True' + } + It 'UserLocale Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.UserLocale.Attributes.Mandatory | Should be 'False' + } + It 'UserLocale Parameter is of String Type' { + $Function.Parameters.UserLocale.ParameterType.FullName | Should be 'System.String' + } + It 'UserLocale Parameter is member of ParameterSets' { + [String]$Function.Parameters.UserLocale.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'UserLocale Parameter Position is defined correctly' { + [String]$Function.Parameters.UserLocale.Attributes.Position | Should be '8' + } + It 'Does UserLocale Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.UserLocale.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does UserLocale Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.UserLocale.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does UserLocale Parameter use advanced parameter Validation? ' { + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.UserLocale.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for UserLocale '{ + $function.Definition.Contains('.PARAMETER UserLocale') | Should Be 'True' + } + It 'Has a Parameter called UILanguage' { + $Function.Parameters.Keys.Contains('UILanguage') | Should Be 'True' + } + It 'UILanguage Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.UILanguage.Attributes.Mandatory | Should be 'False' + } + It 'UILanguage Parameter is of String Type' { + $Function.Parameters.UILanguage.ParameterType.FullName | Should be 'System.String' + } + It 'UILanguage Parameter is member of ParameterSets' { + [String]$Function.Parameters.UILanguage.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'UILanguage Parameter Position is defined correctly' { + [String]$Function.Parameters.UILanguage.Attributes.Position | Should be '9' + } + It 'Does UILanguage Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.UILanguage.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does UILanguage Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.UILanguage.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does UILanguage Parameter use advanced parameter Validation? ' { + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.UILanguage.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'True' + } + It 'Has Parameter Help Text for UILanguage '{ + $function.Definition.Contains('.PARAMETER UILanguage') | Should Be 'True' + } + It 'Has a Parameter called Timezone' { + $Function.Parameters.Keys.Contains('Timezone') | Should Be 'True' + } + It 'Timezone Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Timezone.Attributes.Mandatory | Should be 'False' + } + It 'Timezone Parameter is of String Type' { + $Function.Parameters.Timezone.ParameterType.FullName | Should be 'System.String' + } + It 'Timezone Parameter is member of ParameterSets' { + [String]$Function.Parameters.Timezone.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Timezone Parameter Position is defined correctly' { + [String]$Function.Parameters.Timezone.Attributes.Position | Should be '10' + } + It 'Does Timezone Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Timezone.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Timezone Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Timezone.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Timezone Parameter use advanced parameter Validation? ' { + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Timezone.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Timezone '{ + $function.Definition.Contains('.PARAMETER Timezone') | Should Be 'True' + } + It 'Has a Parameter called RegisteredOwner' { + $Function.Parameters.Keys.Contains('RegisteredOwner') | Should Be 'True' + } + It 'RegisteredOwner Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RegisteredOwner.Attributes.Mandatory | Should be 'False' + } + It 'RegisteredOwner Parameter is of String Type' { + $Function.Parameters.RegisteredOwner.ParameterType.FullName | Should be 'System.String' + } + It 'RegisteredOwner Parameter is member of ParameterSets' { + [String]$Function.Parameters.RegisteredOwner.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RegisteredOwner Parameter Position is defined correctly' { + [String]$Function.Parameters.RegisteredOwner.Attributes.Position | Should be '11' + } + It 'Does RegisteredOwner Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RegisteredOwner.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RegisteredOwner Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RegisteredOwner.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RegisteredOwner Parameter use advanced parameter Validation? ' { + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOwner.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RegisteredOwner '{ + $function.Definition.Contains('.PARAMETER RegisteredOwner') | Should Be 'True' + } + It 'Has a Parameter called RegisteredOrganization' { + $Function.Parameters.Keys.Contains('RegisteredOrganization') | Should Be 'True' + } + It 'RegisteredOrganization Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.Mandatory | Should be 'False' + } + It 'RegisteredOrganization Parameter is of String Type' { + $Function.Parameters.RegisteredOrganization.ParameterType.FullName | Should be 'System.String' + } + It 'RegisteredOrganization Parameter is member of ParameterSets' { + [String]$Function.Parameters.RegisteredOrganization.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RegisteredOrganization Parameter Position is defined correctly' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.Position | Should be '12' + } + It 'Does RegisteredOrganization Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RegisteredOrganization Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RegisteredOrganization.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RegisteredOrganization Parameter use advanced parameter Validation? ' { + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RegisteredOrganization.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RegisteredOrganization '{ + $function.Definition.Contains('.PARAMETER RegisteredOrganization') | Should Be 'True' + } + It 'Has a Parameter called ClientCertificatePath' { + $Function.Parameters.Keys.Contains('ClientCertificatePath') | Should Be 'True' + } + It 'ClientCertificatePath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ClientCertificatePath.Attributes.Mandatory | Should be 'False' + } + It 'ClientCertificatePath Parameter is of String Type' { + $Function.Parameters.ClientCertificatePath.ParameterType.FullName | Should be 'System.String' + } + It 'ClientCertificatePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ClientCertificatePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ClientCertificatePath Parameter Position is defined correctly' { + [String]$Function.Parameters.ClientCertificatePath.Attributes.Position | Should be '13' + } + It 'Does ClientCertificatePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ClientCertificatePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ClientCertificatePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ClientCertificatePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ClientCertificatePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ClientCertificatePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ClientCertificatePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.ClientCertificatePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ClientCertificatePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ClientCertificatePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ClientCertificatePath '{ + $function.Definition.Contains('.PARAMETER ClientCertificatePath') | Should Be 'True' + } + It 'Has a Parameter called RootCertificatePath' { + $Function.Parameters.Keys.Contains('RootCertificatePath') | Should Be 'True' + } + It 'RootCertificatePath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.RootCertificatePath.Attributes.Mandatory | Should be 'False' + } + It 'RootCertificatePath Parameter is of String Type' { + $Function.Parameters.RootCertificatePath.ParameterType.FullName | Should be 'System.String' + } + It 'RootCertificatePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.RootCertificatePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'RootCertificatePath Parameter Position is defined correctly' { + [String]$Function.Parameters.RootCertificatePath.Attributes.Position | Should be '14' + } + It 'Does RootCertificatePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.RootCertificatePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does RootCertificatePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.RootCertificatePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does RootCertificatePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.RootCertificatePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.RootCertificatePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'True' + $Function.Parameters.RootCertificatePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.RootCertificatePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.RootCertificatePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for RootCertificatePath '{ + $function.Definition.Contains('.PARAMETER RootCertificatePath') | Should Be 'True' + } + It 'Has a Parameter called BootDelay' { + $Function.Parameters.Keys.Contains('BootDelay') | Should Be 'True' + } + It 'BootDelay Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.BootDelay.Attributes.Mandatory | Should be 'False' + } + It 'BootDelay Parameter is of UInt16 Type' { + $Function.Parameters.BootDelay.ParameterType.FullName | Should be 'System.UInt16' + } + It 'BootDelay Parameter is member of ParameterSets' { + [String]$Function.Parameters.BootDelay.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'BootDelay Parameter Position is defined correctly' { + [String]$Function.Parameters.BootDelay.Attributes.Position | Should be '15' + } + It 'Does BootDelay Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.BootDelay.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does BootDelay Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.BootDelay.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does BootDelay Parameter use advanced parameter Validation? ' { + $Function.Parameters.BootDelay.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.BootDelay.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.BootDelay.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.BootDelay.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.BootDelay.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for BootDelay '{ + $function.Definition.Contains('.PARAMETER BootDelay') | Should Be 'True' + } + It 'Has a Parameter called SecureBoot' { + $Function.Parameters.Keys.Contains('SecureBoot') | Should Be 'True' + } + It 'SecureBoot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SecureBoot.Attributes.Mandatory | Should be 'False' + } + It 'SecureBoot Parameter is of Boolean Type' { + $Function.Parameters.SecureBoot.ParameterType.FullName | Should be 'System.Boolean' + } + It 'SecureBoot Parameter is member of ParameterSets' { + [String]$Function.Parameters.SecureBoot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SecureBoot Parameter Position is defined correctly' { + [String]$Function.Parameters.SecureBoot.Attributes.Position | Should be '16' + } + It 'Does SecureBoot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SecureBoot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SecureBoot.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SecureBoot Parameter use advanced parameter Validation? ' { + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SecureBoot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SecureBoot '{ + $function.Definition.Contains('.PARAMETER SecureBoot') | Should Be 'True' + } + It 'Has a Parameter called CustomBootstrapOrder' { + $Function.Parameters.Keys.Contains('CustomBootstrapOrder') | Should Be 'True' + } + It 'CustomBootstrapOrder Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.CustomBootstrapOrder.Attributes.Mandatory | Should be 'False' + } + It 'CustomBootstrapOrder Parameter is of String Type' { + $Function.Parameters.CustomBootstrapOrder.ParameterType.FullName | Should be 'System.String' + } + It 'CustomBootstrapOrder Parameter is member of ParameterSets' { + [String]$Function.Parameters.CustomBootstrapOrder.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'CustomBootstrapOrder Parameter Position is defined correctly' { + [String]$Function.Parameters.CustomBootstrapOrder.Attributes.Position | Should be '17' + } + It 'Does CustomBootstrapOrder Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.CustomBootstrapOrder.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does CustomBootstrapOrder Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.CustomBootstrapOrder.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does CustomBootstrapOrder Parameter use advanced parameter Validation? ' { + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.CustomBootstrapOrder.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for CustomBootstrapOrder '{ + $function.Definition.Contains('.PARAMETER CustomBootstrapOrder') | Should Be 'True' + } + It 'Has a Parameter called GuestIntegrationServices' { + $Function.Parameters.Keys.Contains('GuestIntegrationServices') | Should Be 'True' + } + It 'GuestIntegrationServices Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Mandatory | Should be 'False' + } + It 'GuestIntegrationServices Parameter is of Boolean Type' { + $Function.Parameters.GuestIntegrationServices.ParameterType.FullName | Should be 'System.Boolean' + } + It 'GuestIntegrationServices Parameter is member of ParameterSets' { + [String]$Function.Parameters.GuestIntegrationServices.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'GuestIntegrationServices Parameter Position is defined correctly' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.Position | Should be '18' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does GuestIntegrationServices Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.GuestIntegrationServices.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does GuestIntegrationServices Parameter use advanced parameter Validation? ' { + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.GuestIntegrationServices.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for GuestIntegrationServices '{ + $function.Definition.Contains('.PARAMETER GuestIntegrationServices') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Start/Start-Lab.ps1 b/Public/Start/Start-Lab.ps1 new file mode 100644 index 00000000..c1939516 --- /dev/null +++ b/Public/Start/Start-Lab.ps1 @@ -0,0 +1,76 @@ +function Start-Lab { + +<# + .SYNOPSIS + Starts all VMs in a lab in a predefined order. + .DESCRIPTION + The Start-Lab cmdlet starts all nodes defined in a PowerShell DSC configuration document, in a preconfigured + order. + + Unlike the standard Start-VM cmdlet, the Start-Lab cmdlet will read the specified PowerShell DSC configuration + document and infer the required start up order. + + The PowerShell DSC configuration document can define the start/stop order of the virtual machines and the boot + delay between each VM power operation. This is defined with the BootOrder and BootDelay properties. The lower + the virtual machine's BootOrder index, the earlier it is started (in relation to the other VMs). + + For example, a VM with a BootOrder index of 10 will be started before a VM with a BootOrder index of 11. All + virtual machines receive a BootOrder value of 99 unless specified otherwise. + + The delay between each power operation is defined with the BootDelay property. This value is specified in + seconds and is enforced between starting or stopping a virtual machine. + + For example, a VM with a BootDelay of 30 will enforce a 30 second delay after being powered on or after the + power off command is issued. All VMs receive a BootDelay value of 0 (no delay) unless specified otherwise. + .PARAMETER ConfigurationData + Specifies a PowerShell DSC configuration data hashtable or a path to an existing PowerShell DSC .psd1 + configuration document. + .LINK + about_ConfigurationData + Stop-Lab +#> + [CmdletBinding()] + param ( + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + $nodes = @(); + $ConfigurationData.AllNodes | + Where-Object { $_.NodeName -ne '*' } | + ForEach-Object { + $nodes += [PSCustomObject] (ResolveLabVMProperties -NodeName $_.NodeName -ConfigurationData $ConfigurationData); + }; + + $currentGroupCount = 0; + $bootGroups = $nodes | Sort-Object -Property BootOrder | Group-Object -Property BootOrder; + $bootGroups | ForEach-Object { + $nodeDisplayNames = $_.Group.NodeDisplayName; + $nodeDisplayNamesString = $nodeDisplayNames -join ', '; + $currentGroupCount++; + [System.Int32] $percentComplete = ($currentGroupCount / $bootGroups.Count) * 100; + $activity = $localized.ConfiguringNode -f $nodeDisplayNamesString; + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + WriteVerbose ($localized.StartingVirtualMachine -f $nodeDisplayNamesString); + Start-VM -Name $nodeDisplayNames; + + $maxGroupBootDelay = $_.Group.BootDelay | Sort-Object -Descending | Select-Object -First 1; + if (($maxGroupBootDelay -gt 0) -and ($currentGroupCount -lt $bootGroups.Count)) { + WriteVerbose ($localized.WaitingForVirtualMachine -f $maxGroupBootDelay, $nodeDisplayNamesString); + for ($i = 1; $i -le $maxGroupBootDelay; $i++) { + [System.Int32] $waitPercentComplete = ($i / $maxGroupBootDelay) * 100; + $waitActivity = $localized.WaitingForVirtualMachine -f $maxGroupBootDelay, $nodeDisplayNamesString; + Write-Progress -ParentId 42 -Activity $waitActivity -PercentComplete $waitPercentComplete; + Start-Sleep -Seconds 1; + } + Write-Progress -Activity $waitActivity -Completed; + } #end if boot delay + } #end foreach boot group + Write-Progress -Id 42 -Activity $activity -Completed; + } #end process + +} + diff --git a/Public/Start/Start-LabConfiguration.ps1 b/Public/Start/Start-LabConfiguration.ps1 new file mode 100644 index 00000000..5c516c0e --- /dev/null +++ b/Public/Start/Start-LabConfiguration.ps1 @@ -0,0 +1,173 @@ +function Start-LabConfiguration { + +<# + .SYNOPSIS + Invokes the deployment and configuration of a VM for each node defined in a PowerShell DSC configuration + document. + .DESCRIPTION + The Start-LabConfiguration initiates the configuration of all nodes defined in a PowerShell DSC configuration + document. The AllNodes array is enumerated and a virtual machine is created per node, using the NodeName + property. + + If any existing virtual machine exists with the same name as the NodeName declaration of the AllNodes array, + the cmdlet will throw an error. If this behaviour is not desired, you can forcibly remove the existing VM + with the -Force parameter. NOTE: THE VIRTUAL MACHINE'S EXISTING DATA WILL BE LOST. + + The virtual machines' local administrator password must be specified when creating the lab VMs. The local + administrator password can be specified as a [PSCredential] or a [SecureString] type. If a [PSCredential] is + used then the username is not used. + + It is possible to override the module's virtual machine default settings by specifying the required property + on the node hashtable in the PowerShell DSC configuration document. Default settings include the Operating + System image to use, the amount of memory assigned to the virtual machine and/or the virtual switch to + connect the virtual machine to. If the settings are not overridden, the module's defaults are used. Use the + Get-LabVMDefault cmdlet to view the module's default values. + + Each virtual machine created by the Start-LabConfiguration cmdlet, has its PowerShell DSC configuraion (.mof) + file injected into the VHD file as it is created. This configuration is then applied during the first boot + process to ensure the virtual machine is configured as required. If the path to the VM's .mof files is not + specified, the module's default Configuration directory is used. Use the Get-LabHostDefault cmdlet to view + the module's default Configuration directory path. + + The virtual machine .mof files must be created before creating the lab. If any .mof files are missing, the + Start-LabConfiguration cmdlet will generate an error. You can choose to ignore this error by specifying + the -SkipMofCheck parameter. If you skip the .mof file check - and no .mof file is found - no configuration + will be applied to the virtual machine's Operating System settings. + + When deploying a lab, the module will create a default baseline snapshot of all virtual machines. This + snapshot can be used to revert all VMs back to their default configuration. If this snapshot is not + required, it can be surpressed with the -NoSnapshot parameter. + .NOTES + The same local administrator password is used for all virtual machines created in the same lab configuration. + .PARAMETER ConfigurationData + Specifies a PowerShell DSC configuration data hashtable or a path to an existing PowerShell DSC .psd1 + configuration document used to create the virtual machines. One virtual machine is created per node defined + in the AllNodes array. + .PARAMETER Credential + Specifies the local administrator password of all virtual machines in the lab configuration. The same + password is used for all virtual machines in the same lab configuration. The username is not used. + .PARAMETER Password + Specifies the local administrator password of all virtual machines in the lab configuration. The same + password is used for all virtual machines in the same lab configuration. + .PARAMETER Path + Specifies the directory path containing the individual PowerShell DSC .mof files. If not specified, the + module's default location is used. + .PARAMETER NoSnapshot + Specifies that no default snapshot will be taken when creating the virtual machine. + + NOTE: If no default snapshot is not created, the lab cannot be restored to its initial configuration + with the Reset-Lab cmdlet. + .PARAMETER SkipMofCheck + Specifies that the module will configure a virtual machines that do not have a corresponding .mof file + located in the -Path specfified. By default, if any .mof file cannot be located then the cmdlet will + generate an error. + + NOTE: If no .mof file is found and the -SkipMofCheck parameter is specified, no configuration will be + applied to the virtual machine's Operating System configuration. + .PARAMETER IgnorePendingReboot + The host's configuration is checked before invoking a lab configuration, including checking for pending + reboots. The -IgnorePendingReboot specifies that a pending reboot should be ignored and the lab + configuration applied. + .PARAMETER Force + Specifies that any existing virtual machine with a matching name, will be removed and recreated. By + default, if a virtual machine already exists with the same name, the cmdlet will generate an error. + + NOTE: If the -Force parameter is specified - and a virtual machine with the same name already exists - + ALL EXISTING DATA WITHIN THE VM WILL BE LOST. + .LINK + about_ConfigurationData + about_Bootstrap + Get-LabHostDefault + Set-LabHostDefault + Get-LabVMDefault + Set-LabVMDefault + Reset-Lab +#> + [CmdletBinding(DefaultParameterSetName = 'PSCredential')] + param ( + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Local administrator password of the VM. The username is NOT used. + [Parameter(ParameterSetName = 'PSCredential', ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.Management.Automation.PSCredential] + [System.Management.Automation.CredentialAttribute()] + $Credential = (& $credentialCheckScriptBlock), + + ## Local administrator password of the VM. + [Parameter(Mandatory, ParameterSetName = 'Password', ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.Security.SecureString] $Password, + + ## Path to .MOF files created from the DSC configuration + [Parameter(ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] + [System.String] $Path = (GetLabHostDSCConfigurationPath), + + ## Skip creating baseline snapshots + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $NoSnapshot, + + ## Forces a reconfiguration/redeployment of all nodes. + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $Force, + + ## Ignores missing MOF file + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $SkipMofCheck, + + ## Skips pending reboot check + [Parameter(ValueFromPipelineByPropertyName)] + [System.Management.Automation.SwitchParameter] $IgnorePendingReboot + ) + begin { + ## If we have only a secure string, create a PSCredential + if ($PSCmdlet.ParameterSetName -eq 'Password') { + $Credential = New-Object -TypeName 'System.Management.Automation.PSCredential' -ArgumentList 'LocalAdministrator', $Password; + } + if (-not $Credential) { throw ($localized.CannotProcessCommandError -f 'Credential'); } + elseif ($Credential.Password.Length -eq 0) { throw ($localized.CannotBindArgumentError -f 'Password'); } + + if (-not (Test-LabHostConfiguration -IgnorePendingReboot:$IgnorePendingReboot) -and (-not $Force)) { + throw $localized.HostConfigurationTestError; + } + } + process { + WriteVerbose $localized.StartedLabConfiguration; + $nodes = $ConfigurationData.AllNodes | Where-Object { $_.NodeName -ne '*' }; + + $Path = ResolvePathEx -Path $Path; + foreach ($node in $nodes) { + $testLabConfigurationMofParams = @{ + ConfigurationData = $ConfigurationData; + Name = $node.NodeName; + Path = $Path; + } + TestLabConfigurationMof @testLabConfigurationMofParams -SkipMofCheck:$SkipMofCheck; + } #end foreach node + + $currentNodeCount = 0; + foreach ($node in (Test-LabConfiguration -ConfigurationData $ConfigurationData)) { + $currentNodeCount++; + [System.Int16] $percentComplete = (($currentNodeCount / $nodes.Count) * 100) - 1; + $activity = $localized.ConfiguringNode -f $node.Name; + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + if ($node.IsConfigured -and $Force) { + WriteVerbose ($localized.NodeForcedConfiguration -f $node.Name); + NewLabVM -Name $node.Name -ConfigurationData $ConfigurationData -Path $Path -NoSnapshot:$NoSnapshot -Credential $Credential; + } + elseif ($node.IsConfigured) { + WriteVerbose ($localized.NodeAlreadyConfigured -f $node.Name); + } + else { + WriteVerbose ($localized.NodeMissingOrMisconfigured -f $node.Name); + NewLabVM -Name $node.Name -ConfigurationData $ConfigurationData -Path $Path -NoSnapshot:$NoSnapshot -Credential $Credential; + } + } + Write-Progress -Id 42 -Activity $activity -Completed; + WriteVerbose $localized.FinishedLabConfiguration; + } #end process + +} + diff --git a/Public/Start/Start-LabHostConfiguration.ps1 b/Public/Start/Start-LabHostConfiguration.ps1 new file mode 100644 index 00000000..6f971626 --- /dev/null +++ b/Public/Start/Start-LabHostConfiguration.ps1 @@ -0,0 +1,58 @@ +function Start-LabHostConfiguration { + +<# + .SYNOPSIS + Invokes the configuration of the lab host. + .DESCRIPTION + The Start-LabHostConfiguration cmdlet invokes the configuration of the local host computer. + .LINK + Test-LabHostConfiguration + Get-LabHostConfiguration +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( ) + process { + WriteVerbose $localized.StartedHostConfiguration; + ## Create required directory structure + $hostDefaults = GetConfigurationData -Configuration Host; + foreach ($property in $hostDefaults.PSObject.Properties) { + + if (($property.Name.EndsWith('Path')) -and (-not [System.String]::IsNullOrEmpty($property.Value))) { + + ## DismPath is not a folder and should be ignored (#159) + if ($property.Name -ne 'DismPath') { + + [ref] $null = NewDirectory -Path $(ResolvePathEx -Path $Property.Value) -ErrorAction Stop; + } + } + } + + # Once all the path are created, check if the hostdefaults.Json file in the $env:ALLUSERSPROFILE is doesn't have entries with %SYSTEMDRIVE% in it + # Many subsequent call are failing to Get-LabImage, Test-LabHostConfiguration which do not resolve the "%SYSTEMDRIVE%" in the path for Host defaults + foreach ($property in $($hostDefaults.PSObject.Properties | Where-Object -Property TypeNameOfValue -eq 'System.String')) { + if ($property.Value.Contains('%')) { + # if the Path for host defaults contains a '%' character then resolve it + $resolvedPath = ResolvePathEx -Path $Property.Value; + # update the hostdefaults Object + $hostDefaults.($property.Name) = $resolvedPath; + $hostdefaultupdated = $true; + } + } + if ($hostdefaultupdated) { + # Write the changes back to the json file in the $env:ALLUSERSPROFILE + $hostDefaults | ConvertTo-Json | Out-File -FilePath $(ResolveConfigurationDataPath -Configuration host) + } + + $labHostSetupConfiguation = GetLabHostSetupConfiguration; + foreach ($configuration in $labHostSetupConfiguation) { + ImportDscResource -ModuleName $configuration.ModuleName -ResourceName $configuration.ResourceName -Prefix $configuration.Prefix -UseDefault:$configuration.UseDefault; + WriteVerbose ($localized.TestingNodeConfiguration -f $Configuration.Description); + [ref] $null = InvokeDscResource -ResourceName $configuration.Prefix -Parameters $configuration.Parameters; + ## TODO: Need to check for pending reboots.. + } + WriteVerbose $localized.FinishedHostConfiguration; + } #end process + +} + diff --git a/Public/Start/Tests/Start-Lab.Functional.Tests.ps1 b/Public/Start/Tests/Start-Lab.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Start/Tests/Start-Lab.Tests.ps1 b/Public/Start/Tests/Start-Lab.Tests.ps1 new file mode 100644 index 00000000..b1a94064 --- /dev/null +++ b/Public/Start/Tests/Start-Lab.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'Start-Lab Tests' { + + Context 'Parameters for Start-Lab'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Start/Tests/Start-LabConfiguration.Functional.Tests.ps1 b/Public/Start/Tests/Start-LabConfiguration.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Start/Tests/Start-LabConfiguration.Tests.ps1 b/Public/Start/Tests/Start-LabConfiguration.Tests.ps1 new file mode 100644 index 00000000..99d24b5c --- /dev/null +++ b/Public/Start/Tests/Start-LabConfiguration.Tests.ps1 @@ -0,0 +1,283 @@ +Describe 'Start-LabConfiguration Tests' { + + Context 'Parameters for Start-LabConfiguration'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '-2147483648' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called Credential' { + $Function.Parameters.Keys.Contains('Credential') | Should Be 'True' + } + It 'Credential Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Credential.Attributes.Mandatory | Should be 'False' + } + It 'Credential Parameter is of PSCredential Type' { + $Function.Parameters.Credential.ParameterType.FullName | Should be 'System.Management.Automation.PSCredential' + } + It 'Credential Parameter is member of ParameterSets' { + [String]$Function.Parameters.Credential.ParameterSets.Keys | Should Be 'PSCredential' + } + It 'Credential Parameter Position is defined correctly' { + [String]$Function.Parameters.Credential.Attributes.Position | Should be '-2147483648' + } + It 'Does Credential Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Credential Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Credential.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Credential Parameter use advanced parameter Validation? ' { + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Credential.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Credential '{ + $function.Definition.Contains('.PARAMETER Credential') | Should Be 'True' + } + It 'Has a Parameter called Password' { + $Function.Parameters.Keys.Contains('Password') | Should Be 'True' + } + It 'Password Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Password.Attributes.Mandatory | Should be 'True' + } + It 'Password Parameter is of SecureString Type' { + $Function.Parameters.Password.ParameterType.FullName | Should be 'System.Security.SecureString' + } + It 'Password Parameter is member of ParameterSets' { + [String]$Function.Parameters.Password.ParameterSets.Keys | Should Be 'Password' + } + It 'Password Parameter Position is defined correctly' { + [String]$Function.Parameters.Password.Attributes.Position | Should be '-2147483648' + } + It 'Does Password Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Password.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Password Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Password.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Password Parameter use advanced parameter Validation? ' { + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Password.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Password '{ + $function.Definition.Contains('.PARAMETER Password') | Should Be 'True' + } + It 'Has a Parameter called Path' { + $Function.Parameters.Keys.Contains('Path') | Should Be 'True' + } + It 'Path Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Path.Attributes.Mandatory | Should be 'False' + } + It 'Path Parameter is of String Type' { + $Function.Parameters.Path.ParameterType.FullName | Should be 'System.String' + } + It 'Path Parameter is member of ParameterSets' { + [String]$Function.Parameters.Path.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Path Parameter Position is defined correctly' { + [String]$Function.Parameters.Path.Attributes.Position | Should be '-2147483648' + } + It 'Does Path Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Path Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Path.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Path Parameter use advanced parameter Validation? ' { + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Path.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Path '{ + $function.Definition.Contains('.PARAMETER Path') | Should Be 'True' + } + It 'Has a Parameter called NoSnapshot' { + $Function.Parameters.Keys.Contains('NoSnapshot') | Should Be 'True' + } + It 'NoSnapshot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.NoSnapshot.Attributes.Mandatory | Should be 'False' + } + It 'NoSnapshot Parameter is of SwitchParameter Type' { + $Function.Parameters.NoSnapshot.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'NoSnapshot Parameter is member of ParameterSets' { + [String]$Function.Parameters.NoSnapshot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'NoSnapshot Parameter Position is defined correctly' { + [String]$Function.Parameters.NoSnapshot.Attributes.Position | Should be '-2147483648' + } + It 'Does NoSnapshot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.NoSnapshot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does NoSnapshot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.NoSnapshot.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does NoSnapshot Parameter use advanced parameter Validation? ' { + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.NoSnapshot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for NoSnapshot '{ + $function.Definition.Contains('.PARAMETER NoSnapshot') | Should Be 'True' + } + It 'Has a Parameter called Force' { + $Function.Parameters.Keys.Contains('Force') | Should Be 'True' + } + It 'Force Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False' + } + It 'Force Parameter is of SwitchParameter Type' { + $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'Force Parameter is member of ParameterSets' { + [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Force Parameter Position is defined correctly' { + [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648' + } + It 'Does Force Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Force Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Force Parameter use advanced parameter Validation? ' { + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Force '{ + $function.Definition.Contains('.PARAMETER Force') | Should Be 'True' + } + It 'Has a Parameter called SkipMofCheck' { + $Function.Parameters.Keys.Contains('SkipMofCheck') | Should Be 'True' + } + It 'SkipMofCheck Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.SkipMofCheck.Attributes.Mandatory | Should be 'False' + } + It 'SkipMofCheck Parameter is of SwitchParameter Type' { + $Function.Parameters.SkipMofCheck.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'SkipMofCheck Parameter is member of ParameterSets' { + [String]$Function.Parameters.SkipMofCheck.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'SkipMofCheck Parameter Position is defined correctly' { + [String]$Function.Parameters.SkipMofCheck.Attributes.Position | Should be '-2147483648' + } + It 'Does SkipMofCheck Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.SkipMofCheck.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does SkipMofCheck Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.SkipMofCheck.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does SkipMofCheck Parameter use advanced parameter Validation? ' { + $Function.Parameters.SkipMofCheck.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.SkipMofCheck.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.SkipMofCheck.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.SkipMofCheck.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.SkipMofCheck.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for SkipMofCheck '{ + $function.Definition.Contains('.PARAMETER SkipMofCheck') | Should Be 'True' + } + It 'Has a Parameter called IgnorePendingReboot' { + $Function.Parameters.Keys.Contains('IgnorePendingReboot') | Should Be 'True' + } + It 'IgnorePendingReboot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.IgnorePendingReboot.Attributes.Mandatory | Should be 'False' + } + It 'IgnorePendingReboot Parameter is of SwitchParameter Type' { + $Function.Parameters.IgnorePendingReboot.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'IgnorePendingReboot Parameter is member of ParameterSets' { + [String]$Function.Parameters.IgnorePendingReboot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'IgnorePendingReboot Parameter Position is defined correctly' { + [String]$Function.Parameters.IgnorePendingReboot.Attributes.Position | Should be '-2147483648' + } + It 'Does IgnorePendingReboot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.IgnorePendingReboot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does IgnorePendingReboot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.IgnorePendingReboot.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does IgnorePendingReboot Parameter use advanced parameter Validation? ' { + $Function.Parameters.IgnorePendingReboot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.IgnorePendingReboot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.IgnorePendingReboot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.IgnorePendingReboot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.IgnorePendingReboot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for IgnorePendingReboot '{ + $function.Definition.Contains('.PARAMETER IgnorePendingReboot') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Start/Tests/Start-LabHostConfiguration.Functional.Tests.ps1 b/Public/Start/Tests/Start-LabHostConfiguration.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Start/Tests/Start-LabHostConfiguration.Tests.ps1 b/Public/Start/Tests/Start-LabHostConfiguration.Tests.ps1 new file mode 100644 index 00000000..2671f8db --- /dev/null +++ b/Public/Start/Tests/Start-LabHostConfiguration.Tests.ps1 @@ -0,0 +1,35 @@ +Describe 'Start-LabHostConfiguration Tests' { + + Context 'Parameters for Start-LabHostConfiguration'{ + + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Stop/Stop-Lab.ps1 b/Public/Stop/Stop-Lab.ps1 new file mode 100644 index 00000000..4128a8c4 --- /dev/null +++ b/Public/Stop/Stop-Lab.ps1 @@ -0,0 +1,64 @@ +function Stop-Lab { + +<# + .SYNOPSIS + Stops all VMs in a lab in a predefined order. + .DESCRIPTION + The Stop-Lab cmdlet stops all nodes defined in a PowerShell DSC configuration document, in a preconfigured + order. + + Unlike the standard Stop-VM cmdlet, the Stop-Lab cmdlet will read the specified PowerShell DSC configuration + document and infer the required shutdown order. + + The PowerShell DSC configuration document can define the start/stop order of the virtual machines and the boot + delay between each VM power operation. This is defined with the BootOrder and BootDelay properties. The higher + the virtual machine's BootOrder index, the earlier it is stopped (in relation to the other VMs). + + For example, a VM with a BootOrder index of 11 will be stopped before a VM with a BootOrder index of 10. All + virtual machines receive a BootOrder value of 99 unless specified otherwise. + + The delay between each power operation is defined with the BootDelay property. This value is specified in + seconds and is enforced between starting or stopping a virtual machine. + + For example, a VM with a BootDelay of 30 will enforce a 30 second delay after being powered on or after the + power off command is issued. All VMs receive a BootDelay value of 0 (no delay) unless specified otherwise. + .PARAMETER ConfigurationData + Specifies a PowerShell DSC configuration data hashtable or a path to an existing PowerShell DSC .psd1 + configuration document. + .LINK + about_ConfigurationData + Start-Lab +#> + [CmdletBinding()] + param ( + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + $nodes = @(); + $ConfigurationData.AllNodes | + Where-Object { $_.NodeName -ne '*' } | + ForEach-Object { + $nodes += [PSCustomObject] (ResolveLabVMProperties -NodeName $_.NodeName -ConfigurationData $ConfigurationData); + }; + + $currentGroupCount = 0; + $bootGroups = $nodes | Sort-Object -Property BootOrder -Descending | Group-Object -Property BootOrder; + $bootGroups | ForEach-Object { + $nodeDisplayNames = $_.Group.NodeDisplayName; + $nodeDisplayNamesString = $nodeDisplayNames -join ', '; + $currentGroupCount++; + [System.Int32] $percentComplete = ($currentGroupCount / $bootGroups.Count) * 100; + $activity = $localized.ConfiguringNode -f $nodeDisplayNamesString; + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + WriteVerbose ($localized.StoppingVirtualMachine -f $nodeDisplayNamesString); + Stop-VM -Name $nodeDisplayNames -Force; + } #end foreach boot group + Write-Progress -Id 42 -Activity $activity -Completed; + } #end process + +} + diff --git a/Public/Stop/Tests/Stop-Lab.Functional.Tests.ps1 b/Public/Stop/Tests/Stop-Lab.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Stop/Tests/Stop-Lab.Tests.ps1 b/Public/Stop/Tests/Stop-Lab.Tests.ps1 new file mode 100644 index 00000000..cb48e180 --- /dev/null +++ b/Public/Stop/Tests/Stop-Lab.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'Stop-Lab Tests' { + + Context 'Parameters for Stop-Lab'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Test/Test-LabConfiguration.ps1 b/Public/Test/Test-LabConfiguration.ps1 new file mode 100644 index 00000000..baca63d9 --- /dev/null +++ b/Public/Test/Test-LabConfiguration.ps1 @@ -0,0 +1,50 @@ +function Test-LabConfiguration { + +<# + .SYNOPSIS + Tests the configuration of all VMs in a lab. + .DESCRIPTION + The Test-LabConfiguration determines whether all nodes defined in a PowerShell DSC configuration document + are configured correctly and returns the results. + + WANRING: Only the virtual machine configuration is checked, not in the internal VM configuration. For example, + the virtual machine's memory configuraiton, virtual switch configuration and processor count are tested. The + VM's operating system configuration is not checked. + .PARAMETER ConfigurationData + Specifies a PowerShell DSC configuration data hashtable or a path to an existing PowerShell DSC .psd1 + configuration document used to create the virtual machines. Each node defined in the AllNodes array is + tested. + .LINK + about_ConfigurationData + Start-LabConfiguration +#> + [CmdletBinding()] + param ( + ## Lab DSC configuration data + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + WriteVerbose $localized.StartedLabConfigurationTest; + $currentNodeCount = 0; + $nodes = $ConfigurationData.AllNodes | Where-Object { $_.NodeName -ne '*' }; + foreach ($node in $nodes) { + $currentNodeCount++; + $nodeProperties = ResolveLabVMProperties -NodeName $node.NodeName -ConfigurationData $ConfigurationData; + [System.Int16] $percentComplete = (($currentNodeCount / $nodes.Count) * 100) - 1; + $activity = $localized.ConfiguringNode -f $nodeProperties.NodeDisplayName; + Write-Progress -Id 42 -Activity $activity -PercentComplete $percentComplete; + $nodeResult = [PSCustomObject] @{ + Name = $nodeProperties.NodeName; + IsConfigured = Test-LabVM -Name $node.NodeName -ConfigurationData $ConfigurationData; + DisplayName = $nodeProperties.NodeDisplayName; + } + Write-Output -InputObject $nodeResult; + } + WriteVerbose $localized.FinishedLabConfigurationTest; + } #end process + +} + diff --git a/Public/Test/Test-LabHostConfiguration.ps1 b/Public/Test/Test-LabHostConfiguration.ps1 new file mode 100644 index 00000000..b093ab5d --- /dev/null +++ b/Public/Test/Test-LabHostConfiguration.ps1 @@ -0,0 +1,70 @@ +function Test-LabHostConfiguration { + +<# + .SYNOPSIS + Tests the lab host's configuration. + .DESCRIPTION + The Test-LabHostConfiguration tests the current configuration of the lab host. + .PARAMETER IgnorePendingReboot + Specifies a pending reboot does not fail the test. + .LINK + Get-LabHostConfiguration + Test-LabHostConfiguration +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + ## Skips pending reboot check + [Parameter()] + [System.Management.Automation.SwitchParameter] $IgnorePendingReboot + ) + process { + WriteVerbose $localized.StartedHostConfigurationTest; + ## Test folders/directories + $hostDefaults = GetConfigurationData -Configuration Host; + foreach ($property in $hostDefaults.PSObject.Properties) { + + if (($property.Name.EndsWith('Path')) -and (-not [System.String]::IsNullOrEmpty($property.Value))) { + + ## DismPath is not a folder and should be ignored (#159) + if ($property.Name -ne 'DismPath') { + + WriteVerbose ($localized.TestingPathExists -f $property.Value); + $resolvedPath = ResolvePathEx -Path $property.Value; + if (-not (Test-Path -Path $resolvedPath -PathType Container)) { + + WriteVerbose -Message ($localized.PathDoesNotExist -f $resolvedPath); + return $false; + } + } + } + } + + $labHostSetupConfiguration = GetLabHostSetupConfiguration; + foreach ($configuration in $labHostSetupConfiguration) { + $importDscResourceParams = @{ + ModuleName = $configuration.ModuleName; + ResourceName = $configuration.ResourceName; + Prefix = $configuration.Prefix; + UseDefault = $configuration.UseDefault; + } + ImportDscResource @importDscResourceParams; + WriteVerbose ($localized.TestingNodeConfiguration -f $Configuration.Description); + if (-not (TestDscResource -ResourceName $configuration.Prefix -Parameters $configuration.Parameters)) { + if ($configuration.Prefix -eq 'PendingReboot') { + WriteWarning $localized.PendingRebootWarning; + if (-not $IgnorePendingReboot) { + return $false; + } + } + else { + return $false; + } + } + } #end foreach labHostSetupConfiguration + WriteVerbose $localized.FinishedHostConfigurationTest; + return $true; + } #end process + +} + diff --git a/Public/Test/Test-LabImage.ps1 b/Public/Test/Test-LabImage.ps1 new file mode 100644 index 00000000..b30d2f62 --- /dev/null +++ b/Public/Test/Test-LabImage.ps1 @@ -0,0 +1,47 @@ +function Test-LabImage { + +<# + .SYNOPSIS + Tests whether a master/parent lab image is present. + .DESCRIPTION + The Test-LabImage cmdlet returns whether a specified disk image is present. + .PARAMETER Id + Specifies the media Id of the image to test. + .PARAMETER ConfigurationData + Specifies a PowerShell DSC configuration data hashtable or a path to an existing PowerShell DSC .psd1 + configuration document that contains the required media definition. + .EXAMPLE + Test-LabImage -Id 2012R2_x64_Standard_EN_Eval + + Tests whether the '-Id 2012R2_x64_Standard_EN_Eval' lab image is present. + .LINK + Get-LabImage +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $Id, + + ## Lab DSC configuration data + [Parameter(ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + + if (Get-LabImage @PSBoundParameters) { + + return $true; + } + else { + + return $false; + } + + } #end process + +} + diff --git a/Public/Test/Test-LabMedia.ps1 b/Public/Test/Test-LabMedia.ps1 new file mode 100644 index 00000000..e41c5437 --- /dev/null +++ b/Public/Test/Test-LabMedia.ps1 @@ -0,0 +1,48 @@ +function Test-LabMedia { + +<# + .SYNOPSIS + Tests whether lab media has already been successfully downloaded. + .DESCRIPTION + The Test-LabMedia cmdlet will check whether the specified media Id has been downloaded and its checksum is correct. + .PARAMETER Id + Specifies the media Id to test. +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String] $Id + ) + process { + + $hostDefaults = GetConfigurationData -Configuration Host; + $media = Get-LabMedia -Id $Id; + if ($media) { + + if (-not $hostDefaults.DisableLocalFileCaching) { + + $testResourceDownloadParams = @{ + DestinationPath = Join-Path -Path $hostDefaults.IsoPath -ChildPath $media.Filename; + Uri = $media.Uri; + Checksum = $media.Checksum; + } + return TestResourceDownload @testResourceDownloadParams; + } + else { + + ## Local file resource caching is disabled + return $true; + } + } + else { + + return $false; + } + + } #end process + +} + diff --git a/Public/Test/Test-LabResource.ps1 b/Public/Test/Test-LabResource.ps1 new file mode 100644 index 00000000..8435c884 --- /dev/null +++ b/Public/Test/Test-LabResource.ps1 @@ -0,0 +1,71 @@ +function Test-LabResource { + +<# + .SYNOPSIS + Tests whether a lab's resources are present. +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + ## PowerShell DSC configuration document (.psd1) containing lab metadata. + [Parameter(Mandatory, ValueFromPipeline)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData, + + ## Lab resource Id to test. + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ResourceId, + + ## Lab resource path + [Parameter(ValueFromPipelineByPropertyName)] + [AllowNull()] + [System.String] $ResourcePath + ) + begin { + + if (-not $ResourcePath) { + $hostDefaults = GetConfigurationData -Configuration Host; + $ResourcePath = $hostDefaults.ResourcePath; + } + + } + process { + + if ($resourceId) { + + $resources = ResolveLabResource -ConfigurationData $ConfigurationData -ResourceId $ResourceId; + } + else { + + $resources = $ConfigurationData.NonNodeData.($labDefaults.ModuleName).Resource; + } + + foreach ($resource in $resources) { + + $fileName = $resource.Id; + if ($resource.Filename) { $fileName = $resource.Filename; } + + $testResourceDownloadParams = @{ + DestinationPath = Join-Path -Path $ResourcePath -ChildPath $fileName;; + Uri = $resource.Uri; + } + + if ($resource.Checksum) { + + $testResourceDownloadParams['Checksum'] = $resource.Checksum; + } + + if (-not (TestResourceDownload @testResourceDownloadParams)) { + + return $false; + } + } #end foreach resource + + return $true; + + } #end process + +} + diff --git a/Public/Test/Test-LabVM.ps1 b/Public/Test/Test-LabVM.ps1 new file mode 100644 index 00000000..b9365a5a --- /dev/null +++ b/Public/Test/Test-LabVM.ps1 @@ -0,0 +1,92 @@ +function Test-LabVM { + +<# + .SYNOPSIS + Checks whether the (external) lab virtual machine is configured as required. +#> + [CmdletBinding()] + [OutputType([System.Boolean])] + param ( + ## Specifies the lab virtual machine/node name. + [Parameter(ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.String[]] $Name, + + ## Specifies a PowerShell DSC configuration document (.psd1) containing the lab configuration. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.Collections.Hashtable] + [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute()] + $ConfigurationData + ) + process { + + if (-not $Name) { + + $Name = $ConfigurationData.AllNodes | Where-Object NodeName -ne '*' | ForEach-Object { $_.NodeName } + } + + foreach ($vmName in $Name) { + + $isNodeCompliant = $true; + $node = ResolveLabVMProperties -NodeName $vmName -ConfigurationData $ConfigurationData; + WriteVerbose ($localized.TestingNodeConfiguration -f $node.NodeDisplayName); + + WriteVerbose ($localized.TestingVMConfiguration -f 'Image', $node.Media); + if (-not (Test-LabImage -Id $node.Media -ConfigurationData $ConfigurationData)) { + + $isNodeCompliant = $false; + } + else { + + ## No point testing switch, vhdx and VM if the image isn't available + WriteVerbose ($localized.TestingVMConfiguration -f 'Virtual Switch', $node.SwitchName); + foreach ($switchName in $node.SwitchName) { + + if (-not (TestLabSwitch -Name $switchName -ConfigurationData $ConfigurationData)) { + + $isNodeCompliant = $false; + } + } + + WriteVerbose ($localized.TestingVMConfiguration -f 'VHDX', $node.Media); + $testLabVMDiskParams = @{ + Name = $node.NodeDisplayName; + Media = $node.Media; + ConfigurationData = $ConfigurationData; + } + if (-not (TestLabVMDisk @testLabVMDiskParams -ErrorAction SilentlyContinue)) { + + $isNodeCompliant = $false; + } + else { + + ## No point testing VM if the VHDX isn't available + WriteVerbose ($localized.TestingVMConfiguration -f 'VM', $vmName); + $testLabVirtualMachineParams = @{ + Name = $node.NodeDisplayName; + SwitchName = $node.SwitchName; + Media = $node.Media; + StartupMemory = $node.StartupMemory; + MinimumMemory = $node.MinimumMemory; + MaximumMemory = $node.MaximumMemory; + ProcessorCount = $node.ProcessorCount; + MACAddress = $node.MACAddress; + SecureBoot = $node.SecureBoot; + GuestIntegrationServices = $node.GuestIntegrationServices; + ConfigurationData = $ConfigurationData; + } + if (-not (TestLabVirtualMachine @testLabVirtualMachineParams)) { + + $isNodeCompliant = $false; + } + } + } + + Write-Output -InputObject $isNodeCompliant; + + } #end foreach vm + + } #end process + +} + diff --git a/Public/Test/Tests/Test-LabConfiguration.Functional.Tests.ps1 b/Public/Test/Tests/Test-LabConfiguration.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Test/Tests/Test-LabConfiguration.Tests.ps1 b/Public/Test/Tests/Test-LabConfiguration.Tests.ps1 new file mode 100644 index 00000000..d4e2ded7 --- /dev/null +++ b/Public/Test/Tests/Test-LabConfiguration.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'Test-LabConfiguration Tests' { + + Context 'Parameters for Test-LabConfiguration'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Test/Tests/Test-LabHostConfiguration.Functional.Tests.ps1 b/Public/Test/Tests/Test-LabHostConfiguration.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Test/Tests/Test-LabHostConfiguration.Tests.ps1 b/Public/Test/Tests/Test-LabHostConfiguration.Tests.ps1 new file mode 100644 index 00000000..37d7fb68 --- /dev/null +++ b/Public/Test/Tests/Test-LabHostConfiguration.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'Test-LabHostConfiguration Tests' { + + Context 'Parameters for Test-LabHostConfiguration'{ + + It 'Has a Parameter called IgnorePendingReboot' { + $Function.Parameters.Keys.Contains('IgnorePendingReboot') | Should Be 'True' + } + It 'IgnorePendingReboot Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.IgnorePendingReboot.Attributes.Mandatory | Should be 'False' + } + It 'IgnorePendingReboot Parameter is of SwitchParameter Type' { + $Function.Parameters.IgnorePendingReboot.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter' + } + It 'IgnorePendingReboot Parameter is member of ParameterSets' { + [String]$Function.Parameters.IgnorePendingReboot.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'IgnorePendingReboot Parameter Position is defined correctly' { + [String]$Function.Parameters.IgnorePendingReboot.Attributes.Position | Should be '-2147483648' + } + It 'Does IgnorePendingReboot Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.IgnorePendingReboot.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does IgnorePendingReboot Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.IgnorePendingReboot.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does IgnorePendingReboot Parameter use advanced parameter Validation? ' { + $Function.Parameters.IgnorePendingReboot.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.IgnorePendingReboot.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.IgnorePendingReboot.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.IgnorePendingReboot.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.IgnorePendingReboot.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for IgnorePendingReboot '{ + $function.Definition.Contains('.PARAMETER IgnorePendingReboot') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Test/Tests/Test-LabImage.Functional.Tests.ps1 b/Public/Test/Tests/Test-LabImage.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Test/Tests/Test-LabImage.Tests.ps1 b/Public/Test/Tests/Test-LabImage.Tests.ps1 new file mode 100644 index 00000000..456af260 --- /dev/null +++ b/Public/Test/Tests/Test-LabImage.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'Test-LabImage Tests' { + + Context 'Parameters for Test-LabImage'{ + + It 'Has a Parameter called Id' { + $Function.Parameters.Keys.Contains('Id') | Should Be 'True' + } + It 'Id Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Id.Attributes.Mandatory | Should be 'True' + } + It 'Id Parameter is of String Type' { + $Function.Parameters.Id.ParameterType.FullName | Should be 'System.String' + } + It 'Id Parameter is member of ParameterSets' { + [String]$Function.Parameters.Id.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Id Parameter Position is defined correctly' { + [String]$Function.Parameters.Id.Attributes.Position | Should be '0' + } + It 'Does Id Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Id Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Id Parameter use advanced parameter Validation? ' { + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Id '{ + $function.Definition.Contains('.PARAMETER Id') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'False' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Test/Tests/Test-LabMedia.Functional.Tests.ps1 b/Public/Test/Tests/Test-LabMedia.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Test/Tests/Test-LabMedia.Tests.ps1 b/Public/Test/Tests/Test-LabMedia.Tests.ps1 new file mode 100644 index 00000000..1c1f41a4 --- /dev/null +++ b/Public/Test/Tests/Test-LabMedia.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'Test-LabMedia Tests' { + + Context 'Parameters for Test-LabMedia'{ + + It 'Has a Parameter called Id' { + $Function.Parameters.Keys.Contains('Id') | Should Be 'True' + } + It 'Id Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Id.Attributes.Mandatory | Should be 'True' + } + It 'Id Parameter is of String Type' { + $Function.Parameters.Id.ParameterType.FullName | Should be 'System.String' + } + It 'Id Parameter is member of ParameterSets' { + [String]$Function.Parameters.Id.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Id Parameter Position is defined correctly' { + [String]$Function.Parameters.Id.Attributes.Position | Should be '0' + } + It 'Does Id Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Id Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Id Parameter use advanced parameter Validation? ' { + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Id '{ + $function.Definition.Contains('.PARAMETER Id') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Test/Tests/Test-LabResource.Functional.Tests.ps1 b/Public/Test/Tests/Test-LabResource.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Test/Tests/Test-LabResource.Tests.ps1 b/Public/Test/Tests/Test-LabResource.Tests.ps1 new file mode 100644 index 00000000..b3110fe3 --- /dev/null +++ b/Public/Test/Tests/Test-LabResource.Tests.ps1 @@ -0,0 +1,128 @@ +Describe 'Test-LabResource Tests' { + + Context 'Parameters for Test-LabResource'{ + + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '0' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + It 'Has a Parameter called ResourceId' { + $Function.Parameters.Keys.Contains('ResourceId') | Should Be 'True' + } + It 'ResourceId Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ResourceId.Attributes.Mandatory | Should be 'False' + } + It 'ResourceId Parameter is of String Type' { + $Function.Parameters.ResourceId.ParameterType.FullName | Should be 'System.String' + } + It 'ResourceId Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourceId.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourceId Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourceId.Attributes.Position | Should be '1' + } + It 'Does ResourceId Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourceId.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourceId Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourceId.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ResourceId Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourceId.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourceId '{ + $function.Definition.Contains('.PARAMETER ResourceId') | Should Be 'True' + } + It 'Has a Parameter called ResourcePath' { + $Function.Parameters.Keys.Contains('ResourcePath') | Should Be 'True' + } + It 'ResourcePath Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.ResourcePath.Attributes.Mandatory | Should be 'False' + } + It 'ResourcePath Parameter is of String Type' { + $Function.Parameters.ResourcePath.ParameterType.FullName | Should be 'System.String' + } + It 'ResourcePath Parameter is member of ParameterSets' { + [String]$Function.Parameters.ResourcePath.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ResourcePath Parameter Position is defined correctly' { + [String]$Function.Parameters.ResourcePath.Attributes.Position | Should be '2' + } + It 'Does ResourcePath Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ResourcePath.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ResourcePath Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ResourcePath.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ResourcePath Parameter use advanced parameter Validation? ' { + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ResourcePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ResourcePath '{ + $function.Definition.Contains('.PARAMETER ResourcePath') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Test/Tests/Test-LabVM.Functional.Tests.ps1 b/Public/Test/Tests/Test-LabVM.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Test/Tests/Test-LabVM.Tests.ps1 b/Public/Test/Tests/Test-LabVM.Tests.ps1 new file mode 100644 index 00000000..c46e26ef --- /dev/null +++ b/Public/Test/Tests/Test-LabVM.Tests.ps1 @@ -0,0 +1,97 @@ +Describe 'Test-LabVM Tests' { + + Context 'Parameters for Test-LabVM'{ + + It 'Has a Parameter called Name' { + $Function.Parameters.Keys.Contains('Name') | Should Be 'True' + } + It 'Name Parameter is Identified as Mandatory being False' { + [String]$Function.Parameters.Name.Attributes.Mandatory | Should be 'False' + } + It 'Name Parameter is of String[] Type' { + $Function.Parameters.Name.ParameterType.FullName | Should be 'System.String[]' + } + It 'Name Parameter is member of ParameterSets' { + [String]$Function.Parameters.Name.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Name Parameter Position is defined correctly' { + [String]$Function.Parameters.Name.Attributes.Position | Should be '0' + } + It 'Does Name Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipeline | Should be 'True' + } + It 'Does Name Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Name.Attributes.ValueFromPipelineByPropertyName | Should be 'False' + } + It 'Does Name Parameter use advanced parameter Validation? ' { + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'True' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Name.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Name '{ + $function.Definition.Contains('.PARAMETER Name') | Should Be 'True' + } + It 'Has a Parameter called ConfigurationData' { + $Function.Parameters.Keys.Contains('ConfigurationData') | Should Be 'True' + } + It 'ConfigurationData Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.ConfigurationData.Attributes.Mandatory | Should be 'True' + } + It 'ConfigurationData Parameter is of Hashtable Type' { + $Function.Parameters.ConfigurationData.ParameterType.FullName | Should be 'System.Collections.Hashtable' + } + It 'ConfigurationData Parameter is member of ParameterSets' { + [String]$Function.Parameters.ConfigurationData.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'ConfigurationData Parameter Position is defined correctly' { + [String]$Function.Parameters.ConfigurationData.Attributes.Position | Should be '1' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does ConfigurationData Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.ConfigurationData.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does ConfigurationData Parameter use advanced parameter Validation? ' { + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.ConfigurationData.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for ConfigurationData '{ + $function.Definition.Contains('.PARAMETER ConfigurationData') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Unregister/Tests/Unregister-LabMedia.Functional.Tests.ps1 b/Public/Unregister/Tests/Unregister-LabMedia.Functional.Tests.ps1 new file mode 100644 index 00000000..e69de29b diff --git a/Public/Unregister/Tests/Unregister-LabMedia.Tests.ps1 b/Public/Unregister/Tests/Unregister-LabMedia.Tests.ps1 new file mode 100644 index 00000000..234909e3 --- /dev/null +++ b/Public/Unregister/Tests/Unregister-LabMedia.Tests.ps1 @@ -0,0 +1,66 @@ +Describe 'Unregister-LabMedia Tests' { + + Context 'Parameters for Unregister-LabMedia'{ + + It 'Has a Parameter called Id' { + $Function.Parameters.Keys.Contains('Id') | Should Be 'True' + } + It 'Id Parameter is Identified as Mandatory being True' { + [String]$Function.Parameters.Id.Attributes.Mandatory | Should be 'True' + } + It 'Id Parameter is of String Type' { + $Function.Parameters.Id.ParameterType.FullName | Should be 'System.String' + } + It 'Id Parameter is member of ParameterSets' { + [String]$Function.Parameters.Id.ParameterSets.Keys | Should Be '__AllParameterSets' + } + It 'Id Parameter Position is defined correctly' { + [String]$Function.Parameters.Id.Attributes.Position | Should be '0' + } + It 'Does Id Parameter Accept Pipeline Input?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipeline | Should be 'False' + } + It 'Does Id Parameter Accept Pipeline Input by PropertyName?' { + [String]$Function.Parameters.Id.Attributes.ValueFromPipelineByPropertyName | Should be 'True' + } + It 'Does Id Parameter use advanced parameter Validation? ' { + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False' + $Function.Parameters.Id.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False' + } + It 'Has Parameter Help Text for Id '{ + $function.Definition.Contains('.PARAMETER Id') | Should Be 'True' + } + } + Context "Function $($function.Name) - Help Section" { + + It "Function $($function.Name) Has show-help comment block" { + + $function.Definition.Contains('<#') | should be 'True' + $function.Definition.Contains('#>') | should be 'True' + } + + It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" { + + $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True' + + } + + It "Function $($function.Name) Has show-help comment block has an example" { + + $function.Definition.Contains('.EXAMPLE') | should be 'True' + } + + It "Function $($function.Name) Is an advanced function" { + + $function.CmdletBinding | should be 'True' + $function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True' + } + + } + + } + + diff --git a/Public/Unregister/Unregister-LabMedia.ps1 b/Public/Unregister/Unregister-LabMedia.ps1 new file mode 100644 index 00000000..d3ab7365 --- /dev/null +++ b/Public/Unregister/Unregister-LabMedia.ps1 @@ -0,0 +1,55 @@ +function Unregister-LabMedia { + +<# + .SYNOPSIS + Unregisters a custom media entry. + .DESCRIPTION + The Unregister-LabMedia cmdlet allows removing custom media entries from the host's configuration. + .LINK + Get-LabMedia + Register-LabMedia +#> + [CmdletBinding(SupportsShouldProcess)] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSProvideDefaultParameterValue', '')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')] + param ( + ## Specifies the custom media Id to unregister. You cannot unregister the built-in media. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [System.String] $Id + ) + process { + + ## Get the custom media list + $customMedia = GetConfigurationData -Configuration CustomMedia; + if (-not $customMedia) { + + ## We don't have anything defined + WriteWarning ($localized.NoCustomMediaFoundWarning -f $Id); + return; + } + else { + + ## Check if we have a matching Id + $media = $customMedia | Where-Object { $_.Id -eq $Id }; + if (-not $media) { + ## We don't have a custom matching Id registered + WriteWarning ($localized.NoCustomMediaFoundWarning -f $Id); + return; + } + } + + $shouldProcessMessage = $localized.PerformingOperationOnTarget -f 'Unregister-LabMedia', $Id; + $verboseProcessMessage = $localized.RemovingCustomMediaEntry -f $Id; + if ($PSCmdlet.ShouldProcess($verboseProcessMessage, $shouldProcessMessage, $localized.ShouldProcessWarning)) { + + $customMedia = $customMedia | Where-Object { $_.Id -ne $Id }; + WriteVerbose ($localized.SavingConfiguration -f $Id); + SetConfigurationData -Configuration CustomMedia -InputObject @($customMedia); + return $media; + } + + } #end process + +} + diff --git a/TestResult.xml b/TestResult.xml new file mode 100644 index 00000000..8f513e3b --- /dev/null +++ b/TestResult.xml @@ -0,0 +1,1538 @@ +<?xml version="1.0" encoding="utf-8" standalone="no"?> +<test-results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="nunit_schema_2.5.xsd" name="Pester" total="757" errors="0" failures="6" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2016-10-20" time="00:19:02"> + <environment user="Ryan" machine-name="LENOVO-10" cwd="GitHub:\kilasuit\Lability" user-domain="LENOVO-10" platform="Microsoft Windows 10 Pro Insider Preview|C:\WINDOWS|\Device\Harddisk0\Partition5" nunit-version="2.5.8.0" os-version="10.0.14946" clr-version="4.0.30319.42000" /> + <culture-info current-culture="en-GB" current-uiculture="en-US" /> + <test-suite type="Powershell" name="Pester" executed="True" result="Failure" success="False" time="355.6951" asserts="0"> + <results> + <test-suite type="TestFixture" name="Testing Private Function - AddDiskImageHotfix for Standard Processing" executed="True" result="Success" success="True" time="1.8754" asserts="0" description="Testing Private Function - AddDiskImageHotfix for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - AddDiskImageHotfix for Standard Processing.Is valid Powershell (Has no script errors)" time="1.8754" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - AddDiskImagePackage for Standard Processing" executed="True" result="Success" success="True" time="0.0583" asserts="0" description="Testing Private Function - AddDiskImagePackage for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - AddDiskImagePackage for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0583" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - AddWindowsOptionalFeature for Standard Processing" executed="True" result="Success" success="True" time="0.0624" asserts="0" description="Testing Private Function - AddWindowsOptionalFeature for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - AddWindowsOptionalFeature for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0624" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - AddWindowsPackage for Standard Processing" executed="True" result="Success" success="True" time="0.0758" asserts="0" description="Testing Private Function - AddWindowsPackage for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - AddWindowsPackage for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0758" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - CloseGitHubZipArchive for Standard Processing" executed="True" result="Success" success="True" time="0.0625" asserts="0" description="Testing Private Function - CloseGitHubZipArchive for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - CloseGitHubZipArchive for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0625" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - CloseZipArchive for Standard Processing" executed="True" result="Success" success="True" time="0.0875" asserts="0" description="Testing Private Function - CloseZipArchive for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - CloseZipArchive for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0875" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ConvertPSObjectToHashtable for Standard Processing" executed="True" result="Success" success="True" time="0.0695" asserts="0" description="Testing Private Function - ConvertPSObjectToHashtable for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ConvertPSObjectToHashtable for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0695" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ConvertToConfigurationData for Standard Processing" executed="True" result="Success" success="True" time="0.0772" asserts="0" description="Testing Private Function - ConvertToConfigurationData for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ConvertToConfigurationData for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0772" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - CopyDirectory for Standard Processing" executed="True" result="Success" success="True" time="0.0563" asserts="0" description="Testing Private Function - CopyDirectory for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - CopyDirectory for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0563" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ExpandDscModule for Standard Processing" executed="True" result="Success" success="True" time="0.0565" asserts="0" description="Testing Private Function - ExpandDscModule for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ExpandDscModule for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0565" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ExpandGitHubZipArchive for Standard Processing" executed="True" result="Success" success="True" time="0.0548" asserts="0" description="Testing Private Function - ExpandGitHubZipArchive for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ExpandGitHubZipArchive for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0548" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ExpandGitHubZipArchiveItem for Standard Processing" executed="True" result="Success" success="True" time="0.0616" asserts="0" description="Testing Private Function - ExpandGitHubZipArchiveItem for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ExpandGitHubZipArchiveItem for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0616" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ExpandIso for Standard Processing" executed="True" result="Success" success="True" time="0.0725" asserts="0" description="Testing Private Function - ExpandIso for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ExpandIso for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0725" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ExpandLabResource for Standard Processing" executed="True" result="Success" success="True" time="0.0618" asserts="0" description="Testing Private Function - ExpandLabResource for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ExpandLabResource for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0618" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ExpandModuleCache for Standard Processing" executed="True" result="Success" success="True" time="0.053" asserts="0" description="Testing Private Function - ExpandModuleCache for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ExpandModuleCache for Standard Processing.Is valid Powershell (Has no script errors)" time="0.053" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ExpandWindowsImage for Standard Processing" executed="True" result="Success" success="True" time="0.0652" asserts="0" description="Testing Private Function - ExpandWindowsImage for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ExpandWindowsImage for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0652" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ExpandZipArchive for Standard Processing" executed="True" result="Success" success="True" time="0.0685" asserts="0" description="Testing Private Function - ExpandZipArchive for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ExpandZipArchive for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0685" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ExpandZipArchiveItem for Standard Processing" executed="True" result="Success" success="True" time="0.0737" asserts="0" description="Testing Private Function - ExpandZipArchiveItem for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ExpandZipArchiveItem for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0737" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetConfigurationData for Standard Processing" executed="True" result="Success" success="True" time="0.11" asserts="0" description="Testing Private Function - GetConfigurationData for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetConfigurationData for Standard Processing.Is valid Powershell (Has no script errors)" time="0.11" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetDiskImageDriveLetter for Standard Processing" executed="True" result="Success" success="True" time="0.0914" asserts="0" description="Testing Private Function - GetDiskImageDriveLetter for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetDiskImageDriveLetter for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0914" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetDscModule for Standard Processing" executed="True" result="Success" success="True" time="0.0734" asserts="0" description="Testing Private Function - GetDscModule for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetDscModule for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0734" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetDscResource for Standard Processing" executed="True" result="Success" success="True" time="0.1201" asserts="0" description="Testing Private Function - GetDscResource for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetDscResource for Standard Processing.Is valid Powershell (Has no script errors)" time="0.1201" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetDscResourceModule for Standard Processing" executed="True" result="Success" success="True" time="0.0844" asserts="0" description="Testing Private Function - GetDscResourceModule for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetDscResourceModule for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0844" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetFormattedMessage for Standard Processing" executed="True" result="Success" success="True" time="0.1018" asserts="0" description="Testing Private Function - GetFormattedMessage for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetFormattedMessage for Standard Processing.Is valid Powershell (Has no script errors)" time="0.1018" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetLabHostDSCConfigurationPath for Standard Processing" executed="True" result="Success" success="True" time="0.0529" asserts="0" description="Testing Private Function - GetLabHostDSCConfigurationPath for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetLabHostDSCConfigurationPath for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0529" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetLabHostSetupConfiguration for Standard Processing" executed="True" result="Success" success="True" time="0.0549" asserts="0" description="Testing Private Function - GetLabHostSetupConfiguration for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetLabHostSetupConfiguration for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0549" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetLabVMDisk for Standard Processing" executed="True" result="Success" success="True" time="0.0575" asserts="0" description="Testing Private Function - GetLabVMDisk for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetLabVMDisk for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0575" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetLabVMSnapshot for Standard Processing" executed="True" result="Success" success="True" time="0.0549" asserts="0" description="Testing Private Function - GetLabVMSnapshot for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetLabVMSnapshot for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0549" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetModule for Standard Processing" executed="True" result="Success" success="True" time="0.0603" asserts="0" description="Testing Private Function - GetModule for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetModule for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0603" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetModuleCache for Standard Processing" executed="True" result="Success" success="True" time="0.06" asserts="0" description="Testing Private Function - GetModuleCache for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetModuleCache for Standard Processing.Is valid Powershell (Has no script errors)" time="0.06" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetModuleCacheManifest for Standard Processing" executed="True" result="Success" success="True" time="0.0576" asserts="0" description="Testing Private Function - GetModuleCacheManifest for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetModuleCacheManifest for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0576" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetResourceDownload for Standard Processing" executed="True" result="Success" success="True" time="0.0616" asserts="0" description="Testing Private Function - GetResourceDownload for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetResourceDownload for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0616" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetVirtualMachineProperties for Standard Processing" executed="True" result="Success" success="True" time="0.0634" asserts="0" description="Testing Private Function - GetVirtualMachineProperties for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetVirtualMachineProperties for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0634" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetWindowsImageIndex for Standard Processing" executed="True" result="Success" success="True" time="0.0749" asserts="0" description="Testing Private Function - GetWindowsImageIndex for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetWindowsImageIndex for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0749" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - GetWindowsImageName for Standard Processing" executed="True" result="Success" success="True" time="0.0637" asserts="0" description="Testing Private Function - GetWindowsImageName for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - GetWindowsImageName for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0637" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ImportDismModule for Standard Processing" executed="True" result="Success" success="True" time="0.0655" asserts="0" description="Testing Private Function - ImportDismModule for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ImportDismModule for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0655" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ImportDscResource for Standard Processing" executed="True" result="Success" success="True" time="0.0534" asserts="0" description="Testing Private Function - ImportDscResource for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ImportDscResource for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0534" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - InvokeDscResource for Standard Processing" executed="True" result="Success" success="True" time="0.0672" asserts="0" description="Testing Private Function - InvokeDscResource for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - InvokeDscResource for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0672" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - InvokeExecutable for Standard Processing" executed="True" result="Success" success="True" time="0.0683" asserts="0" description="Testing Private Function - InvokeExecutable for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - InvokeExecutable for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0683" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - InvokeLabMediaHotfixDownload for Standard Processing" executed="True" result="Success" success="True" time="0.0648" asserts="0" description="Testing Private Function - InvokeLabMediaHotfixDownload for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - InvokeLabMediaHotfixDownload for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0648" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - InvokeLabMediaImageDownload for Standard Processing" executed="True" result="Success" success="True" time="0.0598" asserts="0" description="Testing Private Function - InvokeLabMediaImageDownload for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - InvokeLabMediaImageDownload for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0598" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - InvokeModuleCacheDownload for Standard Processing" executed="True" result="Success" success="True" time="0.0593" asserts="0" description="Testing Private Function - InvokeModuleCacheDownload for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - InvokeModuleCacheDownload for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0593" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - InvokeModuleDownloadFromGitHub for Standard Processing" executed="True" result="Success" success="True" time="0.0611" asserts="0" description="Testing Private Function - InvokeModuleDownloadFromGitHub for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - InvokeModuleDownloadFromGitHub for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0611" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - InvokeModuleDownloadFromPSGallery for Standard Processing" executed="True" result="Success" success="True" time="0.0646" asserts="0" description="Testing Private Function - InvokeModuleDownloadFromPSGallery for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - InvokeModuleDownloadFromPSGallery for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0646" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - InvokeResourceDownload for Standard Processing" executed="True" result="Success" success="True" time="0.054" asserts="0" description="Testing Private Function - InvokeResourceDownload for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - InvokeResourceDownload for Standard Processing.Is valid Powershell (Has no script errors)" time="0.054" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - InvokeWebClientDownload for Standard Processing" executed="True" result="Success" success="True" time="0.0574" asserts="0" description="Testing Private Function - InvokeWebClientDownload for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - InvokeWebClientDownload for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0574" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - NewBootStrap for Standard Processing" executed="True" result="Success" success="True" time="0.085" asserts="0" description="Testing Private Function - NewBootStrap for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - NewBootStrap for Standard Processing.Is valid Powershell (Has no script errors)" time="0.085" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - NewDirectory for Standard Processing" executed="True" result="Success" success="True" time="0.0565" asserts="0" description="Testing Private Function - NewDirectory for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - NewDirectory for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0565" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - NewDiskImage for Standard Processing" executed="True" result="Success" success="True" time="0.0509" asserts="0" description="Testing Private Function - NewDiskImage for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - NewDiskImage for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0509" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - NewDiskImageGpt for Standard Processing" executed="True" result="Success" success="True" time="0.0651" asserts="0" description="Testing Private Function - NewDiskImageGpt for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - NewDiskImageGpt for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0651" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - NewDiskImageMbr for Standard Processing" executed="True" result="Success" success="True" time="0.0566" asserts="0" description="Testing Private Function - NewDiskImageMbr for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - NewDiskImageMbr for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0566" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - NewDiskPartFat32Partition for Standard Processing" executed="True" result="Success" success="True" time="0.0599" asserts="0" description="Testing Private Function - NewDiskPartFat32Partition for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - NewDiskPartFat32Partition for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0599" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - NewLabMedia for Standard Processing" executed="True" result="Success" success="True" time="0.06" asserts="0" description="Testing Private Function - NewLabMedia for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - NewLabMedia for Standard Processing.Is valid Powershell (Has no script errors)" time="0.06" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - NewLabSwitch for Standard Processing" executed="True" result="Success" success="True" time="0.0645" asserts="0" description="Testing Private Function - NewLabSwitch for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - NewLabSwitch for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0645" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - NewLabVM for Standard Processing" executed="True" result="Success" success="True" time="0.0659" asserts="0" description="Testing Private Function - NewLabVM for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - NewLabVM for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0659" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - NewLabVMSnapshot for Standard Processing" executed="True" result="Success" success="True" time="0.0563" asserts="0" description="Testing Private Function - NewLabVMSnapshot for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - NewLabVMSnapshot for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0563" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - NewUnattendXml for Standard Processing" executed="True" result="Success" success="True" time="0.0568" asserts="0" description="Testing Private Function - NewUnattendXml for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - NewUnattendXml for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0568" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - RemoveConfigurationData for Standard Processing" executed="True" result="Success" success="True" time="0.0447" asserts="0" description="Testing Private Function - RemoveConfigurationData for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - RemoveConfigurationData for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0447" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - RemoveLabSwitch for Standard Processing" executed="True" result="Success" success="True" time="0.0489" asserts="0" description="Testing Private Function - RemoveLabSwitch for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - RemoveLabSwitch for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0489" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - RemoveLabVirtualMachine for Standard Processing" executed="True" result="Success" success="True" time="0.059" asserts="0" description="Testing Private Function - RemoveLabVirtualMachine for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - RemoveLabVirtualMachine for Standard Processing.Is valid Powershell (Has no script errors)" time="0.059" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - RemoveLabVM for Standard Processing" executed="True" result="Success" success="True" time="0.0602" asserts="0" description="Testing Private Function - RemoveLabVM for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - RemoveLabVM for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0602" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - RemoveLabVMDisk for Standard Processing" executed="True" result="Success" success="True" time="0.0471" asserts="0" description="Testing Private Function - RemoveLabVMDisk for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - RemoveLabVMDisk for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0471" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - RemoveLabVMSnapshot for Standard Processing" executed="True" result="Success" success="True" time="0.0579" asserts="0" description="Testing Private Function - RemoveLabVMSnapshot for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - RemoveLabVMSnapshot for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0579" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - RenameModuleCacheVersion for Standard Processing" executed="True" result="Success" success="True" time="0.0552" asserts="0" description="Testing Private Function - RenameModuleCacheVersion for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - RenameModuleCacheVersion for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0552" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResetLabVMDisk for Standard Processing" executed="True" result="Success" success="True" time="0.0455" asserts="0" description="Testing Private Function - ResetLabVMDisk for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResetLabVMDisk for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0455" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolveConfigurationDataPath for Standard Processing" executed="True" result="Success" success="True" time="0.0506" asserts="0" description="Testing Private Function - ResolveConfigurationDataPath for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolveConfigurationDataPath for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0506" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolveCustomBootStrap for Standard Processing" executed="True" result="Success" success="True" time="0.0595" asserts="0" description="Testing Private Function - ResolveCustomBootStrap for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolveCustomBootStrap for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0595" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolveDismPath for Standard Processing" executed="True" result="Success" success="True" time="0.0662" asserts="0" description="Testing Private Function - ResolveDismPath for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolveDismPath for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0662" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolveGitHubModuleUri for Standard Processing" executed="True" result="Success" success="True" time="0.0699" asserts="0" description="Testing Private Function - ResolveGitHubModuleUri for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolveGitHubModuleUri for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0699" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolveLabMedia for Standard Processing" executed="True" result="Success" success="True" time="0.0762" asserts="0" description="Testing Private Function - ResolveLabMedia for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolveLabMedia for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0762" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolveLabModule for Standard Processing" executed="True" result="Success" success="True" time="0.0585" asserts="0" description="Testing Private Function - ResolveLabModule for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolveLabModule for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0585" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolveLabResource for Standard Processing" executed="True" result="Success" success="True" time="0.0545" asserts="0" description="Testing Private Function - ResolveLabResource for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolveLabResource for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0545" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolveLabSwitch for Standard Processing" executed="True" result="Success" success="True" time="0.0617" asserts="0" description="Testing Private Function - ResolveLabSwitch for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolveLabSwitch for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0617" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolveLabVMDiskPath for Standard Processing" executed="True" result="Success" success="True" time="0.0658" asserts="0" description="Testing Private Function - ResolveLabVMDiskPath for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolveLabVMDiskPath for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0658" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolveLabVMProperties for Standard Processing" executed="True" result="Success" success="True" time="0.062" asserts="0" description="Testing Private Function - ResolveLabVMProperties for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolveLabVMProperties for Standard Processing.Is valid Powershell (Has no script errors)" time="0.062" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolveModule for Standard Processing" executed="True" result="Success" success="True" time="0.0566" asserts="0" description="Testing Private Function - ResolveModule for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolveModule for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0566" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolvePathEx for Standard Processing" executed="True" result="Success" success="True" time="0.0498" asserts="0" description="Testing Private Function - ResolvePathEx for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolvePathEx for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0498" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolveProgramFilesFolder for Standard Processing" executed="True" result="Success" success="True" time="0.0536" asserts="0" description="Testing Private Function - ResolveProgramFilesFolder for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolveProgramFilesFolder for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0536" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ResolvePSGalleryModuleUri for Standard Processing" executed="True" result="Success" success="True" time="0.0601" asserts="0" description="Testing Private Function - ResolvePSGalleryModuleUri for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ResolvePSGalleryModuleUri for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0601" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetBootStrap for Standard Processing" executed="True" result="Success" success="True" time="0.0628" asserts="0" description="Testing Private Function - SetBootStrap for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetBootStrap for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0628" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetConfigurationData for Standard Processing" executed="True" result="Success" success="True" time="0.0508" asserts="0" description="Testing Private Function - SetConfigurationData for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetConfigurationData for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0508" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetDiskImageBootVolume for Standard Processing" executed="True" result="Success" success="True" time="0.0534" asserts="0" description="Testing Private Function - SetDiskImageBootVolume for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetDiskImageBootVolume for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0534" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetDiskImageBootVolumeGpt for Standard Processing" executed="True" result="Success" success="True" time="0.0559" asserts="0" description="Testing Private Function - SetDiskImageBootVolumeGpt for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetDiskImageBootVolumeGpt for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0559" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetDiskImageBootVolumeMbr for Standard Processing" executed="True" result="Success" success="True" time="0.0599" asserts="0" description="Testing Private Function - SetDiskImageBootVolumeMbr for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetDiskImageBootVolumeMbr for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0599" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetDscResource for Standard Processing" executed="True" result="Success" success="True" time="0.0738" asserts="0" description="Testing Private Function - SetDscResource for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetDscResource for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0738" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetLabSwitch for Standard Processing" executed="True" result="Success" success="True" time="0.0614" asserts="0" description="Testing Private Function - SetLabSwitch for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetLabSwitch for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0614" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetLabVirtualMachine for Standard Processing" executed="True" result="Success" success="True" time="0.0593" asserts="0" description="Testing Private Function - SetLabVirtualMachine for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetLabVirtualMachine for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0593" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetLabVMDisk for Standard Processing" executed="True" result="Success" success="True" time="0.0511" asserts="0" description="Testing Private Function - SetLabVMDisk for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetLabVMDisk for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0511" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetLabVMDiskFile for Standard Processing" executed="True" result="Success" success="True" time="0.0545" asserts="0" description="Testing Private Function - SetLabVMDiskFile for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetLabVMDiskFile for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0545" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetLabVMDiskFileBootstrap for Standard Processing" executed="True" result="Success" success="True" time="0.0568" asserts="0" description="Testing Private Function - SetLabVMDiskFileBootstrap for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetLabVMDiskFileBootstrap for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0568" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetLabVMDiskFileCertificate for Standard Processing" executed="True" result="Success" success="True" time="0.0514" asserts="0" description="Testing Private Function - SetLabVMDiskFileCertificate for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetLabVMDiskFileCertificate for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0514" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetLabVMDiskFileModule for Standard Processing" executed="True" result="Success" success="True" time="0.0555" asserts="0" description="Testing Private Function - SetLabVMDiskFileModule for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetLabVMDiskFileModule for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0555" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetLabVMDiskFileMof for Standard Processing" executed="True" result="Success" success="True" time="0.0595" asserts="0" description="Testing Private Function - SetLabVMDiskFileMof for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetLabVMDiskFileMof for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0595" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetLabVMDiskFileResource for Standard Processing" executed="True" result="Success" success="True" time="0.058" asserts="0" description="Testing Private Function - SetLabVMDiskFileResource for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetLabVMDiskFileResource for Standard Processing.Is valid Powershell (Has no script errors)" time="0.058" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetLabVMDiskFileUnattendXml for Standard Processing" executed="True" result="Success" success="True" time="0.0709" asserts="0" description="Testing Private Function - SetLabVMDiskFileUnattendXml for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetLabVMDiskFileUnattendXml for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0709" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetLabVMDiskModule for Standard Processing" executed="True" result="Success" success="True" time="0.0566" asserts="0" description="Testing Private Function - SetLabVMDiskModule for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetLabVMDiskModule for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0566" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetResourceChecksum for Standard Processing" executed="True" result="Success" success="True" time="0.0614" asserts="0" description="Testing Private Function - SetResourceChecksum for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetResourceChecksum for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0614" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetResourceDownload for Standard Processing" executed="True" result="Success" success="True" time="0.0531" asserts="0" description="Testing Private Function - SetResourceDownload for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetResourceDownload for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0531" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetSetupCompleteCmd for Standard Processing" executed="True" result="Success" success="True" time="0.0554" asserts="0" description="Testing Private Function - SetSetupCompleteCmd for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetSetupCompleteCmd for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0554" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - SetUnattendXml for Standard Processing" executed="True" result="Success" success="True" time="0.0537" asserts="0" description="Testing Private Function - SetUnattendXml for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - SetUnattendXml for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0537" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestComputerName for Standard Processing" executed="True" result="Success" success="True" time="0.0677" asserts="0" description="Testing Private Function - TestComputerName for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestComputerName for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0677" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestDscModule for Standard Processing" executed="True" result="Success" success="True" time="0.0676" asserts="0" description="Testing Private Function - TestDscModule for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestDscModule for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0676" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestDscResource for Standard Processing" executed="True" result="Success" success="True" time="0.0582" asserts="0" description="Testing Private Function - TestDscResource for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestDscResource for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0582" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestDscResourceModule for Standard Processing" executed="True" result="Success" success="True" time="0.0584" asserts="0" description="Testing Private Function - TestDscResourceModule for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestDscResourceModule for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0584" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestLabConfigurationMof for Standard Processing" executed="True" result="Success" success="True" time="0.0497" asserts="0" description="Testing Private Function - TestLabConfigurationMof for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestLabConfigurationMof for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0497" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestLabResourceIsLocal for Standard Processing" executed="True" result="Success" success="True" time="0.0477" asserts="0" description="Testing Private Function - TestLabResourceIsLocal for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestLabResourceIsLocal for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0477" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestLabSwitch for Standard Processing" executed="True" result="Success" success="True" time="0.0541" asserts="0" description="Testing Private Function - TestLabSwitch for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestLabSwitch for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0541" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestLabVirtualMachine for Standard Processing" executed="True" result="Success" success="True" time="0.0537" asserts="0" description="Testing Private Function - TestLabVirtualMachine for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestLabVirtualMachine for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0537" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestLabVMDisk for Standard Processing" executed="True" result="Success" success="True" time="0.0503" asserts="0" description="Testing Private Function - TestLabVMDisk for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestLabVMDisk for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0503" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestModule for Standard Processing" executed="True" result="Success" success="True" time="0.0554" asserts="0" description="Testing Private Function - TestModule for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestModule for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0554" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestModuleCache for Standard Processing" executed="True" result="Success" success="True" time="0.0521" asserts="0" description="Testing Private Function - TestModuleCache for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestModuleCache for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0521" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestModuleVersion for Standard Processing" executed="True" result="Success" success="True" time="0.0585" asserts="0" description="Testing Private Function - TestModuleVersion for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestModuleVersion for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0585" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - TestResourceDownload for Standard Processing" executed="True" result="Success" success="True" time="0.0492" asserts="0" description="Testing Private Function - TestResourceDownload for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - TestResourceDownload for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0492" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - ValidateTimeZone for Standard Processing" executed="True" result="Success" success="True" time="0.0663" asserts="0" description="Testing Private Function - ValidateTimeZone for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - ValidateTimeZone for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0663" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - WriteVerbose for Standard Processing" executed="True" result="Success" success="True" time="0.0524" asserts="0" description="Testing Private Function - WriteVerbose for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - WriteVerbose for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0524" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Private Function - WriteWarning for Standard Processing" executed="True" result="Success" success="True" time="0.0565" asserts="0" description="Testing Private Function - WriteWarning for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Private Function - WriteWarning for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0565" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Checkpoint-Lab for Standard Processing" executed="True" result="Success" success="True" time="0.082" asserts="0" description="Testing Public Function - Checkpoint-Lab for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Checkpoint-Lab for Standard Processing.Is valid Powershell (Has no script errors)" time="0.082" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Export-LabHostConfiguration for Standard Processing" executed="True" result="Success" success="True" time="0.0532" asserts="0" description="Testing Public Function - Export-LabHostConfiguration for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Export-LabHostConfiguration for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0532" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Get-LabHostConfiguration for Standard Processing" executed="True" result="Success" success="True" time="0.054" asserts="0" description="Testing Public Function - Get-LabHostConfiguration for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Get-LabHostConfiguration for Standard Processing.Is valid Powershell (Has no script errors)" time="0.054" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Get-LabHostDefault for Standard Processing" executed="True" result="Success" success="True" time="0.0629" asserts="0" description="Testing Public Function - Get-LabHostDefault for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Get-LabHostDefault for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0629" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Get-LabHostDefaults for Standard Processing" executed="True" result="Success" success="True" time="0.054" asserts="0" description="Testing Public Function - Get-LabHostDefaults for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Get-LabHostDefaults for Standard Processing.Is valid Powershell (Has no script errors)" time="0.054" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Get-LabImage for Standard Processing" executed="True" result="Success" success="True" time="0.0662" asserts="0" description="Testing Public Function - Get-LabImage for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Get-LabImage for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0662" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Get-LabMedia for Standard Processing" executed="True" result="Success" success="True" time="0.0582" asserts="0" description="Testing Public Function - Get-LabMedia for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Get-LabMedia for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0582" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Get-LabVM for Standard Processing" executed="True" result="Success" success="True" time="0.0521" asserts="0" description="Testing Public Function - Get-LabVM for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Get-LabVM for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0521" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Get-LabVMDefault for Standard Processing" executed="True" result="Success" success="True" time="0.0561" asserts="0" description="Testing Public Function - Get-LabVMDefault for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Get-LabVMDefault for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0561" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Get-LabVMDefaults for Standard Processing" executed="True" result="Success" success="True" time="0.0629" asserts="0" description="Testing Public Function - Get-LabVMDefaults for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Get-LabVMDefaults for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0629" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Import-LabHostConfiguration for Standard Processing" executed="True" result="Success" success="True" time="0.0564" asserts="0" description="Testing Public Function - Import-LabHostConfiguration for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Import-LabHostConfiguration for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0564" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Invoke-LabResourceDownload for Standard Processing" executed="True" result="Success" success="True" time="0.0549" asserts="0" description="Testing Public Function - Invoke-LabResourceDownload for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Invoke-LabResourceDownload for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0549" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - New-LabImage for Standard Processing" executed="True" result="Success" success="True" time="0.0806" asserts="0" description="Testing Public Function - New-LabImage for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - New-LabImage for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0806" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - New-LabVM for Standard Processing" executed="True" result="Success" success="True" time="0.0694" asserts="0" description="Testing Public Function - New-LabVM for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - New-LabVM for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0694" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Register-LabMedia for Standard Processing" executed="True" result="Success" success="True" time="0.0719" asserts="0" description="Testing Public Function - Register-LabMedia for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Register-LabMedia for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0719" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Remove-LabConfiguration for Standard Processing" executed="True" result="Success" success="True" time="0.0646" asserts="0" description="Testing Public Function - Remove-LabConfiguration for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Remove-LabConfiguration for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0646" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Remove-LabVM for Standard Processing" executed="True" result="Success" success="True" time="0.068" asserts="0" description="Testing Public Function - Remove-LabVM for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Remove-LabVM for Standard Processing.Is valid Powershell (Has no script errors)" time="0.068" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Reset-Lab for Standard Processing" executed="True" result="Success" success="True" time="0.058" asserts="0" description="Testing Public Function - Reset-Lab for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Reset-Lab for Standard Processing.Is valid Powershell (Has no script errors)" time="0.058" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Reset-LabHostDefault for Standard Processing" executed="True" result="Success" success="True" time="0.0755" asserts="0" description="Testing Public Function - Reset-LabHostDefault for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Reset-LabHostDefault for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0755" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Reset-LabHostDefaults for Standard Processing" executed="True" result="Success" success="True" time="0.0602" asserts="0" description="Testing Public Function - Reset-LabHostDefaults for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Reset-LabHostDefaults for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0602" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Reset-LabMedia for Standard Processing" executed="True" result="Success" success="True" time="0.0518" asserts="0" description="Testing Public Function - Reset-LabMedia for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Reset-LabMedia for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0518" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Reset-LabVM for Standard Processing" executed="True" result="Success" success="True" time="0.0545" asserts="0" description="Testing Public Function - Reset-LabVM for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Reset-LabVM for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0545" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Reset-LabVMDefault for Standard Processing" executed="True" result="Success" success="True" time="0.0579" asserts="0" description="Testing Public Function - Reset-LabVMDefault for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Reset-LabVMDefault for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0579" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Reset-LabVMDefaults for Standard Processing" executed="True" result="Success" success="True" time="0.0609" asserts="0" description="Testing Public Function - Reset-LabVMDefaults for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Reset-LabVMDefaults for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0609" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Restore-Lab for Standard Processing" executed="True" result="Success" success="True" time="0.0604" asserts="0" description="Testing Public Function - Restore-Lab for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Restore-Lab for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0604" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Set-LabHostDefault for Standard Processing" executed="True" result="Success" success="True" time="0.0548" asserts="0" description="Testing Public Function - Set-LabHostDefault for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Set-LabHostDefault for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0548" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Set-LabHostDefaults for Standard Processing" executed="True" result="Success" success="True" time="0.0542" asserts="0" description="Testing Public Function - Set-LabHostDefaults for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Set-LabHostDefaults for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0542" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Set-LabVMDefault for Standard Processing" executed="True" result="Success" success="True" time="0.0538" asserts="0" description="Testing Public Function - Set-LabVMDefault for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Set-LabVMDefault for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0538" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Set-LabVMDefaults for Standard Processing" executed="True" result="Success" success="True" time="0.0557" asserts="0" description="Testing Public Function - Set-LabVMDefaults for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Set-LabVMDefaults for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0557" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Start-Lab for Standard Processing" executed="True" result="Success" success="True" time="0.06" asserts="0" description="Testing Public Function - Start-Lab for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Start-Lab for Standard Processing.Is valid Powershell (Has no script errors)" time="0.06" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Start-LabConfiguration for Standard Processing" executed="True" result="Success" success="True" time="0.0692" asserts="0" description="Testing Public Function - Start-LabConfiguration for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Start-LabConfiguration for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0692" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Start-LabHostConfiguration for Standard Processing" executed="True" result="Success" success="True" time="0.0529" asserts="0" description="Testing Public Function - Start-LabHostConfiguration for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Start-LabHostConfiguration for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0529" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Stop-Lab for Standard Processing" executed="True" result="Success" success="True" time="0.068" asserts="0" description="Testing Public Function - Stop-Lab for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Stop-Lab for Standard Processing.Is valid Powershell (Has no script errors)" time="0.068" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Test-LabConfiguration for Standard Processing" executed="True" result="Success" success="True" time="0.063" asserts="0" description="Testing Public Function - Test-LabConfiguration for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Test-LabConfiguration for Standard Processing.Is valid Powershell (Has no script errors)" time="0.063" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Test-LabHostConfiguration for Standard Processing" executed="True" result="Success" success="True" time="0.0603" asserts="0" description="Testing Public Function - Test-LabHostConfiguration for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Test-LabHostConfiguration for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0603" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Test-LabImage for Standard Processing" executed="True" result="Success" success="True" time="0.0723" asserts="0" description="Testing Public Function - Test-LabImage for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Test-LabImage for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0723" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Test-LabMedia for Standard Processing" executed="True" result="Success" success="True" time="0.0533" asserts="0" description="Testing Public Function - Test-LabMedia for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Test-LabMedia for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0533" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Test-LabResource for Standard Processing" executed="True" result="Success" success="True" time="0.057" asserts="0" description="Testing Public Function - Test-LabResource for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Test-LabResource for Standard Processing.Is valid Powershell (Has no script errors)" time="0.057" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Test-LabVM for Standard Processing" executed="True" result="Success" success="True" time="0.0652" asserts="0" description="Testing Public Function - Test-LabVM for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Test-LabVM for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0652" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Testing Public Function - Unregister-LabMedia for Standard Processing" executed="True" result="Success" success="True" time="0.0563" asserts="0" description="Testing Public Function - Unregister-LabMedia for Standard Processing"> + <results> + <test-case description="Is valid Powershell (Has no script errors)" name="Testing Public Function - Unregister-LabMedia for Standard Processing.Is valid Powershell (Has no script errors)" time="0.0563" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="ScriptAnalyzer Rule Testing" executed="True" result="Failure" success="False" time="208.9671" asserts="0" description="ScriptAnalyzer Rule Testing"> + <results> + <test-case description="Passes the Script Analyzer " name="ScriptAnalyzer Rule Testing.Passes the Script Analyzer " time="57.8952" asserts="0" success="False" result="Failure" executed="True"> + <failure> + <message>Expected: {0} +But was: {3}</message> + <stack-trace>at line: 81 in C:\Users\Ryan\Onedrive\Github\kilasuit\Lability\Min.Tests.ps1 +81: (Invoke-ScriptAnalyzer -Path $PublicFunctionPath -Recurse ).Count | Should Be 0 +</stack-trace> + </failure> + </test-case> + <test-case description="Passes the Script Analyzer " name="ScriptAnalyzer Rule Testing.Passes the Script Analyzer " time="151.0719" asserts="0" success="False" result="Failure" executed="True"> + <failure> + <message>Expected: {0} +But was: {6}</message> + <stack-trace>at line: 89 in C:\Users\Ryan\Onedrive\Github\kilasuit\Lability\Min.Tests.ps1 +89: (Invoke-ScriptAnalyzer -Path $PrivateFunctionPath ).Count | Should Be 0 +</stack-trace> + </failure> + </test-case> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\BootStrap" executed="True" result="Success" success="True" time="3.0639" asserts="0" description="Lib\BootStrap"> + <results> + <test-case description="Returns a &quot;System.Management.Automation.ScriptBlock&quot; type" name="Lib\BootStrap.Returns a &quot;System.Management.Automation.ScriptBlock&quot; type" time="2.4005" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Includes custom BootStrap injection point" name="Lib\BootStrap.Includes custom BootStrap injection point" time="0.0175" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates target file &quot;SetupComplete.cmd&quot;" name="Lib\BootStrap.Creates target file &quot;SetupComplete.cmd&quot;" time="0.0705" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Bypasses Powershell execution policy" name="Lib\BootStrap.Bypasses Powershell execution policy" time="0.0284" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Runs non-interactively" name="Lib\BootStrap.Runs non-interactively" time="0.0288" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates scheduled tasks for CoreCLR image" name="Lib\BootStrap.Creates scheduled tasks for CoreCLR image" time="0.0329" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Uses ASCII encoding" name="Lib\BootStrap.Uses ASCII encoding" time="0.076" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates target file &quot;BootStrap.ps1&quot;" name="Lib\BootStrap.Creates target file &quot;BootStrap.ps1&quot;" time="0.0967" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Replaces custom BootStrap injection point with custom BootStrap" name="Lib\BootStrap.Replaces custom BootStrap injection point with custom BootStrap" time="0.0641" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Uses UTF8 encoding" name="Lib\BootStrap.Uses UTF8 encoding" time="0.0472" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns empty string when &quot;CustomBootStrapOrder&quot; = &quot;Disabled&quot;" name="Lib\BootStrap.Returns empty string when &quot;CustomBootStrapOrder&quot; = &quot;Disabled&quot;" time="0.0711" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns configuration bootstrap when &quot;CustomBootStrapOrder&quot; = &quot;ConfigurationOnly&quot;" name="Lib\BootStrap.Returns configuration bootstrap when &quot;CustomBootStrapOrder&quot; = &quot;ConfigurationOnly&quot;" time="0.0222" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns media bootstrap when &quot;CustomBootStrapOrder&quot; = &quot;MediaOnly&quot;" name="Lib\BootStrap.Returns media bootstrap when &quot;CustomBootStrapOrder&quot; = &quot;MediaOnly&quot;" time="0.0254" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns configuration bootstrap first when &quot;CustomBootStrapOrder&quot; = &quot;ConfigurationFirst&quot;" name="Lib\BootStrap.Returns configuration bootstrap first when &quot;CustomBootStrapOrder&quot; = &quot;ConfigurationFirst&quot;" time="0.0141" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns media bootstrap first when &quot;CustomBootStrapOrder&quot; = &quot;MediaFirst&quot;" name="Lib\BootStrap.Returns media bootstrap first when &quot;CustomBootStrapOrder&quot; = &quot;MediaFirst&quot;" time="0.0153" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns configuration bootstrap when &quot;MediaCustomBootstrap&quot; is null" name="Lib\BootStrap.Returns configuration bootstrap when &quot;MediaCustomBootstrap&quot; is null" time="0.0309" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns media bootstrap when &quot;ConfigurationCustomBootstrap&quot; is null" name="Lib\BootStrap.Returns media bootstrap when &quot;ConfigurationCustomBootstrap&quot; is null" time="0.0223" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\ConfigurationData" executed="True" result="Failure" success="False" time="3.4092" asserts="0" description="Lib\ConfigurationData"> + <results> + <test-case description="Resolves 'Host' to module path when custom configuration does not exist" name="Lib\ConfigurationData.Resolves 'Host' to module path when custom configuration does not exist" time="2.4094" asserts="0" success="False" result="Failure" executed="True"> + <failure> + <message>parsing "C:\Users\Ryan\Onedrive\Github\kilasuit\Lability" - Unrecognized escape sequence \U.</message> + <stack-trace>at line: 19 in C:\Users\Ryan\Onedrive\Github\kilasuit\Lability\Tests\Lib\ConfigurationData.Tests.ps1</stack-trace> + </failure> + </test-case> + <test-case description="Resolves 'Host' to %ALLUSERSPROFILE% path when custom configuration does exist" name="Lib\ConfigurationData.Resolves 'Host' to %ALLUSERSPROFILE% path when custom configuration does exist" time="0.0365" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Resolves 'VM' to module path when custom configuration does not exist" name="Lib\ConfigurationData.Resolves 'VM' to module path when custom configuration does not exist" time="0.0261" asserts="0" success="False" result="Failure" executed="True"> + <failure> + <message>parsing "C:\Users\Ryan\Onedrive\Github\kilasuit\Lability" - Unrecognized escape sequence \U.</message> + <stack-trace>at line: 19 in C:\Users\Ryan\Onedrive\Github\kilasuit\Lability\Tests\Lib\ConfigurationData.Tests.ps1</stack-trace> + </failure> + </test-case> + <test-case description="Resolves 'VM' to %ALLUSERSPROFILE% path when custom configuration does exist" name="Lib\ConfigurationData.Resolves 'VM' to %ALLUSERSPROFILE% path when custom configuration does exist" time="0.0451" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Resolves 'Media' to module path when custom configuration does not exist" name="Lib\ConfigurationData.Resolves 'Media' to module path when custom configuration does not exist" time="0.0356" asserts="0" success="False" result="Failure" executed="True"> + <failure> + <message>parsing "C:\Users\Ryan\Onedrive\Github\kilasuit\Lability" - Unrecognized escape sequence \U.</message> + <stack-trace>at line: 19 in C:\Users\Ryan\Onedrive\Github\kilasuit\Lability\Tests\Lib\ConfigurationData.Tests.ps1</stack-trace> + </failure> + </test-case> + <test-case description="Resolves 'Media' to %ALLUSERSPROFILE% path when custom configuration does exist" name="Lib\ConfigurationData.Resolves 'Media' to %ALLUSERSPROFILE% path when custom configuration does exist" time="0.0339" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Resolves 'CustomMedia' to module path when custom configuration does not exist" name="Lib\ConfigurationData.Resolves 'CustomMedia' to module path when custom configuration does not exist" time="0.0406" asserts="0" success="False" result="Failure" executed="True"> + <failure> + <message>parsing "C:\Users\Ryan\Onedrive\Github\kilasuit\Lability" - Unrecognized escape sequence \U.</message> + <stack-trace>at line: 19 in C:\Users\Ryan\Onedrive\Github\kilasuit\Lability\Tests\Lib\ConfigurationData.Tests.ps1</stack-trace> + </failure> + </test-case> + <test-case description="Resolves 'CustomMedia' to %ALLUSERSPROFILE% path when custom configuration does exist" name="Lib\ConfigurationData.Resolves 'CustomMedia' to %ALLUSERSPROFILE% path when custom configuration does exist" time="0.0293" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Resolves environment variables in resulting path" name="Lib\ConfigurationData.Resolves environment variables in resulting path" time="0.0586" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Adds missing &quot;CustomBootstrapOrder&quot; property to VM configuration" name="Lib\ConfigurationData.Adds missing &quot;CustomBootstrapOrder&quot; property to VM configuration" time="0.1674" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Adds missing &quot;SecureBoot&quot; property to VM configuration" name="Lib\ConfigurationData.Adds missing &quot;SecureBoot&quot; property to VM configuration" time="0.0642" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Adds missing &quot;GuestIntegrationServices&quot; property to VM configuration" name="Lib\ConfigurationData.Adds missing &quot;GuestIntegrationServices&quot; property to VM configuration" time="0.0547" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Adds missing &quot;OperatingSystem&quot; property to CustomMedia configuration" name="Lib\ConfigurationData.Adds missing &quot;OperatingSystem&quot; property to CustomMedia configuration" time="0.0713" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Adds missing &quot;DisableLocalFileCaching&quot; property to Host configuration" name="Lib\ConfigurationData.Adds missing &quot;DisableLocalFileCaching&quot; property to Host configuration" time="0.0608" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Adds missing &quot;EnableCallStackLogging&quot; property to Host configuration" name="Lib\ConfigurationData.Adds missing &quot;EnableCallStackLogging&quot; property to Host configuration" time="0.0725" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes deprecated &quot;UpdatePath&quot; property from Host configuration (Issue #77)" name="Lib\ConfigurationData.Removes deprecated &quot;UpdatePath&quot; property from Host configuration (Issue #77)" time="0.0678" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes configuration file" name="Lib\ConfigurationData.Removes configuration file" time="0.1353" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\DiskImage" executed="True" result="Success" success="True" time="6.3249" asserts="0" description="Lib\DiskImage"> + <results> + <test-case description="Throws when no disk letter is found" name="Lib\DiskImage.Throws when no disk letter is found" time="2.4118" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when no disk letter is found for specified partition type" name="Lib\DiskImage.Throws when no disk letter is found for specified partition type" time="0.0317" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a single character" name="Lib\DiskImage.Returns a single character" time="0.039" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if VHD image already exists" name="Lib\DiskImage.Throws if VHD image already exists" time="0.0804" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes existing VHD image if it already exists and -Force is specified" name="Lib\DiskImage.Removes existing VHD image if it already exists and -Force is specified" time="0.152" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates new VHD file and initializes disk" name="Lib\DiskImage.Creates new VHD file and initializes disk" time="0.1355" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does dismount VHD file if -PassThru is not specified" name="Lib\DiskImage.Does dismount VHD file if -PassThru is not specified" time="0.1103" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not dismount VHD file if -PassThru is specified" name="Lib\DiskImage.Does not dismount VHD file if -PassThru is specified" time="0.0886" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;BCDBOOT.EXE&quot; with &quot;/f BIOS&quot;" name="Lib\DiskImage.Calls &quot;BCDBOOT.EXE&quot; with &quot;/f BIOS&quot;" time="0.1693" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;BCDEDIT.EXE&quot; thrice" name="Lib\DiskImage.Calls &quot;BCDEDIT.EXE&quot; thrice" time="0.1193" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;BCDBOOT.EXE&quot; with &quot;/f UEFI&quot;" name="Lib\DiskImage.Calls &quot;BCDBOOT.EXE&quot; with &quot;/f UEFI&quot;" time="0.2048" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Stops Shell Hardware Detection service" name="Lib\DiskImage.Stops Shell Hardware Detection service" time="0.3216" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates a full size active IFS partition" name="Lib\DiskImage.Creates a full size active IFS partition" time="0.1468" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Formats volume as NTFS" name="Lib\DiskImage.Formats volume as NTFS" time="0.139" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Stops and starts Shell Hardware Detection service" name="Lib\DiskImage.Stops and starts Shell Hardware Detection service" time="0.2553" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates 250MB system partition" name="Lib\DiskImage.Creates 250MB system partition" time="0.2257" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates OS partition" name="Lib\DiskImage.Creates OS partition" time="0.218" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Formats volume as NTFS" name="Lib\DiskImage.Formats volume as NTFS" time="0.2279" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetDiskImageBootVolumeGpt&quot; when partition style is GPT" name="Lib\DiskImage.Calls &quot;SetDiskImageBootVolumeGpt&quot; when partition style is GPT" time="0.1232" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetDiskImageBootVolumeMbr&quot; when partition style is MBR" name="Lib\DiskImage.Calls &quot;SetDiskImageBootVolumeMbr&quot; when partition style is MBR" time="0.0764" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not call &quot;Add-WindowsPackage&quot; for no hotfixes" name="Lib\DiskImage.Does not call &quot;Add-WindowsPackage&quot; for no hotfixes" time="0.21" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not call &quot;Add-WindowsPackage&quot; for no hotfixes" name="Lib\DiskImage.Does not call &quot;Add-WindowsPackage&quot; for no hotfixes" time="0.1128" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Add-WindowsPackage&quot; for a single hotfix" name="Lib\DiskImage.Calls &quot;Add-WindowsPackage&quot; for a single hotfix" time="0.1595" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Add-WindowsPackage&quot; for a single hotfix" name="Lib\DiskImage.Calls &quot;Add-WindowsPackage&quot; for a single hotfix" time="0.1483" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Add-WindowsPackage&quot; for each hotfix with multiple hotfixes" name="Lib\DiskImage.Calls &quot;Add-WindowsPackage&quot; for each hotfix with multiple hotfixes" time="0.2175" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Add-WindowsPackage&quot; for each hotfix with multiple hotfixes" name="Lib\DiskImage.Calls &quot;Add-WindowsPackage&quot; for each hotfix with multiple hotfixes" time="0.2006" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\DscModule" executed="True" result="Success" success="True" time="3.9636" asserts="0" description="Lib\DscModule"> + <results> + <test-case description="Returns true if &quot;GetDscModule&quot; returns a path" name="Lib\DscModule.Returns true if &quot;GetDscModule&quot; returns a path" time="2.7823" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns false if &quot;GetDscModule&quot; fails" name="Lib\DscModule.Returns false if &quot;GetDscModule&quot; fails" time="0.0406" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if module does not exist" name="Lib\DscModule.Throws if module does not exist" time="0.2046" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns DSC resource's parent directory path" name="Lib\DscModule.Returns DSC resource's parent directory path" time="0.0754" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns DSC resource's DSCResources subdirectory path if ResourceName is specified" name="Lib\DscModule.Returns DSC resource's DSCResources subdirectory path if ResourceName is specified" time="0.1581" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Errors if DSC resource's subdirectory path does not exist and ResourceName is specified" name="Lib\DscModule.Errors if DSC resource's subdirectory path does not exist and ResourceName is specified" time="0.1354" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns $null if DSC resource's subdirectory path does not exist and ResourceName is specified" name="Lib\DscModule.Returns $null if DSC resource's subdirectory path does not exist and ResourceName is specified" time="0.1056" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not throw if DSC module version is equal to the MinimumVersion specified" name="Lib\DscModule.Does not throw if DSC module version is equal to the MinimumVersion specified" time="0.1192" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not throw if DSC module version is greater than the MinimumVersion specified" name="Lib\DscModule.Does not throw if DSC module version is greater than the MinimumVersion specified" time="0.1388" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Errors if DSC module version is less than the MinimumVersion specified" name="Lib\DscModule.Errors if DSC module version is less than the MinimumVersion specified" time="0.1096" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns $null if DSC module version is less than the MinimumVersion specified" name="Lib\DscModule.Returns $null if DSC module version is less than the MinimumVersion specified" time="0.0939" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\DscResource" executed="True" result="Success" success="True" time="4.1699" asserts="0" description="Lib\DscResource"> + <results> + <test-case description="Does not import module if command is already imported" name="Lib\DscResource.Does not import module if command is already imported" time="3.2303" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not call &quot;GetDscModule&quot; if &quot;UseDefault&quot; is not specified" name="Lib\DscResource.Does not call &quot;GetDscModule&quot; if &quot;UseDefault&quot; is not specified" time="0.0907" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;GetDscModule&quot; if &quot;UseDefault&quot; is specified" name="Lib\DscResource.Calls &quot;GetDscModule&quot; if &quot;UseDefault&quot; is specified" time="0.0971" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Get-&lt;ResourceName&gt;TargetResource&quot; method" name="Lib\DscResource.Calls &quot;Get-&lt;ResourceName&gt;TargetResource&quot; method" time="0.1228" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Test-&lt;ResourceName&gt;TargetResource&quot; method" name="Lib\DscResource.Calls &quot;Test-&lt;ResourceName&gt;TargetResource&quot; method" time="0.1777" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Return $false when &quot;Test-&lt;ResourceName&gt;TargetResource&quot; throws (#104)" name="Lib\DscResource.Return $false when &quot;Test-&lt;ResourceName&gt;TargetResource&quot; throws (#104)" time="0.0449" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Set-&lt;ResourceName&gt;TargetResource&quot; method" name="Lib\DscResource.Calls &quot;Set-&lt;ResourceName&gt;TargetResource&quot; method" time="0.1305" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not call &quot;Set-&lt;ResourceName&gt;TargetResource&quot; if &quot;TestDscResource&quot; passes" name="Lib\DscResource.Does not call &quot;Set-&lt;ResourceName&gt;TargetResource&quot; if &quot;TestDscResource&quot; passes" time="0.1572" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does call &quot;Set-&lt;ResourceName&gt;TargetResource&quot; if &quot;TestDscResource&quot; fails" name="Lib\DscResource.Does call &quot;Set-&lt;ResourceName&gt;TargetResource&quot; if &quot;TestDscResource&quot; fails" time="0.0661" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when &quot;TestDscResource&quot; fails and &quot;ResourceName&quot; matches &quot;PendingReboot&quot;" name="Lib\DscResource.Throws when &quot;TestDscResource&quot; fails and &quot;ResourceName&quot; matches &quot;PendingReboot&quot;" time="0.0525" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\DscResourceModule" executed="True" result="Success" success="True" time="3.2207" asserts="0" description="Lib\DscResourceModule"> + <results> + <test-case description="Returns &quot;True&quot; when the module contains a &quot;DSCResources&quot; folder" name="Lib\DscResourceModule.Returns &quot;True&quot; when the module contains a &quot;DSCResources&quot; folder" time="2.6492" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns &quot;False&quot; when the module does not contain a &quot;DSCResources&quot; folder" name="Lib\DscResourceModule.Returns &quot;False&quot; when the module does not contain a &quot;DSCResources&quot; folder" time="0.0247" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns &quot;True&quot; when the module .psm1 contains a &quot;[DSCResource()]&quot; definition" name="Lib\DscResourceModule.Returns &quot;True&quot; when the module .psm1 contains a &quot;[DSCResource()]&quot; definition" time="0.0521" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns &quot;False&quot; when the module .psm1 does not contain a &quot;[DSCResource()]&quot; definition" name="Lib\DscResourceModule.Returns &quot;False&quot; when the module .psm1 does not contain a &quot;[DSCResource()]&quot; definition" time="0.0344" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns module with &quot;DSCResources&quot;" name="Lib\DscResourceModule.Returns module with &quot;DSCResources&quot;" time="0.1721" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns module with &quot;[DSCResource()]&quot;" name="Lib\DscResourceModule.Returns module with &quot;[DSCResource()]&quot;" time="0.0621" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return a module without &quot;DSCResources&quot; and &quot;[DSCResource()]&quot;" name="Lib\DscResourceModule.Does not return a module without &quot;DSCResources&quot; and &quot;[DSCResource()]&quot;" time="0.0424" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns versioned module with &quot;DSCResources&quot;" name="Lib\DscResourceModule.Returns versioned module with &quot;DSCResources&quot;" time="0.0611" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns versioned module with &quot;[DSCResource()]&quot;" name="Lib\DscResourceModule.Returns versioned module with &quot;[DSCResource()]&quot;" time="0.0712" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return a versioned module without &quot;DSCResources&quot; and &quot;[DSCResource()]&quot;" name="Lib\DscResourceModule.Does not return a versioned module without &quot;DSCResources&quot; and &quot;[DSCResource()]&quot;" time="0.0514" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\Internal" executed="True" result="Success" success="True" time="4.6948" asserts="0" description="Lib\Internal"> + <results> + <test-case description="Resolves existing home path" name="Lib\Internal.Resolves existing home path" time="2.5537" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Resolves non-existent home path" name="Lib\Internal.Resolves non-existent home path" time="0.0513" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Start-Process&quot; with correct process path" name="Lib\Internal.Calls &quot;Start-Process&quot; with correct process path" time="0.147" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Start-Process&quot; with correct arguments" name="Lib\Internal.Calls &quot;Start-Process&quot; with correct arguments" time="0.0642" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Waits for &quot;Start-Process&quot; to exit" name="Lib\Internal.Waits for &quot;Start-Process&quot; to exit" time="0.0523" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Warns when process exits with non-zero exit code" name="Lib\Internal.Warns when process exits with non-zero exit code" time="0.0563" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return call stack information when &quot;$labDefaults.CallStackLogging&quot; = &quot;$null&quot;" name="Lib\Internal.Does not return call stack information when &quot;$labDefaults.CallStackLogging&quot; = &quot;$null&quot;" time="0.0767" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return call stack information when &quot;$labDefaults.CallStackLogging&quot; = &quot;$false&quot;" name="Lib\Internal.Does not return call stack information when &quot;$labDefaults.CallStackLogging&quot; = &quot;$false&quot;" time="0.0364" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns call stack information when &quot;$labDefaults.CallStackLogging&quot; = &quot;$true&quot;" name="Lib\Internal.Returns call stack information when &quot;$labDefaults.CallStackLogging&quot; = &quot;$true&quot;" time="0.022" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;GetFormattedMessage&quot; method" name="Lib\Internal.Calls &quot;GetFormattedMessage&quot; method" time="0.1089" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Write-Verbose&quot; method with test message" name="Lib\Internal.Calls &quot;Write-Verbose&quot; method with test message" time="0.0592" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;GetFormattedMessage&quot; method" name="Lib\Internal.Calls &quot;GetFormattedMessage&quot; method" time="0.1283" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Write-Warning&quot; method with test message" name="Lib\Internal.Calls &quot;Write-Warning&quot; method with test message" time="0.0573" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.Collections.Hashtable&quot; object" name="Lib\Internal.Returns a &quot;System.Collections.Hashtable&quot; object" time="0.12" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Converts property value types correctly" name="Lib\Internal.Converts property value types correctly" time="0.0294" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Ignores &quot;$null&quot; values when specified" name="Lib\Internal.Ignores &quot;$null&quot; values when specified" time="0.0493" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Converts nested &quot;PSCustomObject&quot; types to a hashtable" name="Lib\Internal.Converts nested &quot;PSCustomObject&quot; types to a hashtable" time="0.0438" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when computer name does not contain invalid characters" name="Lib\Internal.Passes when computer name does not contain invalid characters" time="0.1164" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '~' character" name="Lib\Internal.Fails when computer name contains invalid '~' character" time="0.0256" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '!' character" name="Lib\Internal.Fails when computer name contains invalid '!' character" time="0.0394" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '@' character" name="Lib\Internal.Fails when computer name contains invalid '@' character" time="0.0231" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '#' character" name="Lib\Internal.Fails when computer name contains invalid '#' character" time="0.044" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '$' character" name="Lib\Internal.Fails when computer name contains invalid '$' character" time="0.0195" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '%' character" name="Lib\Internal.Fails when computer name contains invalid '%' character" time="0.0394" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '^' character" name="Lib\Internal.Fails when computer name contains invalid '^' character" time="0.0246" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '&amp;' character" name="Lib\Internal.Fails when computer name contains invalid '&amp;' character" time="0.0388" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '*' character" name="Lib\Internal.Fails when computer name contains invalid '*' character" time="0.0204" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '(' character" name="Lib\Internal.Fails when computer name contains invalid '(' character" time="0.0405" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid ')' character" name="Lib\Internal.Fails when computer name contains invalid ')' character" time="0.0177" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '=' character" name="Lib\Internal.Fails when computer name contains invalid '=' character" time="0.0303" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '+' character" name="Lib\Internal.Fails when computer name contains invalid '+' character" time="0.0189" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '_' character" name="Lib\Internal.Fails when computer name contains invalid '_' character" time="0.0186" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '[' character" name="Lib\Internal.Fails when computer name contains invalid '[' character" time="0.0375" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid ']' character" name="Lib\Internal.Fails when computer name contains invalid ']' character" time="0.0257" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '{' character" name="Lib\Internal.Fails when computer name contains invalid '{' character" time="0.0203" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '}' character" name="Lib\Internal.Fails when computer name contains invalid '}' character" time="0.038" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '\' character" name="Lib\Internal.Fails when computer name contains invalid '\' character" time="0.0255" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '|' character" name="Lib\Internal.Fails when computer name contains invalid '|' character" time="0.0345" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid ';' character" name="Lib\Internal.Fails when computer name contains invalid ';' character" time="0.0282" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid ':' character" name="Lib\Internal.Fails when computer name contains invalid ':' character" time="0.0247" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '.' character" name="Lib\Internal.Fails when computer name contains invalid '.' character" time="0.0352" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid ''' character" name="Lib\Internal.Fails when computer name contains invalid ''' character" time="0.018" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '&quot;' character" name="Lib\Internal.Fails when computer name contains invalid '&quot;' character" time="0.0268" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid ',' character" name="Lib\Internal.Fails when computer name contains invalid ',' character" time="0.0229" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '&lt;' character" name="Lib\Internal.Fails when computer name contains invalid '&lt;' character" time="0.0421" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '&gt;' character" name="Lib\Internal.Fails when computer name contains invalid '&gt;' character" time="0.0437" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '/' character" name="Lib\Internal.Fails when computer name contains invalid '/' character" time="0.0257" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid '?' character" name="Lib\Internal.Fails when computer name contains invalid '?' character" time="0.0518" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when computer name contains invalid ' ' character" name="Lib\Internal.Fails when computer name contains invalid ' ' character" time="0.0211" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\Iso" executed="True" result="Success" success="True" time="3.0874" asserts="0" description="Lib\Iso"> + <results> + <test-case description="Mounts ISO image read-only" name="Lib\Iso.Mounts ISO image read-only" time="2.6775" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Copies ISO image contents to destination path recursively" name="Lib\Iso.Copies ISO image contents to destination path recursively" time="0.2094" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Disounts ISO image" name="Lib\Iso.Disounts ISO image" time="0.2005" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\Module" executed="True" result="Success" success="True" time="7.5297" asserts="0" description="Lib\Module"> + <results> + <test-case description="Returns all PowerShell modules if no &quot;Name&quot; is specified" name="Lib\Module.Returns all PowerShell modules if no &quot;Name&quot; is specified" time="2.5118" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns all PowerShell modules if &quot;*&quot; is specified" name="Lib\Module.Returns all PowerShell modules if &quot;*&quot; is specified" time="0.0215" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns all DSC resources if no &quot;Name&quot; is specified" name="Lib\Module.Returns all DSC resources if no &quot;Name&quot; is specified" time="0.0279" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns all DSC resources if &quot;*&quot; is specified" name="Lib\Module.Returns all DSC resources if &quot;*&quot; is specified" time="0.041" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns matching PowerShell modules when &quot;Name&quot; is specified" name="Lib\Module.Returns matching PowerShell modules when &quot;Name&quot; is specified" time="0.0502" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns matching DSC resources when &quot;Name&quot; is specified" name="Lib\Module.Returns matching DSC resources when &quot;Name&quot; is specified" time="0.0695" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Warns if a PowerShell module cannot be resolved" name="Lib\Module.Warns if a PowerShell module cannot be resolved" time="0.0364" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Warns if a DSC resource cannot be resolved" name="Lib\Module.Warns if a DSC resource cannot be resolved" time="0.0397" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if a PowerShell module cannot be resolved and &quot;ThrowIfNotFound&quot; is specified" name="Lib\Module.Throws if a PowerShell module cannot be resolved and &quot;ThrowIfNotFound&quot; is specified" time="0.0262" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if a DSC resource cannot be resolved and &quot;ThrowIfNotFound&quot; is specified" name="Lib\Module.Throws if a DSC resource cannot be resolved and &quot;ThrowIfNotFound&quot; is specified" time="0.0532" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns only a single module" name="Lib\Module.Returns only a single module" time="0.1671" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns only a single module by &quot;Module&quot;" name="Lib\Module.Returns only a single module by &quot;Module&quot;" time="0.0846" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns the latest PSGallery module version by default" name="Lib\Module.Returns the latest PSGallery module version by default" time="0.0741" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns the latest GitHub module version by default" name="Lib\Module.Returns the latest GitHub module version by default" time="0.0598" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns the latest PSGallery module version when &quot;MinimumVersion&quot; is specified" name="Lib\Module.Returns the latest PSGallery module version when &quot;MinimumVersion&quot; is specified" time="0.0587" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns the latest GitHub module version when &quot;MinimumVersion&quot; is specified" name="Lib\Module.Returns the latest GitHub module version when &quot;MinimumVersion&quot; is specified" time="0.0696" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns the exact PSGallery module version when &quot;RequiredVersion&quot; is specified" name="Lib\Module.Returns the exact PSGallery module version when &quot;RequiredVersion&quot; is specified" time="0.067" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns the exact GitHub module version when &quot;RequiredVersion&quot; is specified" name="Lib\Module.Returns the exact GitHub module version when &quot;RequiredVersion&quot; is specified" time="0.0813" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return PSGallery module when &quot;MinimumVersion&quot; is not cached" name="Lib\Module.Does not return PSGallery module when &quot;MinimumVersion&quot; is not cached" time="0.0693" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return PSGallery module when &quot;RequiredVersion&quot; is not cached" name="Lib\Module.Does not return PSGallery module when &quot;RequiredVersion&quot; is not cached" time="0.0689" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return GitHub module when &quot;MinimumVersion&quot; is not cached" name="Lib\Module.Does not return GitHub module when &quot;MinimumVersion&quot; is not cached" time="0.0643" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return GitHub module when &quot;RequiredVersion&quot; is not cached" name="Lib\Module.Does not return GitHub module when &quot;RequiredVersion&quot; is not cached" time="0.0638" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a FileSystem provider [System.IO.DirectoryInfo] object type" name="Lib\Module.Returns a FileSystem provider [System.IO.DirectoryInfo] object type" time="0.062" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a FileSystem provider [System.IO.FileInfo] object type" name="Lib\Module.Returns a FileSystem provider [System.IO.FileInfo] object type" time="0.0658" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if module &quot;Name&quot; is not specified" name="Lib\Module.Throws if module &quot;Name&quot; is not specified" time="0.0625" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if GitHub module &quot;Owner&quot; is not specified" name="Lib\Module.Throws if GitHub module &quot;Owner&quot; is not specified" time="0.0457" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if FileSystem module &quot;Path&quot; is not specified" name="Lib\Module.Throws if FileSystem module &quot;Path&quot; is not specified" time="0.0473" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if FileSystem module &quot;Path&quot; does not exist" name="Lib\Module.Throws if FileSystem module &quot;Path&quot; does not exist" time="0.0369" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if FileSystem module &quot;Path&quot; is not a &quot;.zip&quot; file" name="Lib\Module.Throws if FileSystem module &quot;Path&quot; is not a &quot;.zip&quot; file" time="0.0424" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when module is found" name="Lib\Module.Passes when module is found" time="0.1496" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when module is not found" name="Lib\Module.Fails when module is not found" time="0.0551" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a [System.IO.FileInfo] object type" name="Lib\Module.Returns a [System.IO.FileInfo] object type" time="0.1649" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Renames PSGallery module to &quot;&lt;ModuleName&gt;-v&lt;Version&gt;.zip" name="Lib\Module.Renames PSGallery module to &quot;&lt;ModuleName&gt;-v&lt;Version&gt;.zip" time="0.0441" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Renames GitHub module to &quot;&lt;ModuleName&gt;-v&lt;Version&gt;_&lt;Owner&gt;_&lt;Branch&gt;.zip" name="Lib\Module.Renames GitHub module to &quot;&lt;ModuleName&gt;-v&lt;Version&gt;_&lt;Owner&gt;_&lt;Branch&gt;.zip" time="0.0589" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes existing cached module file" name="Lib\Module.Removes existing cached module file" time="0.1884" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a [System.IO.FileInfo] object type" name="Lib\Module.Returns a [System.IO.FileInfo] object type" time="0.336" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ResolvePSGalleryModuleUri&quot; with &quot;RequiredVersion&quot; when specified" name="Lib\Module.Calls &quot;ResolvePSGalleryModuleUri&quot; with &quot;RequiredVersion&quot; when specified" time="0.0959" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ResolvePSGalleryModuleUri&quot; with &quot;MinimumVersion&quot; when specified" name="Lib\Module.Calls &quot;ResolvePSGalleryModuleUri&quot; with &quot;MinimumVersion&quot; when specified" time="0.0944" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a [System.IO.FileInfo] object type" name="Lib\Module.Returns a [System.IO.FileInfo] object type" time="0.2234" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ResolveGitHubModuleUri&quot; with &quot;Owner&quot; and &quot;Branch&quot;" name="Lib\Module.Calls &quot;ResolveGitHubModuleUri&quot; with &quot;Owner&quot; and &quot;Branch&quot;" time="0.0971" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ResolveGitHubModuleUri&quot; with &quot;OverrideRepositoryName&quot; when specified" name="Lib\Module.Calls &quot;ResolveGitHubModuleUri&quot; with &quot;OverrideRepositoryName&quot; when specified" time="0.1122" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when &quot;Owner&quot; is not specified" name="Lib\Module.Throws when &quot;Owner&quot; is not specified" time="0.0695" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Warns when no &quot;Branch&quot; is specified" name="Lib\Module.Warns when no &quot;Branch&quot; is specified" time="0.1092" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads module from PSGallery when no Provider is specified" name="Lib\Module.Downloads module from PSGallery when no Provider is specified" time="0.2284" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads module from GitHub by ModuleInfo" name="Lib\Module.Downloads module from GitHub by ModuleInfo" time="0.0818" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads module from PSGallery when &quot;PSGallery&quot; Provider is specified" name="Lib\Module.Downloads module from PSGallery when &quot;PSGallery&quot; Provider is specified" time="0.0874" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads module from GitHub when &quot;GitHub&quot; Provider is specified" name="Lib\Module.Downloads module from GitHub when &quot;GitHub&quot; Provider is specified" time="0.1273" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not download module when &quot;FileSystem&quot; Provider is specified" name="Lib\Module.Does not download module when &quot;FileSystem&quot; Provider is specified" time="0.0765" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not download module when resource is cached" name="Lib\Module.Does not download module when resource is cached" time="0.1612" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a [System.IO.DirectoryInfo] object type" name="Lib\Module.Returns a [System.IO.DirectoryInfo] object type" time="0.3118" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Cleans existing module directory when &quot;Clean&quot; is specified" name="Lib\Module.Cleans existing module directory when &quot;Clean&quot; is specified" time="0.0964" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandZipArchive&quot; when &quot;PSGallery&quot; Provider is specified" name="Lib\Module.Calls &quot;ExpandZipArchive&quot; when &quot;PSGallery&quot; Provider is specified" time="0.0694" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandGitHubZipArchive&quot; when &quot;GitHub&quot; Provider is specified" name="Lib\Module.Calls &quot;ExpandGitHubZipArchive&quot; when &quot;GitHub&quot; Provider is specified" time="0.0643" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandGitHubZipArchive&quot; when &quot;GitHub&quot; Provider and &quot;OverrideRepository&quot; are specified" name="Lib\Module.Calls &quot;ExpandGitHubZipArchive&quot; when &quot;GitHub&quot; Provider and &quot;OverrideRepository&quot; are specified" time="0.0752" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandZipArchive&quot; when &quot;FileSystem&quot; Provider is specified and &quot;Path&quot; is a .zip file" name="Lib\Module.Calls &quot;ExpandZipArchive&quot; when &quot;FileSystem&quot; Provider is specified and &quot;Path&quot; is a .zip file" time="0.0822" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Copy-Item&quot; when &quot;FileSystem&quot; Provider is specified and &quot;Path&quot; is a directory" name="Lib\Module.Calls &quot;Copy-Item&quot; when &quot;FileSystem&quot; Provider is specified and &quot;Path&quot; is a directory" time="0.1003" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\Resource" executed="True" result="Success" success="True" time="4.4176" asserts="0" description="Lib\Resource"> + <results> + <test-case description="Returns a &quot;System.IO.DirectoryInfo&quot; object if target &quot;Path&quot; already exists" name="Lib\Resource.Returns a &quot;System.IO.DirectoryInfo&quot; object if target &quot;Path&quot; already exists" time="2.5086" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.IO.DirectoryInfo&quot; object if target &quot;Path&quot; does not exist" name="Lib\Resource.Returns a &quot;System.IO.DirectoryInfo&quot; object if target &quot;Path&quot; does not exist" time="0.0322" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates target &quot;Path&quot; if it does not exist" name="Lib\Resource.Creates target &quot;Path&quot; if it does not exist" time="0.0243" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.IO.DirectoryInfo&quot; object if target &quot;DirectoryInfo&quot; already exists" name="Lib\Resource.Returns a &quot;System.IO.DirectoryInfo&quot; object if target &quot;DirectoryInfo&quot; already exists" time="0.0387" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.IO.DirectoryInfo&quot; object if target &quot;DirectoryInfo&quot; does not exist" name="Lib\Resource.Returns a &quot;System.IO.DirectoryInfo&quot; object if target &quot;DirectoryInfo&quot; does not exist" time="0.0352" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates target &quot;DirectoryInfo&quot; if it does not exist" name="Lib\Resource.Creates target &quot;DirectoryInfo&quot; if it does not exist" time="0.0424" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns &quot;System.Collections.Hashtable&quot; type" name="Lib\Resource.Returns &quot;System.Collections.Hashtable&quot; type" time="0.1175" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns empty checksum if resource does not exist" name="Lib\Resource.Returns empty checksum if resource does not exist" time="0.0458" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns correct checksum if resource and checksum files exist" name="Lib\Resource.Returns correct checksum if resource and checksum files exist" time="0.0348" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns correct checksum if resource exists but checksum does not exist" name="Lib\Resource.Returns correct checksum if resource exists but checksum does not exist" time="0.0629" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns incorrect checksum if incorrect resource and checksum files exist" name="Lib\Resource.Returns incorrect checksum if incorrect resource and checksum files exist" time="0.052" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns incorrect checksum if incorrect resource exists but checksum does not exist" name="Lib\Resource.Returns incorrect checksum if incorrect resource exists but checksum does not exist" time="0.0516" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns true if resource exists but no checksum was specified" name="Lib\Resource.Returns true if resource exists but no checksum was specified" time="0.1313" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns true if resource exists and checksum is correct" name="Lib\Resource.Returns true if resource exists and checksum is correct" time="0.0531" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns false if resource does not exist" name="Lib\Resource.Returns false if resource does not exist" time="0.0676" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns false if resource exists but checksum is incorrect" name="Lib\Resource.Returns false if resource exists but checksum is incorrect" time="0.0859" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeWebClientDownload&quot; with specified Uri" name="Lib\Resource.Calls &quot;InvokeWebClientDownload&quot; with specified Uri" time="0.1692" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeWebClientDownload&quot; with specified destination Path" name="Lib\Resource.Calls &quot;InvokeWebClientDownload&quot; with specified destination Path" time="0.0843" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeWebClientDownload&quot; with default 64KB buffer size" name="Lib\Resource.Calls &quot;InvokeWebClientDownload&quot; with default 64KB buffer size" time="0.0689" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeWebClientDownload&quot; with 1MB buffer size for file resource" name="Lib\Resource.Calls &quot;InvokeWebClientDownload&quot; with 1MB buffer size for file resource" time="0.067" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates checksum file after download" name="Lib\Resource.Creates checksum file after download" time="0.0839" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates target parent directory if it does not exist" name="Lib\Resource.Creates target parent directory if it does not exist" time="0.1248" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.Management.Automation.PSCustomObject&quot; type" name="Lib\Resource.Returns a &quot;System.Management.Automation.PSCustomObject&quot; type" time="0.1799" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetResourceDownload&quot; if &quot;TestResourceDownload&quot; fails" name="Lib\Resource.Calls &quot;SetResourceDownload&quot; if &quot;TestResourceDownload&quot; fails" time="0.0969" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetResourceDownload&quot; if &quot;TestResourceDownload&quot; passes but -Force was specified" name="Lib\Resource.Calls &quot;SetResourceDownload&quot; if &quot;TestResourceDownload&quot; passes but -Force was specified" time="0.1017" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not call &quot;SetResourceDownload&quot; if &quot;TestResourceDownload&quot; passes" name="Lib\Resource.Does not call &quot;SetResourceDownload&quot; if &quot;TestResourceDownload&quot; passes" time="0.057" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\UnattendXml" executed="True" result="Success" success="True" time="3.09" asserts="0" description="Lib\UnattendXml"> + <results> + <test-case description="Returns a &quot;System.Xml.XmlDocument&quot; type" name="Lib\UnattendXml.Returns a &quot;System.Xml.XmlDocument&quot; type" time="2.515" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates equal number of &quot;x86&quot; and &quot;amd64&quot; components" name="Lib\UnattendXml.Creates equal number of &quot;x86&quot; and &quot;amd64&quot; components" time="0.0331" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets encoded Administrator password" name="Lib\UnattendXml.Sets encoded Administrator password" time="0.0439" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets timezone" name="Lib\UnattendXml.Sets timezone" time="0.0354" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets Input locale" name="Lib\UnattendXml.Sets Input locale" time="0.0431" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets System locale" name="Lib\UnattendXml.Sets System locale" time="0.0378" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets UI language" name="Lib\UnattendXml.Sets UI language" time="0.0306" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets User locale" name="Lib\UnattendXml.Sets User locale" time="0.0397" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets computer name" name="Lib\UnattendXml.Sets computer name" time="0.0398" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets product key" name="Lib\UnattendXml.Sets product key" time="0.0452" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Adds single synchronous command" name="Lib\UnattendXml.Adds single synchronous command" time="0.0403" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Adds multiple synchronous commands" name="Lib\UnattendXml.Adds multiple synchronous commands" time="0.0364" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Saves Xml file to disk" name="Lib\UnattendXml.Saves Xml file to disk" time="0.1497" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\VirtualMachine" executed="True" result="Success" success="True" time="5.1505" asserts="0" description="Lib\VirtualMachine"> + <results> + <test-case description="Returns generation 1 VM for x86 media architecture" name="Lib\VirtualMachine.Returns generation 1 VM for x86 media architecture" time="2.5232" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns generation 2 VM for x64 media architecture" name="Lib\VirtualMachine.Returns generation 2 VM for x64 media architecture" time="0.0783" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns generation 1 VM when custom &quot;MBR&quot; partition style is defined" name="Lib\VirtualMachine.Returns generation 1 VM when custom &quot;MBR&quot; partition style is defined" time="0.0846" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns generation 2 VM when custom &quot;GPT&quot; partition style is defined" name="Lib\VirtualMachine.Returns generation 2 VM when custom &quot;GPT&quot; partition style is defined" time="0.0858" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns generation 1 VM when image generation is &quot;VHD&quot;, but media &quot;x64&quot; and partition style is &quot;GPT&quot;" name="Lib\VirtualMachine.Returns generation 1 VM when image generation is &quot;VHD&quot;, but media &quot;x64&quot; and partition style is &quot;GPT&quot;" time="0.1083" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns additional &quot;VhdPath&quot; property" name="Lib\VirtualMachine.Returns additional &quot;VhdPath&quot; property" time="0.1145" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns additional &quot;RestartIfNeeded&quot; property" name="Lib\VirtualMachine.Returns additional &quot;RestartIfNeeded&quot; property" time="0.0928" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return &quot;Media&quot; property" name="Lib\VirtualMachine.Does not return &quot;Media&quot; property" time="0.0946" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return &quot;EnableGuestService&quot; property by default" name="Lib\VirtualMachine.Does not return &quot;EnableGuestService&quot; property by default" time="0.0983" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns &quot;EnableGuestService&quot; property when &quot;GuestIntegrationServices&quot; is specified" name="Lib\VirtualMachine.Returns &quot;EnableGuestService&quot; property when &quot;GuestIntegrationServices&quot; is specified" time="0.0932" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ResolveLabMedia&quot; with &quot;ConfigurationData&quot; when specified (#97)" name="Lib\VirtualMachine.Calls &quot;ResolveLabMedia&quot; with &quot;ConfigurationData&quot; when specified (#97)" time="0.0813" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" name="Lib\VirtualMachine.Calls &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" time="0.0841" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return &quot;ConfigurationData&quot; property by default (#97)" name="Lib\VirtualMachine.Does not return &quot;ConfigurationData&quot; property by default (#97)" time="0.0985" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Imports Hyper-V DSC resource" name="Lib\VirtualMachine.Imports Hyper-V DSC resource" time="0.2323" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns true when VM matches specified configuration" name="Lib\VirtualMachine.Returns true when VM matches specified configuration" time="0.1091" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns false when VM does not match specified configuration" name="Lib\VirtualMachine.Returns false when VM does not match specified configuration" time="0.113" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns false when error is thrown" name="Lib\VirtualMachine.Returns false when error is thrown" time="0.131" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;GetVirtualMachineProperties&quot; with &quot;ConfigurationData&quot; when specified (#97)" name="Lib\VirtualMachine.Calls &quot;GetVirtualMachineProperties&quot; with &quot;ConfigurationData&quot; when specified (#97)" time="0.0983" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Imports Hyper-V DSC resource" name="Lib\VirtualMachine.Imports Hyper-V DSC resource" time="0.1721" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Invokes Hyper-V DSC resource" name="Lib\VirtualMachine.Invokes Hyper-V DSC resource" time="0.111" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;GetVirtualMachineProperties&quot; with &quot;ConfigurationData&quot; when specified (#97)" name="Lib\VirtualMachine.Calls &quot;GetVirtualMachineProperties&quot; with &quot;ConfigurationData&quot; when specified (#97)" time="0.1293" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Imports Hyper-V DSC resource" name="Lib\VirtualMachine.Imports Hyper-V DSC resource" time="0.2304" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Invokes Hyper-V DSC resource" name="Lib\VirtualMachine.Invokes Hyper-V DSC resource" time="0.0878" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;GetVirtualMachineProperties&quot; with &quot;ConfigurationData&quot; when specified (#97)" name="Lib\VirtualMachine.Calls &quot;GetVirtualMachineProperties&quot; with &quot;ConfigurationData&quot; when specified (#97)" time="0.0986" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Lib\WindowsImage" executed="True" result="Success" success="True" time="5.3171" asserts="0" description="Lib\WindowsImage"> + <results> + <test-case description="Mounts ISO image" name="Lib\WindowsImage.Mounts ISO image" time="2.65" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not Mount WIM image" name="Lib\WindowsImage.Does not Mount WIM image" time="0.0955" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;GetWindowsImageIndex&quot; method when passing &quot;WimImageName&quot;" name="Lib\WindowsImage.Calls &quot;GetWindowsImageIndex&quot; method when passing &quot;WimImageName&quot;" time="0.2002" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Expand-WindowsImage&quot; with specified &quot;WimImageIndex&quot;" name="Lib\WindowsImage.Calls &quot;Expand-WindowsImage&quot; with specified &quot;WimImageIndex&quot;" time="0.3354" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Expand-WindowsImage&quot; with custom &quot;WimPath&quot;" name="Lib\WindowsImage.Calls &quot;Expand-WindowsImage&quot; with custom &quot;WimPath&quot;" time="0.4051" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Dismounts ISO image" name="Lib\WindowsImage.Dismounts ISO image" time="0.2934" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not dismount WIM image" name="Lib\WindowsImage.Does not dismount WIM image" time="0.2148" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;AddWindowsOptionalFeature&quot; when &quot;WindowsOptionalFeature&quot; is defined" name="Lib\WindowsImage.Calls &quot;AddWindowsOptionalFeature&quot; when &quot;WindowsOptionalFeature&quot; is defined" time="0.2411" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;AddWindowsOptionalFeature&quot; with custom &quot;SourcePath&quot;" name="Lib\WindowsImage.Calls &quot;AddWindowsOptionalFeature&quot; with custom &quot;SourcePath&quot;" time="0.135" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.Int32&quot; type" name="Lib\WindowsImage.Returns a &quot;System.Int32&quot; type" time="0.1906" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns the matching image index if found" name="Lib\WindowsImage.Returns the matching image index if found" time="0.0775" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns nothing when image index is not found" name="Lib\WindowsImage.Returns nothing when image index is not found" time="0.0991" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.String&quot; type" name="Lib\WindowsImage.Returns a &quot;System.String&quot; type" time="0.2124" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns the matching image name" name="Lib\WindowsImage.Returns the matching image name" time="0.0566" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns nothing when image name is not found" name="Lib\WindowsImage.Returns nothing when image name is not found" time="0.1103" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\Lab" executed="True" result="Success" success="True" time="5.8773" asserts="0" description="Src\Lab"> + <results> + <test-case description="Starts all VMs with matching boot order" name="Src\Lab.Starts all VMs with matching boot order" time="2.5843" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Starts all VMs with differing boot orders individually" name="Src\Lab.Starts all VMs with differing boot orders individually" time="0.1516" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Starts VM using display name" name="Src\Lab.Starts VM using display name" time="0.0836" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Starts VMs in boot order" name="Src\Lab.Starts VMs in boot order" time="0.2747" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not call &quot;Start-Sleep&quot; if a zero boot delay is specified" name="Src\Lab.Does not call &quot;Start-Sleep&quot; if a zero boot delay is specified" time="0.1524" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Stops all VMs with matching boot order" name="Src\Lab.Stops all VMs with matching boot order" time="0.2231" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Stops all VMs with differing boot orders individually" name="Src\Lab.Stops all VMs with differing boot orders individually" time="0.2079" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Stops VM using display name" name="Src\Lab.Stops VM using display name" time="0.1351" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Stops VMs in boot order" name="Src\Lab.Stops VMs in boot order" time="0.2335" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Stop-VM&quot; with &quot;Force&quot;" name="Src\Lab.Calls &quot;Stop-VM&quot; with &quot;Force&quot;" time="0.106" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not call &quot;Start-Sleep&quot; if a zero boot delay is specified" name="Src\Lab.Does not call &quot;Start-Sleep&quot; if a zero boot delay is specified" time="0.1117" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Restore-Lab&quot; with -Force switch" name="Src\Lab.Calls &quot;Restore-Lab&quot; with -Force switch" time="0.152" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Snapshots VMs when powered off" name="Src\Lab.Snapshots VMs when powered off" time="0.2589" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Snapshots VM using display name" name="Src\Lab.Snapshots VM using display name" time="0.0843" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Errors when there is one running VM" name="Src\Lab.Errors when there is one running VM" time="0.1063" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Errors when there are multiple running VMs" name="Src\Lab.Errors when there are multiple running VMs" time="0.1176" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Snapshots VMs when there are running VMs and -Force is specified" name="Src\Lab.Snapshots VMs when there are running VMs and -Force is specified" time="0.1298" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Restores specified snapshot when VMs are powered off" name="Src\Lab.Restores specified snapshot when VMs are powered off" time="0.3262" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Restores VM snapshot using display name" name="Src\Lab.Restores VM snapshot using display name" time="0.118" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Errors when there is a running VM" name="Src\Lab.Errors when there is a running VM" time="0.1345" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Restores specified snapshot when there are running VMs and -Force is specified" name="Src\Lab.Restores specified snapshot when there are running VMs and -Force is specified" time="0.1857" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabConfiguration" executed="True" result="Success" success="True" time="3.7485" asserts="0" description="Src\LabConfiguration"> + <results> + <test-case description="Calls &quot;Test-LabVM&quot; for each node" name="Src\LabConfiguration.Calls &quot;Test-LabVM&quot; for each node" time="2.6216" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if path is invalid" name="Src\LabConfiguration.Throws if path is invalid" time="0.1152" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not throw if &quot;.mof&quot; and &quot;.meta.mof&quot; files exist" name="Src\LabConfiguration.Does not throw if &quot;.mof&quot; and &quot;.meta.mof&quot; files exist" time="0.0477" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if &quot;.mof&quot; file is missing" name="Src\LabConfiguration.Throws if &quot;.mof&quot; file is missing" time="0.0415" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Warns if &quot;.meta.mof&quot; file is missing" name="Src\LabConfiguration.Warns if &quot;.meta.mof&quot; file is missing" time="0.046" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Warns if &quot;.mof&quot; file is missing but -SkipMofCheck is specified" name="Src\LabConfiguration.Warns if &quot;.mof&quot; file is missing but -SkipMofCheck is specified" time="0.0636" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws is &quot;Test-LabHostConfiguration&quot; fails" name="Src\LabConfiguration.Throws is &quot;Test-LabHostConfiguration&quot; fails" time="0.1447" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if path is invalid" name="Src\LabConfiguration.Throws if path is invalid" time="0.073" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;NewLabVM&quot; if node is not configured" name="Src\LabConfiguration.Calls &quot;NewLabVM&quot; if node is not configured" time="0.141" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not call &quot;NewLabVM&quot; if node is configured" name="Src\LabConfiguration.Does not call &quot;NewLabVM&quot; if node is configured" time="0.122" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;NewLabVM&quot; if node is configured but -Force is specified" name="Src\LabConfiguration.Calls &quot;NewLabVM&quot; if node is configured but -Force is specified" time="0.1383" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;RemoveLabVM&quot; for each node" name="Src\LabConfiguration.Calls &quot;RemoveLabVM&quot; for each node" time="0.1939" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabHostConfiguration" executed="True" result="Success" success="True" time="4.4227" asserts="0" description="Src\LabHostConfiguration"> + <results> + <test-case description="Installs &quot;Microsoft-Hyper-V-All&quot; feature with &quot;WindowsOptionalFeature&quot; on a desktop OS" name="Src\LabHostConfiguration.Installs &quot;Microsoft-Hyper-V-All&quot; feature with &quot;WindowsOptionalFeature&quot; on a desktop OS" time="2.4178" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Installs &quot;Hyper-V&quot; feature using &quot;WindowsFeature&quot; on a server OS" name="Src\LabHostConfiguration.Installs &quot;Hyper-V&quot; feature using &quot;WindowsFeature&quot; on a server OS" time="0.0572" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Installs &quot;RSAT-Hyper-V-Tools&quot; feature using &quot;WindowsFeature&quot; on a server OS" name="Src\LabHostConfiguration.Installs &quot;RSAT-Hyper-V-Tools&quot; feature using &quot;WindowsFeature&quot; on a server OS" time="0.0478" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Checks for a pending reboot" name="Src\LabHostConfiguration.Checks for a pending reboot" time="0.0416" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ImportDscResource once for each host configuration item" name="Src\LabHostConfiguration.Calls &quot;ImportDscResource once for each host configuration item" time="0.2251" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;GetDscResource once for each host configuration item" name="Src\LabHostConfiguration.Calls &quot;GetDscResource once for each host configuration item" time="0.1216" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when target paths exist" name="Src\LabHostConfiguration.Passes when target paths exist" time="0.4528" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when a target path does not exist" name="Src\LabHostConfiguration.Fails when a target path does not exist" time="0.0617" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when host configuration is correct" name="Src\LabHostConfiguration.Passes when host configuration is correct" time="0.1417" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when host configuration is incorrect" name="Src\LabHostConfiguration.Fails when host configuration is incorrect" time="0.1472" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when host configuration has a pending reboot" name="Src\LabHostConfiguration.Fails when host configuration has a pending reboot" time="0.1412" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when host configuration has a pending reboot but -IgnorePendingReboot is specified" name="Src\LabHostConfiguration.Passes when host configuration has a pending reboot but -IgnorePendingReboot is specified" time="0.1443" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not attempt to create an empty path" name="Src\LabHostConfiguration.Does not attempt to create an empty path" time="0.1599" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;NewDirectory&quot; for each path" name="Src\LabHostConfiguration.Calls &quot;NewDirectory&quot; for each path" time="0.1007" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeDscResource&quot; for each host configuration item" name="Src\LabHostConfiguration.Calls &quot;InvokeDscResource&quot; for each host configuration item" time="0.1621" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabHostDefaults" executed="True" result="Success" success="True" time="4.1138" asserts="0" description="Src\LabHostDefaults"> + <results> + <test-case description="Calls &quot;GetConfigurationData&quot;" name="Src\LabHostDefaults.Calls &quot;GetConfigurationData&quot;" time="2.6161" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns host configuration path" name="Src\LabHostDefaults.Returns host configuration path" time="0.0905" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Resolves path containing an environment variable" name="Src\LabHostDefaults.Resolves path containing an environment variable" time="0.1325" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls 'Set-LabDefaults' with passed 'ConfigurationPath' parameter" name="Src\LabHostDefaults.Calls 'Set-LabDefaults' with passed 'ConfigurationPath' parameter" time="0.1259" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls 'Set-LabDefaults' with passed 'DifferencingVhdPath' parameter" name="Src\LabHostDefaults.Calls 'Set-LabDefaults' with passed 'DifferencingVhdPath' parameter" time="0.145" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls 'Set-LabDefaults' with passed 'HotfixPath' parameter" name="Src\LabHostDefaults.Calls 'Set-LabDefaults' with passed 'HotfixPath' parameter" time="0.2004" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls 'Set-LabDefaults' with passed 'IsoPath' parameter" name="Src\LabHostDefaults.Calls 'Set-LabDefaults' with passed 'IsoPath' parameter" time="0.1334" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls 'Set-LabDefaults' with passed 'ParentVhdPath' parameter" name="Src\LabHostDefaults.Calls 'Set-LabDefaults' with passed 'ParentVhdPath' parameter" time="0.1474" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls 'Set-LabDefaults' with passed 'ResourcePath' parameter" name="Src\LabHostDefaults.Calls 'Set-LabDefaults' with passed 'ResourcePath' parameter" time="0.2151" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls 'Set-LabDefaults' with passed 'ModuleCachePath' parameter" name="Src\LabHostDefaults.Calls 'Set-LabDefaults' with passed 'ModuleCachePath' parameter" time="0.165" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Set-LabDefaults&quot; with passed &quot;ResourceShareName&quot; parameter" name="Src\LabHostDefaults.Calls &quot;Set-LabDefaults&quot; with passed &quot;ResourceShareName&quot; parameter" time="0.0769" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when passed an invalid path" name="Src\LabHostDefaults.Throws when passed an invalid path" time="0.0656" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabImage" executed="True" result="Success" success="True" time="7.798" asserts="0" description="Src\LabImage"> + <results> + <test-case description="Returns null when there is no parent image when Id specified" name="Src\LabImage.Returns null when there is no parent image when Id specified" time="2.6852" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns null when there is are no parent images" name="Src\LabImage.Returns null when there is are no parent images" time="0.1073" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns all available parent images when no Id is specified" name="Src\LabImage.Returns all available parent images when no Id is specified" time="0.136" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a single parent image when Id specified" name="Src\LabImage.Returns a single parent image when Id specified" time="0.1248" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns image generation 'VHD' for VHD file" name="Src\LabImage.Returns image generation 'VHD' for VHD file" time="0.1302" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns image generation 'VHDX' for VHDX file" name="Src\LabImage.Returns image generation 'VHDX' for VHDX file" time="0.1303" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when parent image is found" name="Src\LabImage.Passes when parent image is found" time="0.1585" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when parent image is not found" name="Src\LabImage.Fails when parent image is not found" time="0.0569" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" name="Src\LabImage.Calls &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" time="0.076" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if image already exists" name="Src\LabImage.Throws if image already exists" time="0.1711" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when no &quot;ImageName&quot; is defined (#148)" name="Src\LabImage.Throws when no &quot;ImageName&quot; is defined (#148)" time="0.2474" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Deletes parent VHDX when image creation fails" name="Src\LabImage.Deletes parent VHDX when image creation fails" time="0.2531" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Deletes existing image if it already exists and -Force is specified" name="Src\LabImage.Deletes existing image if it already exists and -Force is specified" time="0.2065" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeLabMediaImageDownload&quot; to download ISO media (if not present)" name="Src\LabImage.Calls &quot;InvokeLabMediaImageDownload&quot; to download ISO media (if not present)" time="0.2085" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;NewDiskImage&quot; with -PassThru to leave VHDX mounted" name="Src\LabImage.Calls &quot;NewDiskImage&quot; with -PassThru to leave VHDX mounted" time="0.2191" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Uses &quot;GPT&quot; partition style for x64 media" name="Src\LabImage.Uses &quot;GPT&quot; partition style for x64 media" time="0.2072" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Uses &quot;MBR&quot; partition style for x86 media" name="Src\LabImage.Uses &quot;MBR&quot; partition style for x86 media" time="0.2257" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Uses custom partition style when specified" name="Src\LabImage.Uses custom partition style when specified" time="0.2183" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandWindowsImage&quot; with the media WIM image name" name="Src\LabImage.Calls &quot;ExpandWindowsImage&quot; with the media WIM image name" time="0.213" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandWindowsImage&quot; with the media WIM image index" name="Src\LabImage.Calls &quot;ExpandWindowsImage&quot; with the media WIM image index" time="0.2582" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandWindowsImage&quot; with &quot;WindowsOptionalFeature&quot;" name="Src\LabImage.Calls &quot;ExpandWindowsImage&quot; with &quot;WindowsOptionalFeature&quot;" time="0.2899" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandWindowsImage&quot; with &quot;WimPath&quot;" name="Src\LabImage.Calls &quot;ExpandWindowsImage&quot; with &quot;WimPath&quot;" time="0.2217" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandWindowsImage&quot; with &quot;SourcePath&quot;" name="Src\LabImage.Calls &quot;ExpandWindowsImage&quot; with &quot;SourcePath&quot;" time="0.2213" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;AddDiskImageHotfix&quot; to inject hotfixes" name="Src\LabImage.Calls &quot;AddDiskImageHotfix&quot; to inject hotfixes" time="0.2361" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetDiskImageBootVolume&quot; to configure boot volume" name="Src\LabImage.Calls &quot;SetDiskImageBootVolume&quot; to configure boot volume" time="0.2503" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Dismounts image" name="Src\LabImage.Dismounts image" time="0.2605" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Test-LabImage&quot; and &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" name="Src\LabImage.Calls &quot;Test-LabImage&quot; and &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" time="0.285" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabMedia" executed="True" result="Success" success="True" time="5.5535" asserts="0" description="Src\LabMedia"> + <results> + <test-case description="Does not throw with valid mandatory parameters" name="Src\LabMedia.Does not throw with valid mandatory parameters" time="2.6391" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws with an invalid Uri" name="Src\LabMedia.Throws with an invalid Uri" time="0.0243" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when &quot;Id&quot; parameter is missing" name="Src\LabMedia.Throws when &quot;Id&quot; parameter is missing" time="0.0241" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when &quot;Filename&quot; parameter is missing" name="Src\LabMedia.Throws when &quot;Filename&quot; parameter is missing" time="0.0393" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when &quot;Architecture&quot; parameter is missing" name="Src\LabMedia.Throws when &quot;Architecture&quot; parameter is missing" time="0.0193" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when &quot;MediaType&quot; parameter is missing" name="Src\LabMedia.Throws when &quot;MediaType&quot; parameter is missing" time="0.0275" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when &quot;Uri&quot; parameter is missing" name="Src\LabMedia.Throws when &quot;Uri&quot; parameter is missing" time="0.0255" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns &quot;System.Management.Automation.PSCustomObject&quot; object type" name="Src\LabMedia.Returns &quot;System.Management.Automation.PSCustomObject&quot; object type" time="0.0183" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates ProductKey custom entry when &quot;ProductKey&quot; is specified" name="Src\LabMedia.Creates ProductKey custom entry when &quot;ProductKey&quot; is specified" time="0.0393" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if media Id cannot be resolved" name="Src\LabMedia.Throws if media Id cannot be resolved" time="0.1297" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns configuration data media entry if it exists" name="Src\LabMedia.Returns configuration data media entry if it exists" time="0.0202" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns default media if configuration data entry does not exist" name="Src\LabMedia.Returns default media if configuration data entry does not exist" time="0.0681" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns all built-in media when no &quot;Id&quot; is specified" name="Src\LabMedia.Returns all built-in media when no &quot;Id&quot; is specified" time="0.137" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a single matching built-in media when &quot;Id&quot; is specified" name="Src\LabMedia.Returns a single matching built-in media when &quot;Id&quot; is specified" time="0.0799" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns null if no built-in media is found when &quot;Id&quot; is specified" name="Src\LabMedia.Returns null if no built-in media is found when &quot;Id&quot; is specified" time="0.0621" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when media ISO has been downloaded" name="Src\LabMedia.Passes when media ISO has been downloaded" time="0.1892" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when media ISO has not been downloaded" name="Src\LabMedia.Fails when media ISO has not been downloaded" time="0.0798" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when media Id is not found" name="Src\LabMedia.Fails when media Id is not found" time="0.064" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.IO.FileInfo&quot; object type" name="Src\LabMedia.Returns a &quot;System.IO.FileInfo&quot; object type" time="0.15" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeResourceDownload&quot; with &quot;ParentVhdPath&quot; if media type is &quot;VHD&quot;" name="Src\LabMedia.Calls &quot;InvokeResourceDownload&quot; with &quot;ParentVhdPath&quot; if media type is &quot;VHD&quot;" time="0.085" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeResourceDownload&quot; with &quot;IsoPath&quot; if media type is &quot;ISO&quot;" name="Src\LabMedia.Calls &quot;InvokeResourceDownload&quot; with &quot;IsoPath&quot; if media type is &quot;ISO&quot;" time="0.0816" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeResourceDownload&quot; with &quot;IsoPath&quot; if media type is &quot;WIM&quot;" name="Src\LabMedia.Calls &quot;InvokeResourceDownload&quot; with &quot;IsoPath&quot; if media type is &quot;WIM&quot;" time="0.0735" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeResourceDownload&quot; with &quot;Force&quot; parameter when specified" name="Src\LabMedia.Calls &quot;InvokeResourceDownload&quot; with &quot;Force&quot; parameter when specified" time="0.0751" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeResourceDownload&quot; with large &quot;BufferSize&quot; for file Uris" name="Src\LabMedia.Calls &quot;InvokeResourceDownload&quot; with large &quot;BufferSize&quot; for file Uris" time="0.0699" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not call &quot;InvokeResourceDownload&quot; when &quot;DisableLocalFileCaching&quot; is enabled" name="Src\LabMedia.Does not call &quot;InvokeResourceDownload&quot; when &quot;DisableLocalFileCaching&quot; is enabled" time="0.0896" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns source Uri when &quot;DisableLocalFileCaching&quot; is enabled" name="Src\LabMedia.Returns source Uri when &quot;DisableLocalFileCaching&quot; is enabled" time="0.0921" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.IO.FileInfo&quot; object type" name="Src\LabMedia.Returns a &quot;System.IO.FileInfo&quot; object type" time="0.1663" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeResourceDownload&quot; with &quot;Checksum&quot; parameter when specified" name="Src\LabMedia.Calls &quot;InvokeResourceDownload&quot; with &quot;Checksum&quot; parameter when specified" time="0.0862" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeResourceDownload&quot; with &quot;Force&quot; parameter when specified" name="Src\LabMedia.Calls &quot;InvokeResourceDownload&quot; with &quot;Force&quot; parameter when specified" time="0.0909" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when custom media type is &quot;ISO&quot; and OperatingSystem is &quot;Linux&quot;" name="Src\LabMedia.Throws when custom media type is &quot;ISO&quot; and OperatingSystem is &quot;Linux&quot;" time="0.1202" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when custom media type is &quot;WIM&quot; and OperatingSystem is &quot;Linux&quot;" name="Src\LabMedia.Throws when custom media type is &quot;WIM&quot; and OperatingSystem is &quot;Linux&quot;" time="0.064" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when custom media type is &quot;ISO&quot; and &quot;ImageName&quot; is not specified" name="Src\LabMedia.Throws when custom media type is &quot;ISO&quot; and &quot;ImageName&quot; is not specified" time="0.0548" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when custom media type is &quot;WIM&quot; and &quot;ImageName&quot; is not specified" name="Src\LabMedia.Throws when custom media type is &quot;WIM&quot; and &quot;ImageName&quot; is not specified" time="0.0413" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when custom media already exists and &quot;Force&quot; is not specified" name="Src\LabMedia.Throws when custom media already exists and &quot;Force&quot; is not specified" time="0.0768" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not throw when custom media type is &quot;VHD&quot; and &quot;ImageName&quot; is not specified" name="Src\LabMedia.Does not throw when custom media type is &quot;VHD&quot; and &quot;ImageName&quot; is not specified" time="0.1215" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not throw when custom media already exists and &quot;Force&quot; is specified" name="Src\LabMedia.Does not throw when custom media already exists and &quot;Force&quot; is specified" time="0.0825" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes existing custom media entry when 'Id' does exist" name="Src\LabMedia.Removes existing custom media entry when 'Id' does exist" time="0.1883" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not remove any entries when custom media 'Id' doesn't exist" name="Src\LabMedia.Does not remove any entries when custom media 'Id' doesn't exist" time="0.0572" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabModule" executed="True" result="Success" success="True" time="2.6689" asserts="0" description="Src\LabModule"> + <results> + <test-case description="Returns &quot;System.Collections.Hashtable&quot; object type" name="Src\LabModule.Returns &quot;System.Collections.Hashtable&quot; object type" time="2.4534" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns all PowerShell modules when not defined on the node" name="Src\LabModule.Returns all PowerShell modules when not defined on the node" time="0.0506" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns all DSC resources when not defined on the node" name="Src\LabModule.Returns all DSC resources when not defined on the node" time="0.0462" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns PowerShell modules only defined on the node" name="Src\LabModule.Returns PowerShell modules only defined on the node" time="0.0579" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns DSC resource modules only defined on the node" name="Src\LabModule.Returns DSC resource modules only defined on the node" time="0.0608" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabResource" executed="True" result="Success" success="True" time="6.9746" asserts="0" description="Src\LabResource"> + <results> + <test-case description="Passes when no resources are defined in the configuration data" name="Src\LabResource.Passes when no resources are defined in the configuration data" time="2.5782" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when all defined resources are present and &quot;Id&quot; parameter is not specified" name="Src\LabResource.Passes when all defined resources are present and &quot;Id&quot; parameter is not specified" time="0.1282" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when defined resource is present and &quot;Id&quot; parameter is specified" name="Src\LabResource.Passes when defined resource is present and &quot;Id&quot; parameter is specified" time="0.0525" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when a resource is missing and &quot;Id&quot; parameter is not specified" name="Src\LabResource.Fails when a resource is missing and &quot;Id&quot; parameter is not specified" time="0.084" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when a resource is missing and &quot;Id&quot; parameter is specified" name="Src\LabResource.Fails when a resource is missing and &quot;Id&quot; parameter is specified" time="0.0906" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Uses resource &quot;Filename&quot; property if specified" name="Src\LabResource.Uses resource &quot;Filename&quot; property if specified" time="0.0998" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;TestResourceDownload&quot; with &quot;Checksum&quot; parameter when defined" name="Src\LabResource.Calls &quot;TestResourceDownload&quot; with &quot;Checksum&quot; parameter when defined" time="0.1013" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads all media when &quot;MediaId&quot; parameter is not specified" name="Src\LabResource.Downloads all media when &quot;MediaId&quot; parameter is not specified" time="0.5067" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads only unique media when &quot;MediaId&quot; parameter is not specified" name="Src\LabResource.Downloads only unique media when &quot;MediaId&quot; parameter is not specified" time="0.2419" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads single media when &quot;MediaId&quot; parameter is specified" name="Src\LabResource.Downloads single media when &quot;MediaId&quot; parameter is specified" time="0.1624" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads all required hotfixes" name="Src\LabResource.Downloads all required hotfixes" time="0.1088" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads all resources when &quot;ResourceId&quot; parameter is not specified" name="Src\LabResource.Downloads all resources when &quot;ResourceId&quot; parameter is not specified" time="0.194" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads single resource when &quot;ResourceId&quot; parameter is specified" name="Src\LabResource.Downloads single resource when &quot;ResourceId&quot; parameter is specified" time="0.1053" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads a single DSC resource module" name="Src\LabResource.Downloads a single DSC resource module" time="0.1154" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads multiple DSC resource modules" name="Src\LabResource.Downloads multiple DSC resource modules" time="0.106" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads a single PowerShell module" name="Src\LabResource.Downloads a single PowerShell module" time="0.1135" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Downloads multiple PowerShell modules" name="Src\LabResource.Downloads multiple PowerShell modules" time="0.0963" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Uses resource &quot;Filename&quot; property if specified" name="Src\LabResource.Uses resource &quot;Filename&quot; property if specified" time="0.1177" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns resource record if &quot;ResourceId&quot; is found" name="Src\LabResource.Returns resource record if &quot;ResourceId&quot; is found" time="0.0915" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if &quot;ResourceId&quot; is not found" name="Src\LabResource.Throws if &quot;ResourceId&quot; is not found" time="0.0446" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates destination &quot;Resources&quot; directory if it does not exist on target file sytem" name="Src\LabResource.Creates destination &quot;Resources&quot; directory if it does not exist on target file sytem" time="0.1569" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Invokes &quot;Invoke-LabResourceDownload&quot; with &quot;ResourceId&quot; if resource is not found" name="Src\LabResource.Invokes &quot;Invoke-LabResourceDownload&quot; with &quot;ResourceId&quot; if resource is not found" time="0.1607" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Uses resource &quot;Filename&quot; property if specified" name="Src\LabResource.Uses resource &quot;Filename&quot; property if specified" time="0.1695" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Copies resource by default" name="Src\LabResource.Copies resource by default" time="0.158" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Copies resource to explicit target destination path" name="Src\LabResource.Copies resource to explicit target destination path" time="0.1569" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandZipArchive&quot; if &quot;Expand&quot; property is specified on a &quot;ZIP&quot; resource" name="Src\LabResource.Calls &quot;ExpandZipArchive&quot; if &quot;Expand&quot; property is specified on a &quot;ZIP&quot; resource" time="0.1754" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandZipArchive&quot; to explicit target path when &quot;Expand&quot; is specified on a &quot;ZIP&quot; resource" name="Src\LabResource.Calls &quot;ExpandZipArchive&quot; to explicit target path when &quot;Expand&quot; is specified on a &quot;ZIP&quot; resource" time="0.1308" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandIso&quot; if &quot;Expand&quot; property is specified on an &quot;ISO&quot; resource" name="Src\LabResource.Calls &quot;ExpandIso&quot; if &quot;Expand&quot; property is specified on an &quot;ISO&quot; resource" time="0.1226" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandIso&quot; to explicit target path when &quot;Expand&quot; is specified on a &quot;ISO&quot; resource" name="Src\LabResource.Calls &quot;ExpandIso&quot; to explicit target path when &quot;Expand&quot; is specified on a &quot;ISO&quot; resource" time="0.106" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if &quot;Expand&quot; property is specified on an &quot;EXE&quot; resource" name="Src\LabResource.Throws if &quot;Expand&quot; property is specified on an &quot;EXE&quot; resource" time="0.1001" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns &quot;System.Boolean&quot; object type" name="Src\LabResource.Returns &quot;System.Boolean&quot; object type" time="0.1294" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when local .EXE exists" name="Src\LabResource.Passes when local .EXE exists" time="0.0434" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when local .EXE does not exist" name="Src\LabResource.Fails when local .EXE does not exist" time="0.0327" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when local ISO folder exists" name="Src\LabResource.Passes when local ISO folder exists" time="0.0442" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when local ISO folder does not exist" name="Src\LabResource.Fails when local ISO folder does not exist" time="0.0401" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when local ZIP folder exists" name="Src\LabResource.Passes when local ZIP folder exists" time="0.0347" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when local ZIP folder does not exist" name="Src\LabResource.Fails when local ZIP folder does not exist" time="0.0359" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when local .EXE has &quot;Expand&quot; = &quot;True&quot;" name="Src\LabResource.Throws when local .EXE has &quot;Expand&quot; = &quot;True&quot;" time="0.0387" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabSwitch" executed="True" result="Success" success="True" time="3.8814" asserts="0" description="Src\LabSwitch"> + <results> + <test-case description="Returns a &quot;System.Collections.Hashtable&quot; object type" name="Src\LabSwitch.Returns a &quot;System.Collections.Hashtable&quot; object type" time="2.4442" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when switch type is &quot;External&quot; and &quot;NetAdapterName&quot; is not specified" name="Src\LabSwitch.Throws when switch type is &quot;External&quot; and &quot;NetAdapterName&quot; is not specified" time="0.0388" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes &quot;NetAdapterName&quot; if switch type is not &quot;External&quot;" name="Src\LabSwitch.Removes &quot;NetAdapterName&quot; if switch type is not &quot;External&quot;" time="0.0383" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes &quot;AllowManagementOS&quot; if switch type is not &quot;External&quot;" name="Src\LabSwitch.Removes &quot;AllowManagementOS&quot; if switch type is not &quot;External&quot;" time="0.0293" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.Collections.Hashtable&quot; object type" name="Src\LabSwitch.Returns a &quot;System.Collections.Hashtable&quot; object type" time="0.1502" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns specified network switch from configuration data if defined" name="Src\LabSwitch.Returns specified network switch from configuration data if defined" time="0.0954" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns existing &quot;External&quot; switch if &quot;Name&quot; cannot be resolved" name="Src\LabSwitch.Returns existing &quot;External&quot; switch if &quot;Name&quot; cannot be resolved" time="0.1133" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a default &quot;Internal&quot; switch if the switch cannot be resolved" name="Src\LabSwitch.Returns a default &quot;Internal&quot; switch if the switch cannot be resolved" time="0.0801" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when network switch is found" name="Src\LabSwitch.Passes when network switch is found" time="0.2285" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when an existing switch is found" name="Src\LabSwitch.Passes when an existing switch is found" time="0.0629" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when network switch is not found" name="Src\LabSwitch.Fails when network switch is not found" time="0.1043" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeDscResource&quot;" name="Src\LabSwitch.Calls &quot;InvokeDscResource&quot;" time="0.2071" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not call &quot;InvokeDscResource&quot; for an existing switch" name="Src\LabSwitch.Does not call &quot;InvokeDscResource&quot; for an existing switch" time="0.0491" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeDscResource&quot; with &quot;Ensure&quot; = &quot;Absent&quot;" name="Src\LabSwitch.Calls &quot;InvokeDscResource&quot; with &quot;Ensure&quot; = &quot;Absent&quot;" time="0.1847" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not call &quot;InvokeDscResource&quot; for an existing switch" name="Src\LabSwitch.Does not call &quot;InvokeDscResource&quot; for an existing switch" time="0.055" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabVM" executed="True" result="Success" success="True" time="10.8998" asserts="0" description="Src\LabVM"> + <results> + <test-case description="Returns a &quot;System.Collections.Hashtable&quot; object type" name="Src\LabVM.Returns a &quot;System.Collections.Hashtable&quot; object type" time="2.5547" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns node-specific configuration data when present" name="Src\LabVM.Returns node-specific configuration data when present" time="0.0318" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns node-specific configuration data when present and &quot;NoEnumerateWildcardNode&quot; is specified" name="Src\LabVM.Returns node-specific configuration data when present and &quot;NoEnumerateWildcardNode&quot; is specified" time="0.0405" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns wildcard node when node-specific data is not defined" name="Src\LabVM.Returns wildcard node when node-specific data is not defined" time="0.0421" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns default when &quot;NoEnumerateWildcardNode&quot; is specified and node-specific data is not defined" name="Src\LabVM.Returns default when &quot;NoEnumerateWildcardNode&quot; is specified and node-specific data is not defined" time="0.0557" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns default if wildcard and node-specific data is not present" name="Src\LabVM.Returns default if wildcard and node-specific data is not present" time="0.0556" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns &quot;Lability_&quot; specific properties over generic properties" name="Src\LabVM.Returns &quot;Lability_&quot; specific properties over generic properties" time="0.0461" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Adds &quot;EnvironmentPrefix&quot; to &quot;NodeDisplayName&quot; when defined" name="Src\LabVM.Adds &quot;EnvironmentPrefix&quot; to &quot;NodeDisplayName&quot; when defined" time="0.0464" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Adds &quot;EnvironmentSuffix&quot; to &quot;NodeDisplayName&quot; when defined" name="Src\LabVM.Adds &quot;EnvironmentSuffix&quot; to &quot;NodeDisplayName&quot; when defined" time="0.0706" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.Management.Automation.PSCustomObject&quot; object type" name="Src\LabVM.Returns a &quot;System.Management.Automation.PSCustomObject&quot; object type" time="0.2052" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns specific node when &quot;Name&quot; is specified" name="Src\LabVM.Returns specific node when &quot;Name&quot; is specified" time="0.1074" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns all nodes when &quot;Name&quot; is not specified" name="Src\LabVM.Returns all nodes when &quot;Name&quot; is not specified" time="0.1944" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Errors when node cannot be found" name="Src\LabVM.Errors when node cannot be found" time="0.1282" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.Boolean&quot; object type" name="Src\LabVM.Returns a &quot;System.Boolean&quot; object type" time="0.2495" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a result for each VM when &quot;Name&quot; is not specified" name="Src\LabVM.Returns a result for each VM when &quot;Name&quot; is not specified" time="0.2024" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes when VM is configured correctly" name="Src\LabVM.Passes when VM is configured correctly" time="0.1173" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when image is invalid" name="Src\LabVM.Fails when image is invalid" time="0.081" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when switch configuration is incorrect" name="Src\LabVM.Fails when switch configuration is incorrect" time="0.149" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when VM disk configuration is invalid" name="Src\LabVM.Fails when VM disk configuration is invalid" time="0.1168" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Fails when VM configuration is incorrect" name="Src\LabVM.Fails when VM configuration is incorrect" time="0.1312" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Test-LabImage&quot; and &quot;TestLabVMDisk&quot; with &quot;ConfigurationData&quot; (#97)" name="Src\LabVM.Calls &quot;Test-LabImage&quot; and &quot;TestLabVMDisk&quot; with &quot;ConfigurationData&quot; (#97)" time="0.1402" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when &quot;ClientCertificatePath&quot; cannot be found" name="Src\LabVM.Throws when &quot;ClientCertificatePath&quot; cannot be found" time="0.1193" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not throw when &quot;ClientCertificatePath&quot; cannot be found and &quot;IsQuickVM&quot; = &quot;$true&quot;" name="Src\LabVM.Does not throw when &quot;ClientCertificatePath&quot; cannot be found and &quot;IsQuickVM&quot; = &quot;$true&quot;" time="0.2355" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when &quot;RootCertificatePath&quot; cannot be found" name="Src\LabVM.Throws when &quot;RootCertificatePath&quot; cannot be found" time="0.0709" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not throw when &quot;RootCertificatePath&quot; cannot be found and &quot;IsQuickVM&quot; = &quot;$true&quot;" name="Src\LabVM.Does not throw when &quot;RootCertificatePath&quot; cannot be found and &quot;IsQuickVM&quot; = &quot;$true&quot;" time="0.3373" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates parent image if it is not already present" name="Src\LabVM.Creates parent image if it is not already present" time="0.3125" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetLabSwitch&quot; to configure VM switch" name="Src\LabVM.Calls &quot;SetLabSwitch&quot; to configure VM switch" time="0.2478" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetLabSwitch&quot; once per network switch" name="Src\LabVM.Calls &quot;SetLabSwitch&quot; once per network switch" time="0.2034" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ResetLabVMDisk&quot; to create VM disk" name="Src\LabVM.Calls &quot;ResetLabVMDisk&quot; to create VM disk" time="0.2065" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates virtual machine" name="Src\LabVM.Creates virtual machine" time="0.2051" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates virtual machine with &quot;GuestIntegrationServices&quot; when specified" name="Src\LabVM.Creates virtual machine with &quot;GuestIntegrationServices&quot; when specified" time="0.1998" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not inject resources when &quot;OperatingSystem&quot; is &quot;Linux&quot;" name="Src\LabVM.Does not inject resources when &quot;OperatingSystem&quot; is &quot;Linux&quot;" time="0.1897" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Injects VM resources" name="Src\LabVM.Injects VM resources" time="0.197" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes media &quot;ProductKey&quot; when specified (#134)" name="Src\LabVM.Passes media &quot;ProductKey&quot; when specified (#134)" time="0.2181" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not create a snapshot when &quot;NoSnapshot&quot; is specified" name="Src\LabVM.Does not create a snapshot when &quot;NoSnapshot&quot; is specified" time="0.1993" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Writes warning when VM &quot;WarningMessage&quot; is defined" name="Src\LabVM.Writes warning when VM &quot;WarningMessage&quot; is defined" time="0.1901" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Test-LabImage&quot; with &quot;ConfigurationData&quot; (#97)" name="Src\LabVM.Calls &quot;Test-LabImage&quot; with &quot;ConfigurationData&quot; (#97)" time="0.2221" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ResetLabVMDisk&quot; with &quot;ConfigurationData&quot; (#97)" name="Src\LabVM.Calls &quot;ResetLabVMDisk&quot; with &quot;ConfigurationData&quot; (#97)" time="0.235" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetLabVirtualMachine&quot; with &quot;ConfigurationData&quot; (#97)" name="Src\LabVM.Calls &quot;SetLabVirtualMachine&quot; with &quot;ConfigurationData&quot; (#97)" time="0.2987" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Warns when no client or root certificate is used" name="Src\LabVM.Warns when no client or root certificate is used" time="0.0608" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws when VM cannot be found" name="Src\LabVM.Throws when VM cannot be found" time="0.1351" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes all snapshots" name="Src\LabVM.Removes all snapshots" time="0.1821" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes the virtual machine" name="Src\LabVM.Removes the virtual machine" time="0.1608" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes the VHDX file" name="Src\LabVM.Removes the VHDX file" time="0.1635" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not remove the virtual switch by default" name="Src\LabVM.Does not remove the virtual switch by default" time="0.2736" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes the virtual switch when &quot;RemoveSwitch&quot; is specified" name="Src\LabVM.Removes the virtual switch when &quot;RemoveSwitch&quot; is specified" time="0.1784" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;RemoveLabVirtualMachine&quot; with &quot;ConfigurationData&quot; (#97)" name="Src\LabVM.Calls &quot;RemoveLabVirtualMachine&quot; with &quot;ConfigurationData&quot; (#97)" time="0.1574" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;RemoveLabVMDisk&quot; with &quot;ConfigurationData&quot; (#97)" name="Src\LabVM.Calls &quot;RemoveLabVMDisk&quot; with &quot;ConfigurationData&quot; (#97)" time="0.154" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes existing virtual machine" name="Src\LabVM.Removes existing virtual machine" time="0.1548" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates a new virtual machine" name="Src\LabVM.Creates a new virtual machine" time="0.1159" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates a new virtual machine without a snapshot when &quot;NoSnapshot&quot; is specified" name="Src\LabVM.Creates a new virtual machine without a snapshot when &quot;NoSnapshot&quot; is specified" time="0.0986" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates a new virtual machine" name="Src\LabVM.Creates a new virtual machine" time="0.1582" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates a new virtual machine without a snapshot when &quot;NoSnapshot&quot; is specified" name="Src\LabVM.Creates a new virtual machine without a snapshot when &quot;NoSnapshot&quot; is specified" time="0.0849" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes existing virtual machine" name="Src\LabVM.Removes existing virtual machine" time="0.1674" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabVMDefaults" executed="True" result="Success" success="True" time="5.046" asserts="0" description="Src\LabVMDefaults"> + <results> + <test-case description="Calls &quot;RemoveConfigurationData&quot; method" name="Src\LabVMDefaults.Calls &quot;RemoveConfigurationData&quot; method" time="2.624" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Returns a &quot;System.Management.Automation.PSCustomObject&quot; object type" name="Src\LabVMDefaults.Returns a &quot;System.Management.Automation.PSCustomObject&quot; object type" time="0.1235" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return &quot;BootOrder&quot; property" name="Src\LabVMDefaults.Does not return &quot;BootOrder&quot; property" time="0.0526" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Does not return &quot;BootOrder&quot; property" name="Src\LabVMDefaults.Does not return &quot;BootOrder&quot; property" time="0.1638" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;StartupMemory&quot; value" name="Src\LabVMDefaults.Sets &quot;StartupMemory&quot; value" time="0.0813" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;MinimumMemory&quot; value" name="Src\LabVMDefaults.Sets &quot;MinimumMemory&quot; value" time="0.0736" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;MaximumMemory&quot; value" name="Src\LabVMDefaults.Sets &quot;MaximumMemory&quot; value" time="0.0781" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;ProcessorCount&quot; value" name="Src\LabVMDefaults.Sets &quot;ProcessorCount&quot; value" time="0.0728" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;Media&quot; value" name="Src\LabVMDefaults.Sets &quot;Media&quot; value" time="0.1266" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;SwitchName&quot; value" name="Src\LabVMDefaults.Sets &quot;SwitchName&quot; value" time="0.0717" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;Timezone&quot; value" name="Src\LabVMDefaults.Sets &quot;Timezone&quot; value" time="0.0627" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;InputLocale&quot; value" name="Src\LabVMDefaults.Sets &quot;InputLocale&quot; value" time="0.0827" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;InputLocale&quot; value" name="Src\LabVMDefaults.Sets &quot;InputLocale&quot; value" time="0.0695" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;SystemLocale&quot; value" name="Src\LabVMDefaults.Sets &quot;SystemLocale&quot; value" time="0.0723" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;UILanguage&quot; value" name="Src\LabVMDefaults.Sets &quot;UILanguage&quot; value" time="0.0802" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;UserLocale&quot; value" name="Src\LabVMDefaults.Sets &quot;UserLocale&quot; value" time="0.0679" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;RegisteredOwner&quot; value" name="Src\LabVMDefaults.Sets &quot;RegisteredOwner&quot; value" time="0.0734" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;RegisteredOrganization&quot; value" name="Src\LabVMDefaults.Sets &quot;RegisteredOrganization&quot; value" time="0.0804" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;BootDelay&quot; value" name="Src\LabVMDefaults.Sets &quot;BootDelay&quot; value" time="0.074" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;CustomBootstrapOrder&quot; value" name="Src\LabVMDefaults.Sets &quot;CustomBootstrapOrder&quot; value" time="0.0945" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;GuestIntegrationServices&quot; value" name="Src\LabVMDefaults.Sets &quot;GuestIntegrationServices&quot; value" time="0.067" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;ClientCertificatePath&quot; value" name="Src\LabVMDefaults.Sets &quot;ClientCertificatePath&quot; value" time="0.0759" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Sets &quot;RootCertificatePath&quot; value" name="Src\LabVMDefaults.Sets &quot;RootCertificatePath&quot; value" time="0.1286" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if &quot;Timezone&quot; cannot be resolved" name="Src\LabVMDefaults.Throws if &quot;Timezone&quot; cannot be resolved" time="0.0563" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if &quot;ClientCertificatePath&quot; file cannot be found" name="Src\LabVMDefaults.Throws if &quot;ClientCertificatePath&quot; file cannot be found" time="0.0736" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if &quot;RootCertificatePath&quot; file cannot be found" name="Src\LabVMDefaults.Throws if &quot;RootCertificatePath&quot; file cannot be found" time="0.0659" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if &quot;StartupMemory&quot; is less than &quot;MinimumMemory&quot;" name="Src\LabVMDefaults.Throws if &quot;StartupMemory&quot; is less than &quot;MinimumMemory&quot;" time="0.0609" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if &quot;StartupMemory&quot; is greater than &quot;MaximumMemory&quot;" name="Src\LabVMDefaults.Throws if &quot;StartupMemory&quot; is greater than &quot;MaximumMemory&quot;" time="0.0606" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Throws if &quot;Media&quot; cannot be resolved" name="Src\LabVMDefaults.Throws if &quot;Media&quot; cannot be resolved" time="0.1183" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetConfigurationData&quot; to write data to disk" name="Src\LabVMDefaults.Calls &quot;SetConfigurationData&quot; to write data to disk" time="0.1136" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabVMDisk" executed="True" result="Success" success="True" time="4.9118" asserts="0" description="Src\LabVMDisk"> + <results> + <test-case description="Appends the VM's name to the host &quot;DifferencingVhdPath&quot;" name="Src\LabVMDisk.Appends the VM's name to the host &quot;DifferencingVhdPath&quot;" time="2.4433" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Get-LabMedia&quot; to resolve the parent VHDX path" name="Src\LabVMDisk.Calls &quot;Get-LabMedia&quot; to resolve the parent VHDX path" time="0.1822" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;GetDscResource&quot; with virtual machine name" name="Src\LabVMDisk.Calls &quot;GetDscResource&quot; with virtual machine name" time="0.0916" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" name="Src\LabVMDisk.Calls &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" time="0.1017" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Get-LabMedia&quot; to resolve the parent VHDX path" name="Src\LabVMDisk.Calls &quot;Get-LabMedia&quot; to resolve the parent VHDX path" time="0.2221" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;TestDscResource&quot; with virtual machine name" name="Src\LabVMDisk.Calls &quot;TestDscResource&quot; with virtual machine name" time="0.1187" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;TestDscResource&quot; with &quot;MaximumSize&quot; when image is not available (#104)" name="Src\LabVMDisk.Calls &quot;TestDscResource&quot; with &quot;MaximumSize&quot; when image is not available (#104)" time="0.1334" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;TestDscResource&quot; with &quot;VHDX&quot; when image is not available (#104)" name="Src\LabVMDisk.Calls &quot;TestDscResource&quot; with &quot;VHDX&quot; when image is not available (#104)" time="0.1372" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" name="Src\LabVMDisk.Calls &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" time="0.1239" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Get-LabMedia&quot; to resolve the parent VHDX path" name="Src\LabVMDisk.Calls &quot;Get-LabMedia&quot; to resolve the parent VHDX path" time="0.1951" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeDscResource&quot; with virtual machine name" name="Src\LabVMDisk.Calls &quot;InvokeDscResource&quot; with virtual machine name" time="0.1308" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" name="Src\LabVMDisk.Calls &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" time="0.1205" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Get-LabMedia&quot; to resolve the parent VHDX path" name="Src\LabVMDisk.Calls &quot;Get-LabMedia&quot; to resolve the parent VHDX path" time="0.1687" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;InvokeDscResource&quot; with virtual &quot;Ensure&quot; = &quot;Absent&quot;" name="Src\LabVMDisk.Calls &quot;InvokeDscResource&quot; with virtual &quot;Ensure&quot; = &quot;Absent&quot;" time="0.1243" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" name="Src\LabVMDisk.Calls &quot;Get-LabImage&quot; with &quot;ConfigurationData&quot; when specified (#97)" time="0.1402" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes any existing snapshots" name="Src\LabVMDisk.Removes any existing snapshots" time="0.1853" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Removes the existing VHDX file" name="Src\LabVMDisk.Removes the existing VHDX file" time="0.0917" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Creates a new VHDX file" name="Src\LabVMDisk.Creates a new VHDX file" time="0.0993" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;RemoveLabVMDisk&quot; and &quot;SetLabVMDisk&quot; with &quot;ConfigurationData&quot; when specified (#97)" name="Src\LabVMDisk.Calls &quot;RemoveLabVMDisk&quot; and &quot;SetLabVMDisk&quot; with &quot;ConfigurationData&quot; when specified (#97)" time="0.102" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabVMDiskFile" executed="True" result="Success" success="True" time="8.8784" asserts="0" description="Src\LabVMDiskFile"> + <results> + <test-case description="Calls &quot;InvokeModuleCacheDownload&quot; with &quot;Force&quot; when specified" name="Src\LabVMDiskFile.Calls &quot;InvokeModuleCacheDownload&quot; with &quot;Force&quot; when specified" time="2.6481" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandModuleCache&quot; with &quot;Clean&quot; when specified" name="Src\LabVMDiskFile.Calls &quot;ExpandModuleCache&quot; with &quot;Clean&quot; when specified" time="0.0678" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ExpandLabResource&quot; using &quot;ResourceShare&quot; path" name="Src\LabVMDiskFile.Calls &quot;ExpandLabResource&quot; using &quot;ResourceShare&quot; path" time="0.1834" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ResolveLabModule&quot; to query DSC resource modules" name="Src\LabVMDiskFile.Calls &quot;ResolveLabModule&quot; to query DSC resource modules" time="0.2039" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;ResolveLabModule&quot; to query PowerShell modules" name="Src\LabVMDiskFile.Calls &quot;ResolveLabModule&quot; to query PowerShell modules" time="0.0986" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetLabVMDiskModule&quot; to expand modules" name="Src\LabVMDiskFile.Calls &quot;SetLabVMDiskModule&quot; to expand modules" time="0.1189" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetUnattendXml&quot; to create &quot;\Windows\System32\Sysprep\Unattend.xml&quot; file" name="Src\LabVMDiskFile.Calls &quot;SetUnattendXml&quot; to create &quot;\Windows\System32\Sysprep\Unattend.xml&quot; file" time="0.1849" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes node &quot;ProductKey&quot; when specified (#134)" name="Src\LabVMDiskFile.Passes node &quot;ProductKey&quot; when specified (#134)" time="0.1005" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes media &quot;ProductKey&quot; when specified (#134)" name="Src\LabVMDiskFile.Passes media &quot;ProductKey&quot; when specified (#134)" time="0.0909" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Passes node &quot;ProductKey&quot; when node and media key specified (#134)" name="Src\LabVMDiskFile.Passes node &quot;ProductKey&quot; when node and media key specified (#134)" time="0.1179" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetBootStrap&quot; to inject default bootstrap" name="Src\LabVMDiskFile.Calls &quot;SetBootStrap&quot; to inject default bootstrap" time="0.1364" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetBootStrap&quot; to inject custom bootstrap when specified" name="Src\LabVMDiskFile.Calls &quot;SetBootStrap&quot; to inject custom bootstrap when specified" time="0.0669" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetBootStrap&quot; with &quot;CoreCLR&quot; to inject CoreCLR bootstrap when specified" name="Src\LabVMDiskFile.Calls &quot;SetBootStrap&quot; with &quot;CoreCLR&quot; to inject CoreCLR bootstrap when specified" time="0.092" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetSetupCompleteCmd&quot; with &quot;\Windows\Setup\Scripts&quot; path" name="Src\LabVMDiskFile.Calls &quot;SetSetupCompleteCmd&quot; with &quot;\Windows\Setup\Scripts&quot; path" time="0.0864" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Warns if .mof file cannot be found" name="Src\LabVMDiskFile.Warns if .mof file cannot be found" time="0.155" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Copies .mof file if found" name="Src\LabVMDiskFile.Copies .mof file if found" time="0.131" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Copies .meta.mof file if found" name="Src\LabVMDiskFile.Copies .meta.mof file if found" time="0.104" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Copies default client certificate" name="Src\LabVMDiskFile.Copies default client certificate" time="0.2084" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Copies default root certificate" name="Src\LabVMDiskFile.Copies default root certificate" time="0.1053" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Copies custom client certificate" name="Src\LabVMDiskFile.Copies custom client certificate" time="0.1156" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Copies custom root certificate" name="Src\LabVMDiskFile.Copies custom root certificate" time="0.1353" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Stops &quot;ShellHWDetection&quot; service" name="Src\LabVMDiskFile.Stops &quot;ShellHWDetection&quot; service" time="0.4391" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Mounts virtual machine VHDX file" name="Src\LabVMDiskFile.Mounts virtual machine VHDX file" time="0.2071" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Starts &quot;ShellHWDetection&quot; service" name="Src\LabVMDiskFile.Starts &quot;ShellHWDetection&quot; service" time="0.5509" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetLabVMDiskFileResource&quot; to copy node resources" name="Src\LabVMDiskFile.Calls &quot;SetLabVMDiskFileResource&quot; to copy node resources" time="0.831" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetLabVMDiskFileBootstrap&quot; to copy Lability bootstrap" name="Src\LabVMDiskFile.Calls &quot;SetLabVMDiskFileBootstrap&quot; to copy Lability bootstrap" time="0.311" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetLabVMDiskFileUnattendXml&quot; to copy unattended installation file" name="Src\LabVMDiskFile.Calls &quot;SetLabVMDiskFileUnattendXml&quot; to copy unattended installation file" time="0.2448" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetLabVMDiskFileMof&quot; to copy node DSC configuaration files" name="Src\LabVMDiskFile.Calls &quot;SetLabVMDiskFileMof&quot; to copy node DSC configuaration files" time="0.2723" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetLabVMDiskFileCertificate&quot; to copy node certificate files" name="Src\LabVMDiskFile.Calls &quot;SetLabVMDiskFileCertificate&quot; to copy node certificate files" time="0.2879" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;SetLabVMDiskFileModule&quot; to copy PowerShell/DSC resource modules" name="Src\LabVMDiskFile.Calls &quot;SetLabVMDiskFileModule&quot; to copy PowerShell/DSC resource modules" time="0.3263" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Dismounts virtual machine VHDX file" name="Src\LabVMDiskFile.Dismounts virtual machine VHDX file" time="0.257" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + <test-suite type="TestFixture" name="Src\LabVMSnapshot" executed="True" result="Success" success="True" time="3.1065" asserts="0" description="Src\LabVMSnapshot"> + <results> + <test-case description="Calls &quot;Get-VMSnapshot&quot; for each virtual machine specified" name="Src\LabVMSnapshot.Calls &quot;Get-VMSnapshot&quot; for each virtual machine specified" time="2.6133" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Remove-VMSnapshot&quot; for each virtual machine snapshot" name="Src\LabVMSnapshot.Calls &quot;Remove-VMSnapshot&quot; for each virtual machine snapshot" time="0.1222" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Checkpoint-VM&quot; for each virtual machine specified" name="Src\LabVMSnapshot.Calls &quot;Checkpoint-VM&quot; for each virtual machine specified" time="0.1588" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Calls &quot;Get-VMSnapshot&quot; for each virtual machine specified" name="Src\LabVMSnapshot.Calls &quot;Get-VMSnapshot&quot; for each virtual machine specified" time="0.1536" asserts="0" success="True" result="Success" executed="True" /> + <test-case description="Warns when snapshot name cannot be found" name="Src\LabVMSnapshot.Warns when snapshot name cannot be found" time="0.0585" asserts="0" success="True" result="Success" executed="True" /> + </results> + </test-suite> + </results> + </test-suite> +</test-results> \ No newline at end of file diff --git a/Tests/Lib/BootStrap.Tests.ps1 b/Tests/Lib/BootStrap.Tests.ps1 index 616305bf..4f1472b5 100644 --- a/Tests/Lib/BootStrap.Tests.ps1 +++ b/Tests/Lib/BootStrap.Tests.ps1 @@ -7,7 +7,7 @@ if (!$PSScriptRoot) { # $PSScriptRoot is not defined in 2.0 } $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\BootStrap' { diff --git a/Tests/Lib/ConfigurationData.Tests.ps1 b/Tests/Lib/ConfigurationData.Tests.ps1 index a1df4ec3..bb1b9295 100644 --- a/Tests/Lib/ConfigurationData.Tests.ps1 +++ b/Tests/Lib/ConfigurationData.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\ConfigurationData' { diff --git a/Tests/Lib/DiskImage.Tests.ps1 b/Tests/Lib/DiskImage.Tests.ps1 index e7a5ebd8..37def5c5 100644 --- a/Tests/Lib/DiskImage.Tests.ps1 +++ b/Tests/Lib/DiskImage.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\DiskImage' { diff --git a/Tests/Lib/DscModule.Tests.ps1 b/Tests/Lib/DscModule.Tests.ps1 index dc6443ae..eb64eaf8 100644 --- a/Tests/Lib/DscModule.Tests.ps1 +++ b/Tests/Lib/DscModule.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\DscModule' { diff --git a/Tests/Lib/DscResource.Tests.ps1 b/Tests/Lib/DscResource.Tests.ps1 index 3023c526..01e0773b 100644 --- a/Tests/Lib/DscResource.Tests.ps1 +++ b/Tests/Lib/DscResource.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\DscResource' { diff --git a/Tests/Lib/DscResourceModule.Tests.ps1 b/Tests/Lib/DscResourceModule.Tests.ps1 index 52d1a895..41b1b76f 100644 --- a/Tests/Lib/DscResourceModule.Tests.ps1 +++ b/Tests/Lib/DscResourceModule.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\DscResourceModule' { diff --git a/Tests/Lib/Internal.Tests.ps1 b/Tests/Lib/Internal.Tests.ps1 index 25c2bc2d..f56488b8 100644 --- a/Tests/Lib/Internal.Tests.ps1 +++ b/Tests/Lib/Internal.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\Internal' { diff --git a/Tests/Lib/Iso.Tests.ps1 b/Tests/Lib/Iso.Tests.ps1 index 9efb14c6..e5e55d76 100644 --- a/Tests/Lib/Iso.Tests.ps1 +++ b/Tests/Lib/Iso.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\Iso' { diff --git a/Tests/Lib/Module.Tests.ps1 b/Tests/Lib/Module.Tests.ps1 index d71e38e9..da0cfde9 100644 --- a/Tests/Lib/Module.Tests.ps1 +++ b/Tests/Lib/Module.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\Module' { diff --git a/Tests/Lib/Resource.Tests.ps1 b/Tests/Lib/Resource.Tests.ps1 index 61f24525..d11c7994 100644 --- a/Tests/Lib/Resource.Tests.ps1 +++ b/Tests/Lib/Resource.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\Resource' { diff --git a/Tests/Lib/UnattendXml.Tests.ps1 b/Tests/Lib/UnattendXml.Tests.ps1 index ec804daf..917f648a 100644 --- a/Tests/Lib/UnattendXml.Tests.ps1 +++ b/Tests/Lib/UnattendXml.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\UnattendXml' { diff --git a/Tests/Lib/VirtualMachine.Tests.ps1 b/Tests/Lib/VirtualMachine.Tests.ps1 index 3d9298c2..db8b80a0 100644 --- a/Tests/Lib/VirtualMachine.Tests.ps1 +++ b/Tests/Lib/VirtualMachine.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\VirtualMachine' { diff --git a/Tests/Lib/WindowsImage.Tests.ps1 b/Tests/Lib/WindowsImage.Tests.ps1 index a258966d..49c28415 100644 --- a/Tests/Lib/WindowsImage.Tests.ps1 +++ b/Tests/Lib/WindowsImage.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Lib\WindowsImage' { diff --git a/Tests/Src/Lab.Tests.ps1 b/Tests/Src/Lab.Tests.ps1 index 18526a42..4adbd327 100644 --- a/Tests/Src/Lab.Tests.ps1 +++ b/Tests/Src/Lab.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\Lab' { diff --git a/Tests/Src/LabConfiguration.Tests.ps1 b/Tests/Src/LabConfiguration.Tests.ps1 index 65551bcb..71534d93 100644 --- a/Tests/Src/LabConfiguration.Tests.ps1 +++ b/Tests/Src/LabConfiguration.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabConfiguration' { diff --git a/Tests/Src/LabHostConfiguration.Tests.ps1 b/Tests/Src/LabHostConfiguration.Tests.ps1 index 0a04afe1..49815f16 100644 --- a/Tests/Src/LabHostConfiguration.Tests.ps1 +++ b/Tests/Src/LabHostConfiguration.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabHostConfiguration' { diff --git a/Tests/Src/LabHostDefault.Tests.ps1 b/Tests/Src/LabHostDefault.Tests.ps1 index 7112df29..5bff5113 100644 --- a/Tests/Src/LabHostDefault.Tests.ps1 +++ b/Tests/Src/LabHostDefault.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabHostDefaults' { diff --git a/Tests/Src/LabImage.Tests.ps1 b/Tests/Src/LabImage.Tests.ps1 index 0a3b8f62..074a4205 100644 --- a/Tests/Src/LabImage.Tests.ps1 +++ b/Tests/Src/LabImage.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabImage' { diff --git a/Tests/Src/LabMedia.Tests.ps1 b/Tests/Src/LabMedia.Tests.ps1 index a14f1276..c6de608f 100644 --- a/Tests/Src/LabMedia.Tests.ps1 +++ b/Tests/Src/LabMedia.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabMedia' { diff --git a/Tests/Src/LabModule.Tests.ps1 b/Tests/Src/LabModule.Tests.ps1 index f4bc2b45..313e5a13 100644 --- a/Tests/Src/LabModule.Tests.ps1 +++ b/Tests/Src/LabModule.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabModule' { diff --git a/Tests/Src/LabNode.Tests.ps1 b/Tests/Src/LabNode.Tests.ps1 index 3f3eb207..ccdaba34 100644 --- a/Tests/Src/LabNode.Tests.ps1 +++ b/Tests/Src/LabNode.Tests.ps1 @@ -4,7 +4,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabNode' { diff --git a/Tests/Src/LabResource.Tests.ps1 b/Tests/Src/LabResource.Tests.ps1 index 91643078..ca9398f6 100644 --- a/Tests/Src/LabResource.Tests.ps1 +++ b/Tests/Src/LabResource.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabResource' { diff --git a/Tests/Src/LabSwitch.Tests.ps1 b/Tests/Src/LabSwitch.Tests.ps1 index 2380c617..4fde4d00 100644 --- a/Tests/Src/LabSwitch.Tests.ps1 +++ b/Tests/Src/LabSwitch.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabSwitch' { diff --git a/Tests/Src/LabVM.Tests.ps1 b/Tests/Src/LabVM.Tests.ps1 index f6917471..f0f88eb7 100644 --- a/Tests/Src/LabVM.Tests.ps1 +++ b/Tests/Src/LabVM.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabVM' { diff --git a/Tests/Src/LabVMDefault.Tests.ps1 b/Tests/Src/LabVMDefault.Tests.ps1 index 79c8ac1e..6efedf3c 100644 --- a/Tests/Src/LabVMDefault.Tests.ps1 +++ b/Tests/Src/LabVMDefault.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabVMDefaults' { diff --git a/Tests/Src/LabVMDisk.Tests.ps1 b/Tests/Src/LabVMDisk.Tests.ps1 index 9010a9d1..d648676f 100644 --- a/Tests/Src/LabVMDisk.Tests.ps1 +++ b/Tests/Src/LabVMDisk.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabVMDisk' { diff --git a/Tests/Src/LabVMDiskFile.Tests.ps1 b/Tests/Src/LabVMDiskFile.Tests.ps1 index 9e9e97d0..5c4b3796 100644 --- a/Tests/Src/LabVMDiskFile.Tests.ps1 +++ b/Tests/Src/LabVMDiskFile.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabVMDiskFile' { diff --git a/Tests/Src/LabVMSnapshot.Tests.ps1 b/Tests/Src/LabVMSnapshot.Tests.ps1 index ebe3a965..cafefb91 100644 --- a/Tests/Src/LabVMSnapshot.Tests.ps1 +++ b/Tests/Src/LabVMSnapshot.Tests.ps1 @@ -3,7 +3,7 @@ $moduleName = 'Lability'; $repoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path; -Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psm1") -Force; +Import-Module (Join-Path -Path $RepoRoot -ChildPath "$moduleName.psd1") -Force; Describe 'Src\LabVMSnapshot' {