-
-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathTestDataContainer.cs
More file actions
32 lines (26 loc) · 1.11 KB
/
Copy pathTestDataContainer.cs
File metadata and controls
32 lines (26 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Reflection;
using TUnit.Core.Data;
namespace TUnit.Core;
internal static class TestDataContainer
{
private static readonly ScopedDictionary<string> _globalContainer = new();
private static readonly ScopedDictionary<Type> _classContainer = new();
private static readonly ScopedDictionary<Assembly> _assemblyContainer = new();
private static readonly ScopedDictionary<string> _keyContainer = new();
public static object? GetInstanceForClass(Type testClass, Type type, Func<Type, object> func)
{
return _classContainer.GetOrCreate(testClass, type, func);
}
public static object? GetInstanceForAssembly(Assembly assembly, Type type, Func<Type, object> func)
{
return _assemblyContainer.GetOrCreate(assembly, type, func);
}
public static object? GetGlobalInstance(Type type, Func<Type, object> func)
{
return _globalContainer.GetOrCreate(typeof(object).FullName!, type, func);
}
public static object? GetInstanceForKey(string key, Type type, Func<Type, object> func)
{
return _keyContainer.GetOrCreate(key, type, func);
}
}