Skip to content

Commit 31871f1

Browse files
authored
Fix Enum type checking (#25)
1 parent 518191d commit 31871f1

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## [Unreleased]
77

8+
### Changed
9+
10+
- `Clear-ZeroedEnumPropertyValue`
11+
- Fixed enum type check.
12+
813
## [1.2.0] - 2025-02-02
914

1015
### Added

source/Private/Clear-ZeroedEnumPropertyValue.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function Clear-ZeroedEnumPropertyValue
3434
foreach ($property in $InputObject.Keys)
3535
{
3636
$value = $InputObject.$property
37-
if ($value.IsEnum -and [System.Int32]$value.value__ -eq 0)
37+
if ($value -is [System.Enum] -and [System.Int32]$value.value__ -eq 0)
3838
{
3939
continue
4040
}

tests/Unit/Private/Clear-ZeroedEnumPropertyValue.Tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ Describe 'Clear-ZeroedEnumPropertyValue' -Tag 'Private' {
104104
Variable3 = $true
105105
Variable4 = New-TimeSpan -Days 8
106106
Variable5 = [MyMockEnum]::Value1
107-
Variable6 = [MyMockEnum]
107+
Variable6 = [MyMockEnum]::new()
108108
Variable7 = [MyMockEnum]::Value3
109-
Variable8 = [MyMockEnum]
109+
Variable8 = [MyMockEnum]::new()
110110
}
111111

112112
$result = Clear-ZeroedEnumPropertyValue -InputObject $testParams
@@ -136,9 +136,9 @@ Describe 'Clear-ZeroedEnumPropertyValue' -Tag 'Private' {
136136
Variable3 = $true
137137
Variable4 = New-TimeSpan -Days 8
138138
Variable5 = [MyMockEnum]::Value1
139-
Variable6 = [MyMockEnum]
139+
Variable6 = [MyMockEnum]::new()
140140
Variable7 = [MyMockEnum]::Value3
141-
Variable8 = [MyMockEnum]
141+
Variable8 = [MyMockEnum]::new()
142142
}
143143

144144
$result = $testParams | Clear-ZeroedEnumPropertyValue

0 commit comments

Comments
 (0)