DateOnly CreateDateOnlyFromISO8601_String(string ISO8601_String)
string ToISO8601_String()
DateOnly CreateDateOnlyFromISO8601_String(string ISO8601_String)
string ToISO8601_String()
Name | VALID_PATTERN |
Type | Regex |
Is readonly | Yes |
Contains the regular expression of the valid email address according w3resource.com.
bool IsValid(string potentialEmail)
TElement[] LogEachElement<TElement>(Action<TElement>? logger = null)
Dictionary<TKey, TValue> SetPairIfValueNotIsNull<TKey, TValue>
SetPairIf
Dictionary<TKey, TValue> SetPairIf<TKey, TValue>(TKey key, TValue value, bool condition) where TKey : notnull
Dictionary<TKey, TValue> SetPairIf<TKey, TValue>(TKey key, TValue value, Func<TKey, TValue, bool> condition) where TKey : notnull
List<TElement> AddElementsToStart<TElement> (params TElement[] newElements)
List<TElement> AddElementsToEnd<TElement> (params TElement[] newElements)
List<TElement?> AddElementToEndIfNotNull<TElement>(TElement? newElement)
AddElementToEndIf
List<TElement> AddElementToEndIf<TElement>(TElement newElement, bool condition)
List<TElement> AddElementToEndIf<TElement>(TElement newElement, Func<TElement?, bool> condition)
StringifyEachElementAndJoin<TElement>(string separator)
ReplaceArrayElementsByPredicate
List<TElement> ReplaceArrayElementsByPredicate<TElement>(Func<TElement, bool> predicate, TElement newElement, bool mustReplaceOnlyFirstOne)
List<TElement> ReplaceArrayElementsByPredicate<TElement>(Func<TElement, bool> predicate, Func<TElement, TElement> replacer, bool mustReplaceOnlyFirstOne)
List<TElement> LogEachElement<TElement>(Action<TElement>? logger = null)
bool IsValueOfAnyNumericType(object value)
bool IsNonEmpty()
string ToUpperCamelCase()
string ToLowerCamelCase()
string RemoveAllSpecifiedCharacters(char[] charactersToRemove)
bool GetRandomBoolean()
byte GetRandomByte(byte minimalValue = Byte.MinValue, byte maximalValue = Byte.MaxValue)
ushort GetRandomUShort(ushort minimalValue = ushort.MinValue, ushort maximalValue = ushort.MaxValue)
TArrayElement GetRandomArrayElement<TArrayElement>(TArrayElement[] targetArray)
DateOnly GetRandomDate(DateOnly earliestDate, DateOnly latestDate)
DateTime GetRandomDateTime(DateOnly earliestDate, DateOnly latestDate)
Enumeration element | Description |
---|---|
mustGenerateAll |
All nullable (optional) properties must be generated except the cases of incompatible properties. |
mustGenerateWith50PercentageProbabilityIfHasNotBeenPreDefined |
Nullable (optional) properties must be generated with 50% probability. |
mustSkipIfHasNotBeenPreDefined |
Nullable (optional) properties must not be randomly generated. |
TValueType? DecideOptionalValue<TValueType>(NullablePropertiesDecisionSourceDataAndOptions<TValueType> sourceDataAndOptions)
struct NullablePropertiesDecisionSourceDataAndOptions<TPropertyType>
{
public required NullablePropertiesDecisionStrategies Strategy { get; init; }
public required Func<TPropertyType> RandomValueGenerator? { get; init; }
public TPropertyType? PreDefinedValue { get; init; }
}
Decides, will nullable (optional) value be available or no, and if yes, returns this value. Intended to be used when generating the properties for the class / structure.
The decision will depend mainly on specified nullable property decision strategy:
Enumeration element | Description |
---|---|
mustGenerateAll |
If target nullable property has not been predefined via NullablePropertiesDecisionStrategies.PreDefinedValue , it will be generated by specified RandomValueGenerator . It means the RandomValueGenerator must be specified for this strategy, otherwise ArgumentException will be thrown. |
mustGenerateWith50PercentageProbabilityIfHasNotBeenPreDefined |
If target nullable property has been predefined via NullablePropertiesDecisionStrategies.PreDefinedValue , this value will be returned otherwise will be generated by specified RandomValueGenerator with probability 50%. It means the RandomValueGenerator must be specified for this strategy, otherwise ArgumentException will be thrown. |
mustSkipIfHasNotBeenPreDefined |
If target nullable property has not been predefined via NullablePropertiesDecisionStrategies.PreDefinedValue , no random value will be generated. Only for the strategy RandomValueGenerator should be omitted. |
Error class | Usage |
---|---|
DataRetrievingFailedException |
Intended to be used when the data retrieving from some external resource (server, database, file, etc.) failed. |
DataSubmittingFailedException |
Intended to be used when the data submitting to any external resource (server, database, etc.) failed. |
When mock the asynchronous data transactions, takes care about such routines as
- Randomizing of the pending interval
- Simulation of the error
- Logging
void SetLogger(Log log)
delegate void Log(string message)
Adds the logging method which will be invoked if the logging will be demanded in other methods.
Task<TResponseData> SimulateDataRetrieving<TRequestParameters, TResponseData>(
TRequestParameters requestParameters,
Func<TResponseData> getResponseData,
SimulationOptions options
)
where the SimulationOptions
is the associated structure will be described below.
Task<TResponseData> SimulateDataSubmitting<TRequestData, TResponseData>(
TRequestData requestData,
Func<TResponseData> getResponseData,
SimulationOptions options
)
It's behaviour is almost even with SimulateDataRetrieving
, but there are some differences:
- The logging
DataSubmittingFailedException
will be thrown instead ofDataRetrievingFailedException
when error simulation mode is enabled.
public struct SimulationOptions
{
public ushort? MinimalPendingPeriod__Seconds { get; init; }
public ushort? MaximalPendingPeriod__Seconds { get; init; }
public bool MustSimulateError { get; init; }
public bool MustLogResponseData { get; init; }
public required string GatewayName { get; init; }
public required string TransactionName { get; init; }
}
Type | ushort |
Default value | 1 |
Use case | If you want to see the loading placeholder for a while, increase this value. |
Type | ushort |
Default value | 2 |
Use case | If you want to see the loading placeholder for a while, increase this value. |
Type | bool |
Default value | false |
Use case | If you want to check is the error message displays correctly in your GUI, set this flag to true . |
Type | bool |
Is required | Yes |
Type | bool |
Is required | Yes |
Note | System.Text.Json.JsonSerializer will be used for serializing. |
Type | bool |
Is required | Yes |
Note | Used for logging only. "Gateway" could be called "service" or somehow else in your code. |
Type | bool |
Is required | Yes |
Note | Used for logging only. |