From f7404064be9c53fb216d80156b41860f656f136c Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Tue, 3 Dec 2019 08:43:09 +0100 Subject: [PATCH] AB3980 Cleanup tests --- src/Umbraco.Tests/Scoping/ScopeTests.cs | 55 ++++++++++--------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/src/Umbraco.Tests/Scoping/ScopeTests.cs b/src/Umbraco.Tests/Scoping/ScopeTests.cs index a4a9d32084..b2a3b14800 100644 --- a/src/Umbraco.Tests/Scoping/ScopeTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopeTests.cs @@ -428,46 +428,33 @@ namespace Umbraco.Tests.Scoping var scopeProvider = ScopeProvider; Assert.IsNull(scopeProvider.AmbientScope); - var httpContextItems = new Hashtable(); - // ScopeProviderStatic.HttpContextItemsGetter = () => httpContextItems; - try + using (var scope = scopeProvider.CreateScope()) { - using (var scope = scopeProvider.CreateScope()) + Assert.IsNotNull(scopeProvider.AmbientScope); + Assert.IsNotNull(scopeProvider.AmbientContext); + using (new SafeCallContext()) { - Assert.IsNotNull(scopeProvider.AmbientScope); - Assert.IsNotNull(scopeProvider.AmbientContext); - using (new SafeCallContext()) + Assert.IsNull(scopeProvider.AmbientScope); + Assert.IsNull(scopeProvider.AmbientContext); + + using (var newScope = scopeProvider.CreateScope()) { - // pretend it's another thread - // ScopeProviderStatic.HttpContextItemsGetter = null; - - Assert.IsNull(scopeProvider.AmbientScope); - Assert.IsNull(scopeProvider.AmbientContext); - - using (var newScope = scopeProvider.CreateScope()) - { - Assert.IsNotNull(scopeProvider.AmbientScope); - Assert.IsNull(scopeProvider.AmbientScope.ParentScope); - Assert.IsNotNull(scopeProvider.AmbientContext); - } - - Assert.IsNull(scopeProvider.AmbientScope); - Assert.IsNull(scopeProvider.AmbientContext); - - // back to original thread - // ScopeProviderStatic.HttpContextItemsGetter = () => httpContextItems; + Assert.IsNotNull(scopeProvider.AmbientScope); + Assert.IsNull(scopeProvider.AmbientScope.ParentScope); + Assert.IsNotNull(scopeProvider.AmbientContext); } - Assert.IsNotNull(scopeProvider.AmbientScope); - Assert.AreSame(scope, scopeProvider.AmbientScope); - } - Assert.IsNull(scopeProvider.AmbientScope); - Assert.IsNull(scopeProvider.AmbientContext); - } - finally - { - // ScopeProviderStatic.HttpContextItemsGetter = null; + Assert.IsNull(scopeProvider.AmbientScope); + Assert.IsNull(scopeProvider.AmbientContext); + } + Assert.IsNotNull(scopeProvider.AmbientScope); + Assert.AreSame(scope, scopeProvider.AmbientScope); } + + Assert.IsNull(scopeProvider.AmbientScope); + Assert.IsNull(scopeProvider.AmbientContext); + + } [Test]