mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Add serialization test of SemanticVersion
This commit is contained in:
@@ -184,4 +184,22 @@ Describe "SemanticVersion api tests" -Tags 'CI' {
|
||||
{ [SemanticVersion]::new([Version]::new("1.2")) } | Should Throw # PSArgumentException
|
||||
}
|
||||
}
|
||||
|
||||
Context "Serialization" {
|
||||
$testCases = @(
|
||||
@{ expectedResult = "1.0.0"; semver = [SemanticVersion]::new(1, 0, 0) }
|
||||
@{ expectedResult = "1.0.1"; semver = [SemanticVersion]::new(1, 0, 1) }
|
||||
@{ expectedResult = "1.0.0-alpha"; semver = [SemanticVersion]::new(1, 0, 0, "alpha") }
|
||||
@{ expectedResult = "1.0.0-beta"; semver = [SemanticVersion]::new(1, 0, 0, "beta") }
|
||||
)
|
||||
It "Can round trip" -TestCases $testCases {
|
||||
param($semver, $expectedResult)
|
||||
|
||||
$ser = [PSSerializer]::Serialize($semver)
|
||||
$des = [PSSerializer]::Deserialize($ser)
|
||||
|
||||
$des | Should BeOfType System.Management.Automation.SemanticVersion
|
||||
$des.ToString() | Should Be $expectedResult
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user