Skip to content

Upgrade AsyncGenerator to 0.6.0 #1426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tools/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.2" targetFramework="net461" />
<package id="NUnit.Extension.VSProjectLoader" version="3.6.0" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.5.1" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.6.0" targetFramework="net461" />
<package id="vswhere" version="2.1.4" targetFramework="net461" />
</packages>
14 changes: 8 additions & 6 deletions src/AsyncGenerator.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
projects:
- filePath: NHibernate\NHibernate.csproj
- filePath: NHibernate/NHibernate.csproj
concurrentRun: true
applyChanges: true
analyzation:
Expand Down Expand Up @@ -152,14 +152,14 @@
assemblyName: AsyncGenerator.Core
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
assemblyName: AsyncGenerator.Core
- filePath: NHibernate.DomainModel\NHibernate.DomainModel.csproj
- filePath: NHibernate.DomainModel/NHibernate.DomainModel.csproj
concurrentRun: true
applyChanges: true
analyzation:
scanMethodBody: true
scanForMissingAsyncMembers:
- all: true
- filePath: NHibernate.Test\NHibernate.Test.csproj
- filePath: NHibernate.Test/NHibernate.Test.csproj
concurrentRun: true
applyChanges: true
analyzation:
Expand Down Expand Up @@ -188,6 +188,8 @@
name: ObjectAssert
- conversion: Ignore
name: LinqReadonlyTestsContext
- conversion: Ignore
name: MultiThreadRunner
- conversion: Ignore
hasAttributeName: IgnoreAttribute
- conversion: NewType
Expand All @@ -202,9 +204,9 @@
- hasAttributeName: TheoryAttribute
- hasAttributeName: TestAttribute
ignoreDocuments:
- filePathEndsWith: Linq\MathTests.cs
- filePathEndsWith: Linq\ExpressionSessionLeakTest.cs
- filePathEndsWith: Linq\NorthwindDbCreator.cs
- filePathEndsWith: Linq/MathTests.cs
- filePathEndsWith: Linq/ExpressionSessionLeakTest.cs
- filePathEndsWith: Linq/NorthwindDbCreator.cs
cancellationTokens:
withoutCancellationToken:
- hasAttributeName: TestAttribute
Expand Down
166 changes: 166 additions & 0 deletions src/NHibernate.Test/Async/CacheTest/CacheFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by AsyncGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------


using System;
using System.Collections.Generic;
using System.Threading;
using NHibernate.Cache;
using NHibernate.Cache.Access;
using NUnit.Framework;

namespace NHibernate.Test.CacheTest
{
using System.Threading.Tasks;
[TestFixture]
public class CacheFixtureAsync
{
[Test]
public Task TestSimpleCacheAsync()
{
return DoTestCacheAsync(new HashtableCacheProvider());
}

private CacheKey CreateCacheKey(string text)
{
return new CacheKey(text, NHibernateUtil.String, "Foo", null);
}

public async Task DoTestCacheAsync(ICacheProvider cacheProvider, CancellationToken cancellationToken = default(CancellationToken))
{
ICache cache = cacheProvider.BuildCache(typeof(String).FullName, new Dictionary<string, string>());

long longBefore = Timestamper.Next();

await (Task.Delay(15, cancellationToken));

long before = Timestamper.Next();

await (Task.Delay(15, cancellationToken));

ICacheConcurrencyStrategy ccs = new ReadWriteCache();
ccs.Cache = cache;

// cache something
CacheKey fooKey = CreateCacheKey("foo");

Assert.IsTrue(await (ccs.PutAsync(fooKey, "foo", before, null, null, false, cancellationToken)));

await (Task.Delay(15, cancellationToken));

long after = Timestamper.Next();

Assert.IsNull(await (ccs.GetAsync(fooKey, longBefore, cancellationToken)));
Assert.AreEqual("foo", await (ccs.GetAsync(fooKey, after, cancellationToken)));
Assert.IsFalse(await (ccs.PutAsync(fooKey, "foo", before, null, null, false, cancellationToken)));

// update it;

ISoftLock fooLock = await (ccs.LockAsync(fooKey, null, cancellationToken));

Assert.IsNull(await (ccs.GetAsync(fooKey, after, cancellationToken)));
Assert.IsNull(await (ccs.GetAsync(fooKey, longBefore, cancellationToken)));
Assert.IsFalse(await (ccs.PutAsync(fooKey, "foo", before, null, null, false, cancellationToken)));

await (Task.Delay(15, cancellationToken));

long whileLocked = Timestamper.Next();

Assert.IsFalse(await (ccs.PutAsync(fooKey, "foo", whileLocked, null, null, false, cancellationToken)));

await (Task.Delay(15, cancellationToken));

await (ccs.ReleaseAsync(fooKey, fooLock, cancellationToken));

Assert.IsNull(await (ccs.GetAsync(fooKey, after, cancellationToken)));
Assert.IsNull(await (ccs.GetAsync(fooKey, longBefore, cancellationToken)));
Assert.IsFalse(await (ccs.PutAsync(fooKey, "bar", whileLocked, null, null, false, cancellationToken)));
Assert.IsFalse(await (ccs.PutAsync(fooKey, "bar", after, null, null, false, cancellationToken)));

await (Task.Delay(15, cancellationToken));

long longAfter = Timestamper.Next();

Assert.IsTrue(await (ccs.PutAsync(fooKey, "baz", longAfter, null, null, false, cancellationToken)));
Assert.IsNull(await (ccs.GetAsync(fooKey, after, cancellationToken)));
Assert.IsNull(await (ccs.GetAsync(fooKey, whileLocked, cancellationToken)));

await (Task.Delay(15, cancellationToken));

long longLongAfter = Timestamper.Next();

Assert.AreEqual("baz", await (ccs.GetAsync(fooKey, longLongAfter, cancellationToken)));

// update it again, with multiple locks

ISoftLock fooLock1 = await (ccs.LockAsync(fooKey, null, cancellationToken));
ISoftLock fooLock2 = await (ccs.LockAsync(fooKey, null, cancellationToken));

Assert.IsNull(await (ccs.GetAsync(fooKey, longLongAfter, cancellationToken)));

await (Task.Delay(15, cancellationToken));

whileLocked = Timestamper.Next();

Assert.IsFalse(await (ccs.PutAsync(fooKey, "foo", whileLocked, null, null, false, cancellationToken)));

await (Task.Delay(15, cancellationToken));

await (ccs.ReleaseAsync(fooKey, fooLock2, cancellationToken));

await (Task.Delay(15, cancellationToken));

long betweenReleases = Timestamper.Next();

Assert.IsFalse(await (ccs.PutAsync(fooKey, "bar", betweenReleases, null, null, false, cancellationToken)));
Assert.IsNull(await (ccs.GetAsync(fooKey, betweenReleases, cancellationToken)));

await (Task.Delay(15, cancellationToken));

await (ccs.ReleaseAsync(fooKey, fooLock1, cancellationToken));

Assert.IsFalse(await (ccs.PutAsync(fooKey, "bar", whileLocked, null, null, false, cancellationToken)));

await (Task.Delay(15, cancellationToken));

longAfter = Timestamper.Next();

Assert.IsTrue(await (ccs.PutAsync(fooKey, "baz", longAfter, null, null, false, cancellationToken)));
Assert.IsNull(await (ccs.GetAsync(fooKey, whileLocked, cancellationToken)));

await (Task.Delay(15, cancellationToken));

longLongAfter = Timestamper.Next();

Assert.AreEqual("baz", await (ccs.GetAsync(fooKey, longLongAfter, cancellationToken)));
}

private async Task DoTestMinValueTimestampOnStrategyAsync(ICache cache, ICacheConcurrencyStrategy strategy, CancellationToken cancellationToken = default(CancellationToken))
{
CacheKey key = CreateCacheKey("key");
strategy.Cache = cache;
await (strategy.PutAsync(key, "value", long.MinValue, 0, null, false, cancellationToken));

Assert.IsNull(await (strategy.GetAsync(key, long.MinValue, cancellationToken)), "{0} strategy fails the test", strategy.GetType());
Assert.IsNull(await (strategy.GetAsync(key, long.MaxValue, cancellationToken)), "{0} strategy fails the test", strategy.GetType());
}

[Test]
public async Task MinValueTimestampAsync()
{
ICache cache = new HashtableCacheProvider().BuildCache("region", new Dictionary<string, string>());
ICacheConcurrencyStrategy strategy = new ReadWriteCache();
strategy.Cache = cache;

await (DoTestMinValueTimestampOnStrategyAsync(cache, new ReadWriteCache()));
await (DoTestMinValueTimestampOnStrategyAsync(cache, new NonstrictReadWriteCache()));
await (DoTestMinValueTimestampOnStrategyAsync(cache, new ReadOnlyCache()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ protected override IList Mappings
public delegate IDictionary SingleCarQueryDelegate(ISession session);
public delegate IList AllModelQueryDelegate(ISession session);

[Test]
public Task ShouldWorkWithHQLAsync()
{
return TestLazyDynamicClassAsync(
s => (IDictionary) s.CreateQuery("from ProductLine pl order by pl.Description").UniqueResult(),
s => s.CreateQuery("from Model m").List());
}

[Test]
public Task ShouldWorkWithCriteriaAsync()
{
return TestLazyDynamicClassAsync(
s => (IDictionary) s.CreateCriteria("ProductLine").AddOrder(Order.Asc("Description")).UniqueResult(),
s => s.CreateCriteria("Model").List());
}

public async Task TestLazyDynamicClassAsync(SingleCarQueryDelegate singleCarQueryHandler, AllModelQueryDelegate allModelQueryHandler, CancellationToken cancellationToken = default(CancellationToken))
{
ITransaction t;
Expand Down
2 changes: 1 addition & 1 deletion src/NHibernate.Test/Async/Hql/Ast/BulkManipulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public async Task IncrementTimestampVersionAsync()

DateTime initialVersion = entity.Version;

Thread.Sleep(1300);
await (Task.Delay(1300));

using (ISession s = OpenSession())
{
Expand Down
Loading