Skip to content

Commit

Permalink
Fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien Tschanz committed Oct 9, 2024
1 parent fa3ca35 commit 758a28b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ function Get-TargetResource
$instance = Get-MgBetaDeviceAppManagementMobileApp -MobileAppId $instance.Id `
-ExpandProperty "categories" `
-ErrorAction SilentlyContinue
$Id = $instance.Id
}
}

Expand Down Expand Up @@ -204,10 +205,13 @@ function Get-TargetResource
}

$complexMinimumSupportedOperatingSystem = @{}
$instance.AdditionalProperties.minimumSupportedOperatingSystem.GetEnumerator() | Foreach-Object {
if ($_.Value) # Values are either true or false. Only export the true value.
{
$complexMinimumSupportedOperatingSystem.Add($_.Key, $_.Value)
if ($null -ne $instance.AdditionalProperties.minimumSupportedOperatingSystem)
{
$instance.AdditionalProperties.minimumSupportedOperatingSystem.GetEnumerator() | Foreach-Object {
if ($_.Value) # Values are either true or false. Only export the true value.
{
$complexMinimumSupportedOperatingSystem.Add($_.Key, $_.Value)
}
}
}

Expand Down Expand Up @@ -480,7 +484,9 @@ function Set-TargetResource
$UpdateParameters.Add('@odata.type', '#microsoft.graph.macOSLobApp')
Update-MgBetaDeviceAppManagementMobileApp -MobileAppId $currentInstance.Id -BodyParameter $UpdateParameters

$delta = Compare-Object -ReferenceObject $currentInstance.Categories.DisplayName -DifferenceObject $Categories.DisplayName -PassThru
[array]$referenceObject = if ($null -ne $currentInstance.Categories.DisplayName) { $currentInstance.Categories.DisplayName } else { ,@() }
[array]$differenceObject = if ($null -ne $Categories.DisplayName) { $Categories.DisplayName } else { ,@() }
$delta = Compare-Object -ReferenceObject $referenceObject -DifferenceObject $differenceObject -PassThru
foreach ($diff in $delta)
{
if ($diff.SideIndicator -eq '=>')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
Mock -CommandName Confirm-M365DSCDependencies -MockWith {
}

Mock -CommandName Get-PSSession -MockWith {
}

Mock -CommandName Remove-PSSession -MockWith {
}

Mock -CommandName New-M365DSCConnection -MockWith {
return "Credentials"
}
Expand Down Expand Up @@ -59,11 +65,16 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
BeforeAll {
$testParams = @{
Id = "8d027f94-0682-431e-97c1-827d1879fa79"
Categories = @()
Description = "TeamsForBusinessInstaller"
Developer = "Contoso"
DisplayName = "TeamsForBusinessInstaller"
InformationUrl = ""
IsFeatured = $False
MinimumSupportedOperatingSystem = [CimInstance](
New-CimInstance -ClassName MSFT_DeviceManagementMinimumOperatingSystem -Property @{
v11_0 = $true
} -ClientOnly)
Notes = ""
Owner = ""
PrivacyInformationUrl = ""
Expand Down Expand Up @@ -94,25 +105,30 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
BeforeAll {
$testParams = @{
Id = "ad027f94-0682-431e-97c1-827d1879fa79"
Categories = @()
Description = "TeamsForBusinessInstaller"
Developer = "Contoso"
DisplayName = "TeamsForBusinessInstaller"
InformationUrl = ""
IsFeatured = $False
MinimumSupportedOperatingSystem = [CimInstance](
New-CimInstance -ClassName MSFT_DeviceManagementMinimumOperatingSystem -Property @{
v11_0 = $true
} -ClientOnly)
Notes = ""
Owner = ""
PrivacyInformationUrl = ""
Publisher = "Contoso"
RoleScopeTagIds = @()
IgnoreVersionDetection = $True

Ensure = 'Absent'
Credential = $Credential
}

Mock -CommandName Get-MgBetaDeviceAppManagementMobileApp -MockWith {
return @{
Id = "ad027f94-0682-431e-97c1-827d1879fa79"
Categories = @()
Description = "TeamsForBusinessInstaller"
Developer = "Contoso"
DisplayName = "TeamsForBusinessInstaller"
Expand All @@ -127,6 +143,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
IgnoreVersionDetection = $True
AdditionalProperties = @{
'@odata.type' = '#microsoft.graph.macOSLobApp'
minimumSupportedOperatingSystem = @{
v11_0 = $true
}
}
Ensure = 'Present'
}
Expand All @@ -153,11 +172,16 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
BeforeAll {
$testParams = @{
Id = "8d027f94-0682-431e-97c1-827d1879fa79"
Categories = @()
Description = "TeamsForBusinessInstaller"
Developer = "Contoso"
DisplayName = "TeamsForBusinessInstaller"
InformationUrl = ""
IsFeatured = $False
MinimumSupportedOperatingSystem = [CimInstance](
New-CimInstance -ClassName MSFT_DeviceManagementMinimumOperatingSystem -Property @{
v11_0 = $true
} -ClientOnly)
Notes = ""
Owner = ""
PrivacyInformationUrl = ""
Expand All @@ -170,6 +194,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
Mock -CommandName Get-MgBetaDeviceAppManagementMobileApp -MockWith {
return @{
Id = "8d027f94-0682-431e-97c1-827d1879fa79"
Categories = @()
Description = "TeamsForBusinessInstaller"
Developer = "Contoso"
DisplayName = "TeamsForBusinessInstaller"
Expand All @@ -183,6 +208,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
RoleScopeTagIds = @()
AdditionalProperties = @{
'@odata.type' = '#microsoft.graph.macOSLobApp'
minimumSupportedOperatingSystem = @{
v11_0 = $true
}
}
}
}
Expand All @@ -200,11 +228,16 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
BeforeAll {
$testParams = @{
Id = "8d027f94-0682-431e-97c1-827d1879fa79"
Categories = @()
Description = "TeamsForBusinessInstaller"
Developer = "Contoso"
DisplayName = "TeamsForBusinessInstaller"
InformationUrl = ""
IsFeatured = $False
MinimumSupportedOperatingSystem = [CimInstance](
New-CimInstance -ClassName MSFT_DeviceManagementMinimumOperatingSystem -Property @{
v11_0 = $true
} -ClientOnly)
Notes = ""
Owner = ""
PrivacyInformationUrl = ""
Expand All @@ -217,6 +250,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
Mock -CommandName Get-MgBetaDeviceAppManagementMobileApp -MockWith {
return @{
Id = "8d027f94-0682-431e-97c1-827d1879fa79"
Categories = @()
Description = "TeamsForBusinessInstaller"
Developer = "Contoso"
DisplayName = "TeamsForBusinessInstaller drift"
Expand All @@ -229,6 +263,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
PublishingState = "published"
AdditionalProperties = @{
'@odata.type' = '#microsoft.graph.macOSLobApp'
minimumSupportedOperatingSystem = @{
v11_0 = $true
}
}
}
}
Expand Down Expand Up @@ -260,6 +297,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
Mock -CommandName Get-MgBetaDeviceAppManagementMobileApp -MockWith {
return @{
Id = "8d027f94-0682-431e-97c1-827d1879fa79"
Categories = @()
Description = "TeamsForBusinessInstaller"
Developer = "Contoso"
DisplayName = "TeamsForBusinessInstaller drift"
Expand All @@ -273,6 +311,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
RoleScopeTagIds = @()
AdditionalProperties = @{
'@odata.type' = '#microsoft.graph.macOSLobApp'
minimumSupportedOperatingSystem = @{
v11_0 = $true
}
}
}
}
Expand Down

0 comments on commit 758a28b

Please sign in to comment.