C
C#2y ago
camel

❔ FluentAssertions excluding collection elements

I have two IEnumerable<Claim> tmp1, tmp2 and I want to see if they are equal, except for the claims "exp", "nbf", "iat" because those are timestamps and dependent on the execution time. How can I solve this without having to mock every single thing that gives a time?
tmp1.Should().BeEquivalentTo(tmp2, options =>
{
options.Excluding(x => x.Type == JwtRegisteredClaimNames.Exp);
options.Excluding(x => x.Type == JwtRegisteredClaimNames.Iat);
options.Excluding(x => x.Type == JwtRegisteredClaimNames.Nbf);
return options;
});
tmp1.Should().BeEquivalentTo(tmp2, options =>
{
options.Excluding(x => x.Type == JwtRegisteredClaimNames.Exp);
options.Excluding(x => x.Type == JwtRegisteredClaimNames.Iat);
options.Excluding(x => x.Type == JwtRegisteredClaimNames.Nbf);
return options;
});
3 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
camel
camelOP2y ago
alright that will do thanks!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server