Skip to content

Commit

Permalink
Add IdentityEquals for ValidationPackage (client)
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Jun 21, 2024
1 parent 5827c25 commit c8cbd28
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/AVPRClient/AVPRClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/RELEASE_NOTES.md"))</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageVersion>0.1.0</PackageVersion>
<PackageVersion>0.1.1</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions src/AVPRClient/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/AVPRClient/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
26 changes: 26 additions & 0 deletions tests/ClientTests/TypeExtensionsTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,32 @@ open AVPRClient

open System.Security.Cryptography

module ValidationPackage =

[<Fact>]
let ``IdentityEquals returns true for the same package without suffixes`` () =
Assert.True(
ReferenceObjects.ValidationPackage.allFields_cqcHookAddition.IdentityEquals(
ReferenceObjects.ValidationPackage.allFields_cqcHookAddition
)
)

[<Fact>]
let ``IdentityEquals returns true for the same package with suffixes`` () =
Assert.True(
ReferenceObjects.ValidationPackage.allFields_semVerAddition.IdentityEquals(
ReferenceObjects.ValidationPackage.allFields_semVerAddition
)
)

[<Fact>]
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(
Expand Down

0 comments on commit c8cbd28

Please sign in to comment.