mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Add serialization test of SemanticVersion
This commit is contained in:
1 parent
2b70837d98
commit
420155517a
1 file changed
+18
@@ -184,4 +184,22 @@ Describe "SemanticVersion api tests" -Tags 'CI' {
|
|||||||
{ [SemanticVersion]::new([Version]::new("1.2")) } | Should Throw # PSArgumentException
|
{ [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