From c8cbd28274a0312f393a84b2edb55deee897b333 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Fri, 21 Jun 2024 14:54:46 +0200 Subject: [PATCH] Add IdentityEquals for ValidationPackage (client) --- src/AVPRClient/AVPRClient.csproj | 2 +- src/AVPRClient/Extensions.cs | 12 +++++++++++ src/AVPRClient/RELEASE_NOTES.md | 3 +++ tests/ClientTests/TypeExtensionsTests.fs | 26 ++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/AVPRClient/AVPRClient.csproj b/src/AVPRClient/AVPRClient.csproj index 5d09d2d..67924c5 100644 --- a/src/AVPRClient/AVPRClient.csproj +++ b/src/AVPRClient/AVPRClient.csproj @@ -22,7 +22,7 @@ git $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/RELEASE_NOTES.md")) README.md - 0.1.0 + 0.1.1 diff --git a/src/AVPRClient/Extensions.cs b/src/AVPRClient/Extensions.cs index e8a1b03..7cbc617 100644 --- a/src/AVPRClient/Extensions.cs +++ b/src/AVPRClient/Extensions.cs @@ -13,6 +13,18 @@ namespace AVPRClient { public static class Extensions { + public static bool IdentityEquals( + this AVPRClient.ValidationPackage package, + AVPRClient.ValidationPackage other + ) + { + return package.Name == other.Name + && package.MajorVersion == other.MajorVersion + && package.MinorVersion == other.MinorVersion + && package.PatchVersion == other.PatchVersion + && package.PreReleaseVersionSuffix == other.PreReleaseVersionSuffix + && package.BuildMetadataVersionSuffix == other.BuildMetadataVersionSuffix; + } public static AVPRClient.ValidationPackage toValidationPackage( this AVPRIndex.Domain.ValidationPackageIndex indexedPackage, DateTimeOffset releaseDate diff --git a/src/AVPRClient/RELEASE_NOTES.md b/src/AVPRClient/RELEASE_NOTES.md index 19ceb23..7e86d96 100644 --- a/src/AVPRClient/RELEASE_NOTES.md +++ b/src/AVPRClient/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +## v0.1.1 +- Add `IdentityEquals` extension method for `ValidationPackage` + ## v0.1.0 - Regen client for full semVer support (AVPRIndex >= 0.2.0) diff --git a/tests/ClientTests/TypeExtensionsTests.fs b/tests/ClientTests/TypeExtensionsTests.fs index 7f1bd44..10d0e2e 100644 --- a/tests/ClientTests/TypeExtensionsTests.fs +++ b/tests/ClientTests/TypeExtensionsTests.fs @@ -8,6 +8,32 @@ open AVPRClient open System.Security.Cryptography +module ValidationPackage = + + [] + let ``IdentityEquals returns true for the same package without suffixes`` () = + Assert.True( + ReferenceObjects.ValidationPackage.allFields_cqcHookAddition.IdentityEquals( + ReferenceObjects.ValidationPackage.allFields_cqcHookAddition + ) + ) + + [] + let ``IdentityEquals returns true for the same package with suffixes`` () = + Assert.True( + ReferenceObjects.ValidationPackage.allFields_semVerAddition.IdentityEquals( + ReferenceObjects.ValidationPackage.allFields_semVerAddition + ) + ) + + [] + let ``IdentityEquals returns false for the different packages`` () = + Assert.False( + ReferenceObjects.ValidationPackage.allFields_cqcHookAddition.IdentityEquals( + ReferenceObjects.ValidationPackage.allFields_semVerAddition + ) + ) + module ValidationPackageIndex = let allFields_cqcHookAddition = AVPRIndex.Domain.ValidationPackageIndex.create(