Skip to content

Extending Assertions #1443

Answered by thomhurst
jesuslpm asked this question in Q&A
Dec 21, 2024 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Create an extension like this:

public static InvokableValueAssertionBuilder<RedisLockRecord> IsValid(this IValueSource<RedisLockRecord> valueSource, string resourceId, TimeSpan timeToLive, string lockedByDescription, [CallerArgumentExpression(nameof(resourceId))] string expression1 = "", [CallerArgumentExpression(nameof(timeToLive))] string expression2 = "", [CallerArgumentExpression(nameof(lockedByDescription))] string expression3 = "")
{
    return valueSource.RegisterAssertion(new RedisLockRecordValidAssertCondition(resourceId, timeToLive, lockedByDescription), [expression1, expression2, expression3]);
}

and create a class representing your assertion with the logic in it.

e.g.:

public c…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@jesuslpm
Comment options

@thomhurst
Comment options

@jesuslpm
Comment options

@thomhurst
Comment options

Answer selected by jesuslpm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants