atata-framework / atata

C#/.NET test automation framework for web
https://atata.io
Apache License 2.0
490 stars 80 forks source link

Add `ExecuteSectionAsync` methods to `ILogManager` #836

Closed YevgeniyShunevych closed 6 months ago

YevgeniyShunevych commented 6 months ago

In addition to ExecuteSection methods of ILogManager new async method versions are added:

Task ExecuteSectionAsync(LogSection section, Func<Task> function);

Task<TResult> ExecuteSectionAsync<TResult>(LogSection section, Func<Task<TResult>> function);

Usage

await AtataContext.Current.Log.ExecuteSectionAsync(
    new LogSection("Do some async work without result"),
    async () =>
    {
        //...
    });

var result = await AtataContext.Current.Log.ExecuteSectionAsync(
    new LogSection("Do some async work with result"),
    async () =>
    {
        return await SomeActionAsync();
    });