Improve tests

This commit is contained in:
Tyrrrz
2021-07-19 20:19:32 +03:00
parent 85d53d0e94
commit d735d2acd3
3 changed files with 121 additions and 64 deletions

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace DiscordChatExporter.Cli.Tests.Utils
{
internal static class GlobalCache
{
private static readonly Dictionary<string, object?> Dictionary = new();
public static async Task<T> WrapAsync<T>(string key, Func<Task<T>> getAsync)
{
if (Dictionary.TryGetValue(key, out var value) && value is T existing)
return existing;
var result = await getAsync();
Dictionary[key] = result;
return result;
}
}
}