From 0a561ad2574e31e2a93d3045758acba51dfd4e73 Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Thu, 28 Mar 2024 06:06:16 +0700 Subject: [PATCH] Remove storage from Allure.Net.Commons --- Allure.Net.Commons/AllureLifecycle.cs | 7 ----- Allure.Net.Commons/Storage/AllureStorage.cs | 27 ------------------- .../Storage/ITestResultAccessor.cs | 8 ------ Allure.XUnit/AllureXunitHelper.cs | 7 ++++- 4 files changed, 6 insertions(+), 43 deletions(-) delete mode 100644 Allure.Net.Commons/Storage/AllureStorage.cs delete mode 100644 Allure.Net.Commons/Storage/ITestResultAccessor.cs diff --git a/Allure.Net.Commons/AllureLifecycle.cs b/Allure.Net.Commons/AllureLifecycle.cs index ab32247f..2ab3eeb0 100644 --- a/Allure.Net.Commons/AllureLifecycle.cs +++ b/Allure.Net.Commons/AllureLifecycle.cs @@ -5,7 +5,6 @@ using System.Threading; using Allure.Net.Commons.Configuration; using Allure.Net.Commons.Functions; -using Allure.Net.Commons.Storage; using Allure.Net.Commons.TestPlan; using Allure.Net.Commons.Writer; using Newtonsoft.Json.Linq; @@ -39,7 +38,6 @@ public class AllureLifecycle public IReadOnlyDictionary TypeFormatters => new ReadOnlyDictionary(typeFormatters); - readonly AllureStorage storage; readonly AsyncLocal context = new(); readonly Lazy lazyTestPlan; @@ -102,7 +100,6 @@ Func testPlanFactory JsonConfiguration = config.ToString(); AllureConfiguration = AllureConfiguration.ReadFromJObject(config); writer = writerFactory(AllureConfiguration); - storage = new AllureStorage(); lazyTestPlan = new(testPlanFactory); } @@ -216,7 +213,6 @@ TestResultContainer container ) { container.start = DateTimeOffset.Now.ToUnixTimeMilliseconds(); - this.storage.Put(container.uuid, container); this.UpdateContext(c => c.WithContainer(container)); return this; } @@ -267,7 +263,6 @@ public virtual AllureLifecycle StopTestContainer() public virtual AllureLifecycle WriteTestContainer() { var container = this.Context.CurrentContainer; - this.storage.Remove(container.uuid); this.UpdateContext(c => c.WithNoLastContainer()); this.writer.Write(container); return this; @@ -393,7 +388,6 @@ public virtual AllureLifecycle ScheduleTestCase(TestResult testResult) container.children.Add(uuid); } } - this.storage.Put(uuid, testResult); this.UpdateContext(c => c.WithTestContext(testResult)); return this; } @@ -485,7 +479,6 @@ public virtual AllureLifecycle WriteTestCase() { uuid = testResult.uuid; } - this.storage.Remove(uuid); this.UpdateContext(c => c.WithNoTestContext()); this.writer.Write(testResult); return this; diff --git a/Allure.Net.Commons/Storage/AllureStorage.cs b/Allure.Net.Commons/Storage/AllureStorage.cs deleted file mode 100644 index 8ff9a727..00000000 --- a/Allure.Net.Commons/Storage/AllureStorage.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Concurrent; - -#nullable enable - -namespace Allure.Net.Commons.Storage -{ - internal class AllureStorage - { - readonly ConcurrentDictionary storage = new(); - - public T Get(string uuid) - { - return (T)storage[uuid]; - } - - public T Put(string uuid, T item) where T : notnull - { - return (T)storage.GetOrAdd(uuid, item); - } - - public T Remove(string uuid) - { - storage.TryRemove(uuid, out var value); - return (T)value; - } - } -} \ No newline at end of file diff --git a/Allure.Net.Commons/Storage/ITestResultAccessor.cs b/Allure.Net.Commons/Storage/ITestResultAccessor.cs deleted file mode 100644 index 8c2eb4a7..00000000 --- a/Allure.Net.Commons/Storage/ITestResultAccessor.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Allure.Net.Commons.Storage -{ - public interface ITestResultAccessor - { - TestResultContainer TestResultContainer { get; set; } - TestResult TestResult { get; set; } - } -} \ No newline at end of file diff --git a/Allure.XUnit/AllureXunitHelper.cs b/Allure.XUnit/AllureXunitHelper.cs index 45d86688..5bf99b3f 100644 --- a/Allure.XUnit/AllureXunitHelper.cs +++ b/Allure.XUnit/AllureXunitHelper.cs @@ -1,6 +1,5 @@ using Allure.Net.Commons; using Allure.Net.Commons.Functions; -using Allure.Net.Commons.Storage; using Allure.Xunit.Attributes; using Allure.XUnit; using Allure.XUnit.Attributes; @@ -19,6 +18,12 @@ namespace Allure.Xunit { public static class AllureXunitHelper { + internal interface ITestResultAccessor + { + TestResultContainer TestResultContainer { get; set; } + TestResult TestResult { get; set; } + } + internal static List ExceptionTypes = new() { typeof(XunitException)