-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
97 additions
and
2 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
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,19 @@ | ||
<# | ||
.SYNOPSIS | ||
Tests if the current OS is a Nano server. | ||
#> | ||
function Test-IsNanoServer | ||
{ | ||
[OutputType([System.Boolean])] | ||
[CmdletBinding()] | ||
param () | ||
|
||
$productDatacenterNanoServer = 143 | ||
$productStandardNanoServer = 144 | ||
|
||
$operatingSystemSKU = (Get-CimInstance -ClassName Win32_OperatingSystem).OperatingSystemSKU | ||
|
||
Write-Verbose -Message ($script:localizedData.TestIsNanoServerOperatingSystemSku -f $operatingSystemSKU) | ||
|
||
return ($operatingSystemSKU -in ($productDatacenterNanoServer, $productStandardNanoServer)) | ||
} |
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 |
---|---|---|
|
@@ -311,4 +311,4 @@ InModuleScope $ProjectName { | |
Assert-VerifiableMock | ||
} | ||
|
||
} | ||
} |
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,68 @@ | ||
$ProjectPath = "$PSScriptRoot\..\..\.." | Convert-Path | ||
$ProjectName = ((Get-ChildItem -Path $ProjectPath\*\*.psd1).Where{ | ||
($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) -and | ||
$(try | ||
{ | ||
Test-ModuleManifest $_.FullName -ErrorAction Stop | ||
} | ||
catch | ||
{ | ||
$false | ||
} ) | ||
}).BaseName | ||
|
||
Import-Module $ProjectName -Force | ||
|
||
Describe 'Test-IsNanoServer' -Tag TestIsNanoServer { | ||
function Get-CimInstance | ||
{ | ||
param | ||
( | ||
[Parameter()] | ||
[System.String] | ||
$ClassName | ||
) | ||
} | ||
|
||
Context 'When the current computer is a Datacenter Nano server' { | ||
Mock -CommandName Get-CimInstance ` | ||
-ModuleName $ProjectName ` | ||
-MockWith { | ||
[PSCustomObject] @{ | ||
OperatingSystemSKU = 143 | ||
} | ||
} | ||
|
||
It 'Should retrun true' { | ||
Test-IsNanoServer -Verbose | Should -BeTrue | ||
} | ||
} | ||
|
||
Context 'When the current computer is a Standard Nano server' { | ||
Mock -CommandName Get-CimInstance ` | ||
-ModuleName $ProjectName ` | ||
-MockWith { | ||
[PSCustomObject] @{ | ||
OperatingSystemSKU = 144 | ||
} | ||
} | ||
|
||
It 'Should retrun true' { | ||
Test-IsNanoServer -Verbose | Should -BeTrue | ||
} | ||
} | ||
|
||
Context 'When the current computer is not a Nano server' { | ||
Mock -CommandName Get-CimInstance ` | ||
-ModuleName $ProjectName ` | ||
-MockWith { | ||
[PSCustomObject] @{ | ||
OperatingSystemSKU = 1 | ||
} | ||
} | ||
|
||
It 'Should retrun false' { | ||
Test-IsNanoServer -Verbose | Should -BeFalse | ||
} | ||
} | ||
} |