Skip to content

Commit

Permalink
Add some code formating optimizations and merge file from 'Test' dire…
Browse files Browse the repository at this point in the history
…cotory
  • Loading branch information
J0F3 committed Jun 5, 2018
1 parent a4495a9 commit eff6c05
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 107 deletions.
105 changes: 0 additions & 105 deletions Test/Unit/xBitlockerCommon.tests.ps1

This file was deleted.

98 changes: 96 additions & 2 deletions Tests/Unit/xBitlockerCommon.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -P
# Begin Testing
try
{
InModuleScope "xBitlockerCommon" {
InModuleScope 'xBitlockerCommon' {

function Get-BitlockerVolume
{
Expand All @@ -16,7 +16,21 @@ try
)
}

Describe "xBitlockerCommon\TestBitlocker" {
function Get-WindowsFeature
{
param
(
[string]
$FeatureName
)
}

function Get-OSEdition
{

}

Describe 'xBitlockerCommon\TestBitlocker' {

Context 'When OS Volume is not Encrypted and No Key Protectors Assigned' {
Mock `
Expand Down Expand Up @@ -100,6 +114,86 @@ try
TestBitlocker -MountPoint 'C:' -PrimaryProtector 'TPMProtector' -RecoveryPasswordProtector $true | Should -Be $false
}
}

Context 'When OS is Windows Server Core and all required features are installed' {
Mock -CommandName Get-OSEdition -MockWith {
'Server Core'
}

Mock -CommandName Get-WindowsFeature -MockWith {
if ($FeatureName -eq 'RSAT-Feature-Tools-BitLocker-RemoteAdminTool')
{
return $null
}
else
{
return @{
DisplayName = $FeatureName
Name = $FeatureName
InstallState = 'Installed'
}
}
}

It 'Should run the CheckForPreReqs function without exceptions' {
{CheckForPreReqs} | Should -Not -Throw
}
}

Context 'When OS is Full Server and all required features are installed' {
Mock -CommandName Get-OSEdition -MockWith {
return 'Server'
}

Mock -CommandName Get-WindowsFeature -MockWith {
param
(
[string]
$FeatureName
)

return @{
DisplayName = $FeatureName
Name = $FeatureName
InstallState = 'Installed'
}
}

It 'Should run the CheckForPreReqs function without exceptions' {
{CheckForPreReqs} | Should -Not -Throw
}
}

Context 'When OS is Full Server without the required features (RSAT-Feature-Tools-BitLocker-RemoteAdminTool) installed' {
Mock -CommandName Get-OSEdition -MockWith {
return 'Server'
}

Mock -CommandName Get-WindowsFeature -MockWith {
param
(
[string]
$FeatureName
)

if ($FeatureName -eq 'RSAT-Feature-Tools-BitLocker-RemoteAdminTool')
{
return $null
}
else
{

return @{
DisplayName = $FeatureName
Name = $FeatureName
InstallState = 'Installed'
}
}
}
It 'The CheckForPreReqs function should throw an exceptions about missing Windows Feature' {
{CheckForPreReqs} | Should -Throw 'Required Bitlocker features need to be installed before xBitlocker can be used'
}
}
}
}
}
Expand Down

0 comments on commit eff6c05

Please sign in to comment.