You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using data generated from this library to generate values for data models. In one particular instance, I'm generating data for an field (let's call it Updated) that must be greater than or equal to another field (let's call it Created). In that situation, I can use IComparableGenerator<T>.GreaterThanOrEqualTo(T other) to pass in the value for Created, and generate a value that is greater than or equal to it for Updated. However, if I want to generate a distinct value from the current one that ever fulfills this range requirement, I have to create a new generator for Updated that covers the range of greater than or equal to Created and then invoke IComparableGenerator<T>.NextDistinct(T other) to get the needed value.
Solution
Since IComparableGenerator<T> inherits from IDistinctGenerator<T>, we can fulfill this need by adding four methods to the IComparableGenerator<T> interface:
Given the above example, we would use NextDistinctGreaterThanOrEqualTo(), put the current value for Updated into distinctFrom and put the current value for Created into inclusiveLowerBound. That would give us a new value for Updated that still fulfilled its requirement to be greater than or equal to Created.
The text was updated successfully, but these errors were encountered:
Problem
I'm using data generated from this library to generate values for data models. In one particular instance, I'm generating data for an field (let's call it
Updated
) that must be greater than or equal to another field (let's call itCreated
). In that situation, I can useIComparableGenerator<T>.GreaterThanOrEqualTo(T other)
to pass in the value forCreated
, and generate a value that is greater than or equal to it forUpdated
. However, if I want to generate a distinct value from the current one that ever fulfills this range requirement, I have to create a new generator forUpdated
that covers the range of greater than or equal toCreated
and then invokeIComparableGenerator<T>.NextDistinct(T other)
to get the needed value.Solution
Since
IComparableGenerator<T>
inherits fromIDistinctGenerator<T>
, we can fulfill this need by adding four methods to theIComparableGenerator<T>
interface:Given the above example, we would use
NextDistinctGreaterThanOrEqualTo()
, put the current value forUpdated
intodistinctFrom
and put the current value forCreated
intoinclusiveLowerBound
. That would give us a new value forUpdated
that still fulfilled its requirement to be greater than or equal toCreated
.The text was updated successfully, but these errors were encountered: