From 420155517ad47d492cfbed5c040823e3b04ea981 Mon Sep 17 00:00:00 2001 From: "Jason Shirk (POWERSHELL)" Date: Tue, 2 Aug 2016 09:40:48 -0700 Subject: [PATCH] Add serialization test of SemanticVersion --- .../engine/SemanticVersion.Tests.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/powershell/engine/SemanticVersion.Tests.ps1 b/test/powershell/engine/SemanticVersion.Tests.ps1 index 734ad907a2..b8beeef77e 100644 --- a/test/powershell/engine/SemanticVersion.Tests.ps1 +++ b/test/powershell/engine/SemanticVersion.Tests.ps1 @@ -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 + } + } }