Skip to content

Commit 98dd152

Browse files
authored
Revert "[#255] changed ThreadLocal to AsyncLocal to be able to use async/awai…" (#120)
This reverts commit a28e501.
1 parent a28e501 commit 98dd152

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

Aquality.Selenium.Core/src/Aquality.Selenium.Core/Applications/AqualityServices.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ namespace Aquality.Selenium.Core.Applications
77
public abstract class AqualityServices<TApplication>
88
where TApplication : class, IApplication
99
{
10-
private static readonly AsyncLocal<TApplication> AppContainer = new AsyncLocal<TApplication>();
11-
private static readonly AsyncLocal<IServiceProvider> ServiceProviderContainer = new AsyncLocal<IServiceProvider>();
10+
private static readonly ThreadLocal<TApplication> AppContainer = new ThreadLocal<TApplication>();
11+
private static readonly ThreadLocal<IServiceProvider> ServiceProviderContainer = new ThreadLocal<IServiceProvider>();
1212

1313
protected AqualityServices()
1414
{
1515
}
1616

1717
protected static bool IsApplicationStarted()
1818
{
19-
return AppContainer.Value != null && AppContainer.Value.IsStarted;
19+
return AppContainer.IsValueCreated && AppContainer.Value.IsStarted;
2020
}
2121

2222
protected static TApplication GetApplication(Func<IServiceProvider, TApplication> startApplicationFunction, Func<IServiceCollection> serviceCollectionProvider = null)
@@ -36,7 +36,7 @@ protected static void SetApplication(TApplication application)
3636

3737
protected static IServiceProvider GetServiceProvider(Func<IServiceProvider, TApplication> applicationSupplier, Func<IServiceCollection> serviceCollectionProvider = null)
3838
{
39-
if (ServiceProviderContainer.Value == null)
39+
if (!ServiceProviderContainer.IsValueCreated)
4040
{
4141
IServiceCollection services;
4242
if (serviceCollectionProvider == null)

Aquality.Selenium.Core/tests/Aquality.Selenium.Core.Tests/Applications/Browser/FindElementsTests.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using OpenQA.Selenium;
77
using System.Collections.Generic;
88
using System.Linq;
9-
using System.Threading.Tasks;
109
using Aquality.Selenium.Core.Tests.Applications.Browser.Elements;
1110

1211
namespace Aquality.Selenium.Core.Tests.Applications.Browser
@@ -104,15 +103,5 @@ public void Should_BePossibleTo_WorkWithElements_FoundByDottedLocator()
104103
() => foundElements.Select(element => element.GetElement()).ToList(),
105104
$"Failed to find elements using dotted locator [{DottedLoc}]");
106105
}
107-
108-
[Test]
109-
public async Task Should_BePossibleTo_To_Have_Async_Tests()
110-
{
111-
await Task.Delay(2000);
112-
var foundElements = FindElements<Label>(DottedLoc, expectedCount: ElementsCount.MoreThenZero);
113-
Assert.DoesNotThrow(
114-
() => foundElements.Select(element => element.GetElement()).ToList(),
115-
$"Failed to find elements using dotted locator [{DottedLoc}]");
116-
}
117106
}
118107
}

0 commit comments

Comments
 (0)