-
Notifications
You must be signed in to change notification settings - Fork 64
/
AllureStorage.cs
65 lines (53 loc) · 1.57 KB
/
AllureStorage.cs
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace Allure.Net.Commons.Storage
{
internal class AllureStorage
{
private readonly ConcurrentDictionary<string, LinkedList<string>> stepContext = new();
private readonly ConcurrentDictionary<string, object> storage = new();
private LinkedList<string> Steps => stepContext.GetOrAdd(
AllureLifecycle.CurrentTestIdGetter(),
new LinkedList<string>()
);
public T Get<T>(string uuid)
{
return (T) storage[uuid];
}
public T Put<T>(string uuid, T item)
{
return (T) storage.GetOrAdd(uuid, item);
}
public T Remove<T>(string uuid)
{
storage.TryRemove(uuid, out var value);
return (T) value;
}
public void ClearStepContext()
{
Steps.Clear();
stepContext.TryRemove(AllureLifecycle.CurrentTestIdGetter(), out _);
}
public void StartStep(string uuid)
{
Steps.AddFirst(uuid);
}
public void StopStep()
{
Steps.RemoveFirst();
}
public string GetRootStep()
{
return Steps.Last?.Value;
}
public string GetCurrentStep()
{
return Steps.First?.Value;
}
public void AddStep(string parentUuid, string uuid, StepResult stepResult)
{
Put(uuid, stepResult);
Get<ExecutableItem>(parentUuid).steps.Add(stepResult);
}
}
}