Skip to content

Commit

Permalink
Merge pull request #2 from Dan1el42/dev
Browse files Browse the repository at this point in the history
Fix space indentation
  • Loading branch information
vors committed Apr 27, 2015
2 parents 13601a8 + f71b00c commit 5112ee4
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions Tests/MSFT_xIPAddress.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Remove-Module -Name MSFT_xIPAddress -Force -ErrorAction SilentlyContinue
Import-Module -Name $PSScriptRoot\..\DSCResources\MSFT_xIPAddress -Force -DisableNameChecking

InModuleScope MSFT_xIPAddress {

Describe 'Get-TargetResource' {

#region Mocks
Mock Get-NetIPAddress {

[PSCustomObject]@{
IPAddress = '192.168.0.1'
}
}
#endregion

Context 'comparing IPAddress' {
It 'should return true' {

$Splat = @{
IPAddress = '192.168.0.1'
InterfaceAlias = 'Ethernet'
}
$Result = Get-TargetResource @Splat
$Result.IPAddress | Should Be $Splat.IPAddress
}
}
}


Describe 'ValidateProperties' {

#region Mocks
Mock Get-NetIPAddress -MockWith {

[PSCustomObject]@{
IPAddress = '192.168.0.1'
InterfaceAlias = 'Ethernet'
}
}

Mock New-NetIPAddress -MockWith {}

Mock Get-NetConnectionProfile {
[PSCustomObject]@{
Name = 'MSFT'
InterfaceAlias = 'Ethernet'
InterfaceIndex = 1
NetworkCategory = 'Public'
IPV4Connectivity = 'Internet'
IPV6Connectivity = 'NoTraffic'
}
}

Mock Set-NetConnectionProfile {}
#endregion

Context 'invoking without -Apply switch' {

It 'should be $false' {
$Splat = @{
IPAddres = '10.0.0.2'
InterfaceAlias = 'Ethernet'
}
$Result = ValidateProperties @Splat
$Result | Should Be $false
}

It 'should be $true' {
$Splat = @{
IPAddres = '192.168.0.1'
InterfaceAlias = 'Ethernet'
}
$Result = ValidateProperties @Splat
$Result | Should Be $true
}
}

Context 'invoking with -Apply switch' {

It 'should be $null' {
$Splat = @{
IPAddres = '10.0.0.2'
InterfaceAlias = 'Ethernet'
}
$Result = ValidateProperties @Splat -Apply
$Result | Should BeNullOrEmpty
}
}
}
}

0 comments on commit 5112ee4

Please sign in to comment.