"Wait" implementation. Allows to process given condition until timeout is reached. Overall timeout and polling interval are configurable. Appearing exceptions can be ignored so processing of condition continues.
- Install via NuGet package Tiver.Fowl.Waiting
Can be configured via Tiver_config.json
file in following way:
{
"Tiver.Fowl.Waiting": {
"Timeout": 1000,
"PollingInterval": 250
}
}
Full configuration can look like following:
{
"Tiver.Fowl.Waiting": {
"Timeout": 5000,
"PollingInterval": 250,
"ExtendOnTimeout": true,
"ExtendedTimeout": 15000,
"IgnoredExceptionsTypeNames": [
"System.ArgumentException",
"NUnit.Framework.AssertionException, NUnit.Framework"
]
}
}
Produces debug log. Uses Microsoft.Extensions.Logging.Abstractions
Logger instance can be configured using static method: Wait.SetLogger(loggerInstance)
Throws Tiver.Fowl.Waiting.Exceptions.WaitTimeoutException
on timeout
You can ignore exceptions during Wait
// Following code throws System.DivideByZeroException
var zero = 0;
var wait = Wait.Until(() => 2 / zero);
// Following code continue execution before timeout occurs
var zero = 0;
var wait = Wait.Until(() => 2 / zero, new WaitConfiguration(typeof(DivideByZeroException)));
Simple Wait (use Tiver_config.json
values or defaults)
var result = Wait.Until(() => 2 + 2);
Assert.AreEqual(4, result);
Simple Wait with specific config
var config = new WaitConfiguration(1000, 250);
var result = Wait.Until(() => 2 + 2, config);
Assert.AreEqual(4, result);
Extensible Wait
var config = new WaitConfiguration(1000, 250, 5000);
var result = Wait.Until(() => 2 + 2, config);
Assert.AreEqual(4, result);
Custom exit condition (Default one - result is not null)
var counter = 0;
var result = Wait.Until(() => counter += 1, result => result == 10);
Assert.AreEqual(10, result);