Skip to content

Commit

Permalink
Remove cast of associated store identifier values when serializing. A…
Browse files Browse the repository at this point in the history
…dd test condition.
  • Loading branch information
tomasmcguinness committed Mar 21, 2023
1 parent c118590 commit 40e9e95
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Passbook.Generator.Tests/GeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public void EnsurePassIsGeneratedCorrectly()
Row = 1
});

request.AssociatedStoreIdentifiers.Add(long.MaxValue);

using (MemoryStream ms = new MemoryStream())
{
using (StreamWriter sr = new StreamWriter(ms))
Expand Down Expand Up @@ -65,6 +67,10 @@ public void EnsurePassIsGeneratedCorrectly()
Assert.Equal("Test", (string)auxField["value"]);
Assert.Equal("Label", (string)auxField["label"]);
Assert.Equal(1, (int)auxField["row"]);

var associatedAppIdentifiersPayload = (JArray)json["associatedStoreIdentifiers"];
Assert.Single(associatedAppIdentifiersPayload);
Assert.Equal(long.MaxValue, associatedAppIdentifiersPayload[0]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Passbook.Generator/PassGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public byte[] Generate(IReadOnlyList<PassGeneratorRequest> generatorRequests)
throw new ArgumentNullException(nameof(generatorRequests), "You must pass an instance of IReadOnlyList containing at least one PassGeneratorRequest");
}

if (generatorRequests.Count() == 0)
if (!generatorRequests.Any())
{
throw new ArgumentException(nameof(generatorRequests), "The IReadOnlyList must contain at least one PassGeneratorRequest");
}
Expand Down
2 changes: 1 addition & 1 deletion Passbook.Generator/PassGeneratorRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ private void WriteStandardKeys(JsonWriter writer)
writer.WritePropertyName("associatedStoreIdentifiers");
writer.WriteStartArray();

foreach (int storeIdentifier in AssociatedStoreIdentifiers)
foreach (var storeIdentifier in AssociatedStoreIdentifiers)
{
writer.WriteValue(storeIdentifier);
}
Expand Down
2 changes: 1 addition & 1 deletion Passbook.Generator/Passbook.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>3.2.2.0</Version>
<Version>3.2.3.0</Version>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageId>dotnet-passbook</PackageId>
<Company>Tomas McGuinness</Company>
Expand Down

0 comments on commit 40e9e95

Please sign in to comment.