Skip to content

Commit

Permalink
Preserve trailing zeroes in entity tests (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmrdavid authored Nov 13, 2023
1 parent 738f5e4 commit b13778f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions test/Client/Core.Tests/Entities/EntityMetadataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.DurableTask.Entities;

namespace Microsoft.DurableTask.Client.Entities.Tests;
Expand Down Expand Up @@ -38,8 +39,9 @@ public void Serialize_StateNotIncluded()
LockedBy = lockedBy,
};

string nowStr = JsonSerializer.Serialize(now); // STJ drops trailing zeroes from dates. see: https://github.com/microsoft/durabletask-dotnet/pull/239
string json = JsonSerializer.Serialize(metadata);
json.Should().Be($"{{\"Id\":\"{this.id}\",\"LastModifiedTime\":\"{now:O}\",\"BacklogQueueSize\":10,\"LockedBy\""
json.Should().Be($"{{\"Id\":\"{this.id}\",\"LastModifiedTime\":{nowStr},\"BacklogQueueSize\":10,\"LockedBy\""
+ $":\"{lockedBy}\"}}");
}

Expand All @@ -56,8 +58,9 @@ public void Serialize_StateIncluded_Int()
LockedBy = lockedBy,
};

string nowStr = JsonSerializer.Serialize(now); // STJ drops trailing zeroes from dates. see: https://github.com/microsoft/durabletask-dotnet/pull/239
string json = JsonSerializer.Serialize(metadata);
json.Should().Be($"{{\"Id\":\"{this.id}\",\"LastModifiedTime\":\"{now:O}\",\"BacklogQueueSize\":10,\"LockedBy\""
json.Should().Be($"{{\"Id\":\"{this.id}\",\"LastModifiedTime\":{nowStr},\"BacklogQueueSize\":10,\"LockedBy\""
+ $":\"{lockedBy}\",\"State\":{state}}}");
}

Expand All @@ -74,8 +77,9 @@ public void Serialize_StateIncluded_Object()
LockedBy = lockedBy,
};

string nowStr = JsonSerializer.Serialize(now); // STJ drops trailing zeroes from dates. see: https://github.com/microsoft/durabletask-dotnet/pull/239
string json = JsonSerializer.Serialize(metadata);
json.Should().Be($"{{\"Id\":\"{this.id}\",\"LastModifiedTime\":\"{now:O}\",\"BacklogQueueSize\":10,\"LockedBy\""
json.Should().Be($"{{\"Id\":\"{this.id}\",\"LastModifiedTime\":{nowStr},\"BacklogQueueSize\":10,\"LockedBy\""
+ $":\"{lockedBy}\",\"State\":{{\"Number\":{state.Number}}}}}");
}

Expand All @@ -89,8 +93,9 @@ public void Serialize_StateIncluded_Object2()
LastModifiedTime = now,
};

string nowStr = JsonSerializer.Serialize(now); // STJ drops trailing zeroes from dates. see: https://github.com/microsoft/durabletask-dotnet/pull/239
string json = JsonSerializer.Serialize(metadata);
json.Should().Be($"{{\"Id\":\"{this.id}\",\"LastModifiedTime\":\"{now:O}\",\"State\":"
json.Should().Be($"{{\"Id\":\"{this.id}\",\"LastModifiedTime\":{nowStr},\"State\":"
+ $"{{\"Number\":{state.Number}}}}}");
}

Expand All @@ -104,8 +109,9 @@ public void Serialize_StateNotIncluded_NonGeneric()
LastModifiedTime = now,
};

string nowStr = JsonSerializer.Serialize(now); // STJ drops trailing zeroes from dates. see: https://github.com/microsoft/durabletask-dotnet/pull/239
string json = JsonSerializer.Serialize(metadata);
json.Should().Be($"{{\"Id\":\"{this.id}\",\"LastModifiedTime\":\"{now:O}\"}}");
json.Should().Be($"{{\"Id\":\"{this.id}\",\"LastModifiedTime\":{nowStr}}}");
}


Expand All @@ -119,8 +125,9 @@ public void Serialize_StateIncluded_NonGeneric()
LastModifiedTime = now,
};

string nowStr = JsonSerializer.Serialize(now); // STJ drops trailing zeroes from dates. see: https://github.com/microsoft/durabletask-dotnet/pull/239
string json = JsonSerializer.Serialize(metadata);
json.Should().Be($@"{{""Id"":""{this.id}"",""LastModifiedTime"":""{now:O}"",""State"":""{{\u0022Number\u0022:{state.Number}}}""}}");
json.Should().Be($@"{{""Id"":""{this.id}"",""LastModifiedTime"":{nowStr},""State"":""{{\u0022Number\u0022:{state.Number}}}""}}");
}

record class State(int Number)
Expand Down

0 comments on commit b13778f

Please sign in to comment.