forked from dsccommunity/xBitlocker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dsccommunity#38 from mhendric/AddBLBitlockerTests
Add MSFT_xBLBitlocker Unit Tests
- Loading branch information
Showing
3 changed files
with
105 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#region HEADER | ||
$script:DSCModuleName = 'xBitlocker' | ||
$script:DSCResourceName = 'MSFT_xBLBitlocker' | ||
|
||
# Unit Test Template Version: 1.2.4 | ||
$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) | ||
if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` | ||
(-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) | ||
{ | ||
& git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) | ||
} | ||
|
||
Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force | ||
|
||
$TestEnvironment = Initialize-TestEnvironment ` | ||
-DSCModuleName $script:DSCModuleName ` | ||
-DSCResourceName $script:DSCResourceName ` | ||
-ResourceType 'Mof' ` | ||
-TestType Unit | ||
|
||
#endregion HEADER | ||
|
||
function Invoke-TestSetup | ||
{ | ||
|
||
} | ||
|
||
function Invoke-TestCleanup | ||
{ | ||
Restore-TestEnvironment -TestEnvironment $TestEnvironment | ||
} | ||
|
||
# Begin Testing | ||
try | ||
{ | ||
Invoke-TestSetup | ||
|
||
InModuleScope $script:DSCResourceName { | ||
# Override helper functions | ||
function CheckForPreReqs {} | ||
|
||
# Setup common test variables | ||
$testMountPoint = 'C:' | ||
$testPrimaryProtector = 'TpmProtector' | ||
|
||
# Setup common Mocks | ||
Mock -CommandName CheckForPreReqs -Verifiable | ||
|
||
Describe 'MSFT_xBLBitlocker\Get-TargetResource' -Tag 'Get' { | ||
AfterEach { | ||
Assert-VerifiableMock | ||
} | ||
|
||
Context 'When Get-TargetResource is called' { | ||
It 'Should return a Hashtable with the input MountPoint' { | ||
$getResult = Get-TargetResource -MountPoint $testMountPoint -PrimaryProtector $testPrimaryProtector | ||
$getResult | Should -Be -Not $null | ||
$getResult.MountPoint | Should -Be $testMountPoint | ||
|
||
} | ||
} | ||
} | ||
|
||
Describe 'MSFT_xBLBitlocker\Set-TargetResource' -Tag 'Set' { | ||
AfterEach { | ||
Assert-VerifiableMock | ||
} | ||
|
||
Context 'When Set-TargetResource is called' { | ||
It 'Should call EnableBitlocker' { | ||
Mock -CommandName EnableBitlocker -Verifiable | ||
|
||
Set-TargetResource -MountPoint $testMountPoint -PrimaryProtector $testPrimaryProtector | ||
} | ||
} | ||
} | ||
|
||
Describe 'MSFT_xBLBitlocker\Test-TargetResource' -Tag 'Test' { | ||
AfterEach { | ||
Assert-VerifiableMock | ||
} | ||
|
||
Context 'When TestBitlocker returns True' { | ||
It 'Should return True' { | ||
Mock -CommandName TestBitlocker -Verifiable -MockWith { return $true } | ||
|
||
Test-TargetResource -MountPoint $testMountPoint -PrimaryProtector $testPrimaryProtector | Should -Be $true | ||
} | ||
} | ||
|
||
Context 'When TestBitlocker returns False' { | ||
It 'Should return False' { | ||
Mock -CommandName TestBitlocker -Verifiable -MockWith { return $false } | ||
|
||
Test-TargetResource -MountPoint $testMountPoint -PrimaryProtector $testPrimaryProtector | Should -Be $false | ||
} | ||
} | ||
} | ||
} | ||
} | ||
finally | ||
{ | ||
Invoke-TestCleanup | ||
} |
This file was deleted.
Oops, something went wrong.