From 46c073aaf6dc97dd5a6965935ee43ef16cbbc8be Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 3 Mar 2021 14:12:14 +1100 Subject: [PATCH] removes CallContextTests --- .../Scoping/ScopeFileSystemsTests.cs | 6 +- .../Scoping/ScopeTests.cs | 4 +- .../CoreThings/CallContextTests.cs | 75 ------------------- 3 files changed, 5 insertions(+), 80 deletions(-) delete mode 100644 src/Umbraco.Tests.UnitTests/Umbraco.Core/CoreThings/CallContextTests.cs diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Scoping/ScopeFileSystemsTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Scoping/ScopeFileSystemsTests.cs index c95417bb2b..f96852faeb 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Scoping/ScopeFileSystemsTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Scoping/ScopeFileSystemsTests.cs @@ -127,7 +127,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Scoping Assert.IsFalse(physMediaFileSystem.FileExists("f1.txt")); // execute on another disconnected thread (execution context will not flow) - Task t = taskHelper.RunBackgroundTask(() => + Task t = taskHelper.ExecuteBackgroundTask(() => { Assert.IsFalse(mediaFileSystem.FileExists("f1.txt")); @@ -159,7 +159,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Scoping { // This is testing when another thread concurrently tries to create a scoped file system // because at the moment we don't support concurrent scoped filesystems. - Task t = taskHelper.RunBackgroundTask(() => + Task t = taskHelper.ExecuteBackgroundTask(() => { // ok to create a 'normal' other scope using (IScope other = scopeProvider.CreateScope()) @@ -194,7 +194,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Scoping { // This is testing when another thread concurrently tries to create a scoped file system // because at the moment we don't support concurrent scoped filesystems. - Task t = taskHelper.RunBackgroundTask(() => + Task t = taskHelper.ExecuteBackgroundTask(() => { // not ok to create a 'scoped filesystems' other scope // because at the moment we don't support concurrent scoped filesystems diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Scoping/ScopeTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Scoping/ScopeTests.cs index 9aaea4b8cc..f8b9a35c5b 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Scoping/ScopeTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Scoping/ScopeTests.cs @@ -449,7 +449,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Scoping Assert.IsNotNull(scopeProvider.AmbientContext); // Run on another thread without a flowed context - Task t = taskHelper.RunBackgroundTask(() => + Task t = taskHelper.ExecuteBackgroundTask(() => { Assert.IsNull(scopeProvider.AmbientScope); Assert.IsNull(scopeProvider.AmbientContext); @@ -490,7 +490,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Scoping Assert.IsNotNull(scopeProvider.AmbientContext); // Run on another thread without a flowed context - Task t = taskHelper.RunBackgroundTask(() => + Task t = taskHelper.ExecuteBackgroundTask(() => { Assert.IsNull(scopeProvider.AmbientScope); Assert.IsNull(scopeProvider.AmbientContext); diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/CoreThings/CallContextTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/CoreThings/CallContextTests.cs deleted file mode 100644 index ac54e72cce..0000000000 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/CoreThings/CallContextTests.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Umbraco. -// See LICENSE for more details. - -using NUnit.Framework; -using Umbraco.Cms.Core; -using Umbraco.Cms.Core.Scoping; - -namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.CoreThings -{ - [TestFixture] - public class CallContextTests - { - private static bool s_first; - - static CallContextTests() => SafeCallContext.Register( - () => - { - CallContext.SetData("test1", null); - CallContext.SetData("test2", null); - return null; - }, o => { }); - - [OneTimeSetUp] - public void SetUpFixture() => s_first = true; - - // logical call context leaks between tests - // is is required to clear it before tests begin - // (don't trust other tests properly tearing down) - [SetUp] - public void Setup() => SafeCallContext.Clear(); - - [TearDown] - public void TearDown() => SafeCallContext.Clear(); - - [Test] - public void Test1() - { - CallContext.SetData("test1", "test1"); - Assert.IsNull(CallContext.GetData("test2")); - - CallContext.SetData("test3b", "test3b"); - - if (s_first) - { - s_first = false; - } - else - { - Assert.IsNotNull(CallContext.GetData("test3a")); // leak! - } - } - - [Test] - public void Test2() - { - CallContext.SetData("test2", "test2"); - Assert.IsNull(CallContext.GetData("test1")); - } - - [Test] - public void Test3() - { - CallContext.SetData("test3a", "test3a"); - - if (s_first) - { - s_first = false; - } - else - { - Assert.IsNotNull(CallContext.GetData("test3b")); // leak! - } - } - } -}