From 9c548856f28d0f9ea61f161b0a8a4b41ea423756 Mon Sep 17 00:00:00 2001 From: Chris Ubben Date: Tue, 13 Sep 2016 19:22:33 -0700 Subject: [PATCH] Adding test coverage for PSDrive provider --- .../PSDrive.Tests.ps1 | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Management/PSDrive.Tests.ps1 diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/PSDrive.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/PSDrive.Tests.ps1 new file mode 100644 index 000000000..b9ccfce61 --- /dev/null +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/PSDrive.Tests.ps1 @@ -0,0 +1,45 @@ +Describe "Validate basic PSDrive Cmdlets" -Tags "CI" { + BeforeAll { + #just use same location as TestDrive for simplicity + $psDriveRoot = "TestDrive:" + $psDriveName = "PsTestDriveName" + } + + BeforeEach { + New-PSDrive -Name $psDriveName -PSProvider FileSystem -Root $psDriveRoot > $null + } + + AfterEach { + Remove-PSDrive -Name $psDriveName -ErrorAction SilentlyContinue + } + + It "Create a new PSDrive" { + $newDrive = New-PSDrive -Name "NewDifferentPSDrive" -PSProvider FileSystem -Root $psDriveRoot + try { + $newDrive.Name | Should Be "NewDifferentPSDrive" + $newDrive.Root | Should Be (Convert-Path $psDriveRoot) + } + finally { + Remove-PSDrive -Name "NewDifferentPSDrive" -ErrorAction SilentlyContinue + } + } + + It "Read data from a PSDrive" { + $driveProp = Get-ItemProperty ${psDriveName}: + $driveProp.PSDrive.Name | Should Be $psDriveName + } + + It "Remove the PSDrive" { + $existsBefore = Test-Path "${psDriveName}:\" + Remove-PSDrive -Name ${psDriveName} -ea SilentlyContinue + $existsAfter = Test-Path "${psDriveName}:\" + $existsBefore | Should Be $true + $existsAfter | Should Be $false + } + + It "Verify 'Used' and 'Free' script properties" { + $drive = Get-PSDrive -Name $psDriveName + $drive.Used -gt 0 | Should Be $true + $drive.Free -gt 0 | Should Be $true + } +}