From 54c3ae15d083b75b1db8af472466acb450345d85 Mon Sep 17 00:00:00 2001 From: maca88 Date: Sat, 13 Apr 2019 21:20:02 +0200 Subject: [PATCH 1/2] Update AsyncGenerator to 0.14.0 --- Tools/packages.config | 2 +- src/AsyncGenerator.yml | 41 +- .../Async/Ado/BatcherFixture.cs | 39 +- .../Async/CacheTest/BatchableCacheFixture.cs | 62 +-- .../Async/Component/Basic/ComponentTest.cs | 72 ---- .../Async/Criteria/CriteriaQueryTest.cs | 110 ----- .../FetchLazyPropertiesFixture.cs | 53 ++- .../Identity/IdentityGeneratedKeysTest.cs | 122 ------ .../GhostProperty/GhostPropertyFixture.cs | 12 - .../Async/Hql/Ast/HqlFixture.cs | 25 -- .../Async/Hql/EntityJoinHqlTest.cs | 17 - src/NHibernate.Test/Async/Hql/HQLFunctions.cs | 34 -- .../Async/LazyGroup/LazyGroupFixture.cs | 10 +- .../Async/LazyProperty/LazyPropertyFixture.cs | 19 +- .../Async/Legacy/ABCProxyTest.cs | 33 -- .../Async/Legacy/SQLFunctionsTest.cs | 17 - .../Async/Legacy/SQLLoaderTest.cs | 51 --- .../Linq/BooleanMethodExtensionExample.cs | 55 --- .../Async/Linq/ByMethod/CastTests.cs | 9 - .../Async/Linq/ConstantTest.cs | 13 - src/NHibernate.Test/Async/Linq/JoinTests.cs | 30 -- .../Async/Linq/LinqQuerySamples.cs | 381 ------------------ src/NHibernate.Test/Async/Linq/PagingTests.cs | 133 ------ .../Async/Linq/WhereSubqueryTests.cs | 93 ----- src/NHibernate.Test/Async/Linq/WhereTests.cs | 13 - .../Fixture.cs | 5 +- .../Fixture.cs | 15 - .../Async/NHSpecificTest/GH1300/Fixture.cs | 19 +- .../Async/NHSpecificTest/GH1920/Fixture.cs | 7 +- .../Async/NHSpecificTest/GH1921/Fixture.cs | 37 +- .../Async/NHSpecificTest/NH1001/Fixture.cs | 14 - .../Async/NHSpecificTest/NH1985/SampleTest.cs | 39 -- .../Async/NHSpecificTest/NH2208/Filter.cs | 29 -- .../Async/NHSpecificTest/NH2294/Fixture.cs | 32 -- .../Async/NHSpecificTest/NH2302/Fixture.cs | 29 -- .../NH2583/ManualTestFixture.cs | 38 -- .../Async/NHSpecificTest/NH2693/Fixture.cs | 152 ------- .../Async/NHSpecificTest/NH2705/Test.cs | 12 - .../Async/NHSpecificTest/NH2721/Fixture.cs | 79 ---- .../Async/NHSpecificTest/NH2951/Fixture.cs | 63 --- .../NHSpecificTest/NH3037/FixtureByCode.cs | 5 +- .../Async/NHSpecificTest/NH3074/Fixture.cs | 90 ----- .../NHSpecificTest/NH3138/FixtureByCode.cs | 15 - .../Async/NHSpecificTest/NH3401/Fixture.cs | 64 --- .../NHSpecificTest/NH3850/MainFixture.cs | 49 --- .../Async/Operations/MergeFixture.cs | 35 -- .../Async/ReadOnly/ReadOnlyProxyTest.cs | 100 ----- .../Async/ReadOnly/ReadOnlyVersionedNodes.cs | 74 ---- .../SqlTest/Query/NativeSQLQueriesFixture.cs | 74 ---- 49 files changed, 112 insertions(+), 2410 deletions(-) delete mode 100644 src/NHibernate.Test/Async/Linq/BooleanMethodExtensionExample.cs delete mode 100644 src/NHibernate.Test/Async/NHSpecificTest/NH2208/Filter.cs delete mode 100644 src/NHibernate.Test/Async/NHSpecificTest/NH2294/Fixture.cs delete mode 100644 src/NHibernate.Test/Async/NHSpecificTest/NH2721/Fixture.cs delete mode 100644 src/NHibernate.Test/Async/NHSpecificTest/NH2951/Fixture.cs delete mode 100644 src/NHibernate.Test/Async/NHSpecificTest/NH3074/Fixture.cs delete mode 100644 src/NHibernate.Test/Async/NHSpecificTest/NH3401/Fixture.cs diff --git a/Tools/packages.config b/Tools/packages.config index 6d41f85d78e..cf6de7cecb7 100644 --- a/Tools/packages.config +++ b/Tools/packages.config @@ -7,7 +7,7 @@ - + diff --git a/src/AsyncGenerator.yml b/src/AsyncGenerator.yml index 881e7096216..a4d096948b0 100644 --- a/src/AsyncGenerator.yml +++ b/src/AsyncGenerator.yml @@ -181,30 +181,10 @@ methodConversion: - conversion: Copy name: AfterTransactionCompletionProcess_EvictsFromCache - - conversion: Copy - hasAttributeName: OneTimeSetUpAttribute - - conversion: Copy - hasAttributeName: OneTimeTearDownAttribute - - conversion: Copy - hasAttributeName: SetUpAttribute - - conversion: Copy - hasAttributeName: TearDownAttribute - - conversion: Smart - hasAttributeName: TestAttribute - - conversion: Smart - hasAttributeName: TheoryAttribute asyncExtensionMethods: projectFiles: - fileName: LinqExtensionMethods.cs projectName: NHibernate - preserveReturnType: - - hasAttributeName: TestAttribute - - hasAttributeName: TheoryAttribute - alwaysAwait: - - hasAttributeName: TestAttribute - - hasAttributeName: TheoryAttribute - - hasAttributeName: SetUpAttribute - - hasAttributeName: TearDownAttribute typeConversion: - conversion: Ignore name: ObjectAssert @@ -214,32 +194,24 @@ name: MultiThreadRunner - conversion: Ignore name: PeVerifier - - conversion: Ignore - hasAttributeName: IgnoreAttribute - - conversion: NewType - hasAttributeName: TestFixtureAttribute - - conversion: NewType - anyBaseTypeRule: HasTestFixtureAttribute - conversion: Ignore rule: IsTestCase - conversion: Ignore anyBaseTypeRule: IsTestCase - ignoreSearchForMethodReferences: - - hasAttributeName: TheoryAttribute - - hasAttributeName: TestAttribute ignoreDocuments: - filePathEndsWith: Linq/MathTests.cs - filePathEndsWith: Linq/ExpressionSessionLeakTest.cs - filePathEndsWith: Linq/NorthwindDbCreator.cs cancellationTokens: - withoutCancellationToken: - - hasAttributeName: TestAttribute - - hasAttributeName: TheoryAttribute + enabled: true scanMethodBody: true scanForMissingAsyncMembers: - all: true registerPlugin: - - type: AsyncGenerator.Core.Plugins.NUnitAsyncCounterpartsFinder + - type: AsyncGenerator.Core.Plugins.NUnitPlugin + parameters: + - name: createNewTypes + value: true assemblyName: AsyncGenerator.Core - type: AsyncGenerator.Core.Plugins.TransactionScopeAsyncFlowAdder assemblyName: AsyncGenerator.Core @@ -302,6 +274,3 @@ typeRules: - filters: - name: TestCase name: IsTestCase -- filters: - - hasAttributeName: TestFixtureAttribute - name: HasTestFixtureAttribute diff --git a/src/NHibernate.Test/Async/Ado/BatcherFixture.cs b/src/NHibernate.Test/Async/Ado/BatcherFixture.cs index 89b61255596..a21e4c918e0 100644 --- a/src/NHibernate.Test/Async/Ado/BatcherFixture.cs +++ b/src/NHibernate.Test/Async/Ado/BatcherFixture.cs @@ -102,44 +102,7 @@ public async Task OneRoundTripUpdateAsync() await (CleanupAsync()); } -#if NETFX - [Test, Ignore("Not fixed yet.")] - [Description("SqlClient: The batcher should run all different INSERT queries in only one roundtrip.")] - public async Task SqlClientOneRoundTripForUpdateAndInsertAsync() - { - if (Sfi.Settings.BatcherFactory is SqlClientBatchingBatcherFactory == false) - Assert.Ignore("This test is for SqlClientBatchingBatcher only"); - - await (FillDbAsync()); - - using (var sqlLog = new SqlLogSpy()) - using (ISession s = Sfi.OpenSession()) - using (ITransaction tx = s.BeginTransaction()) - { - await (s.SaveAsync(new VerySimple - { - Name = "test441", - Weight = 894 - })); - - await (s.SaveAsync(new AlmostSimple - { - Name = "test441", - Weight = 894 - })); - - await (tx.CommitAsync()); - - var log = sqlLog.GetWholeLog(); - //log should only contain NHibernate.SQL once, because that means - //that we ony generated a single batch (NHibernate.SQL log will output - //once per batch) - Assert.AreEqual(0, log.IndexOf("NHibernate.SQL"), "log should start with NHibernate.SQL"); - Assert.AreEqual(-1, log.IndexOf("NHibernate.SQL", "NHibernate.SQL".Length), "NHibernate.SQL should only appear once in the log"); - } - - await (CleanupAsync()); - } + #if NETFX [Test] [Description("SqlClient: The batcher log output should be formatted")] diff --git a/src/NHibernate.Test/Async/CacheTest/BatchableCacheFixture.cs b/src/NHibernate.Test/Async/CacheTest/BatchableCacheFixture.cs index 741992bf116..41b7770e63e 100644 --- a/src/NHibernate.Test/Async/CacheTest/BatchableCacheFixture.cs +++ b/src/NHibernate.Test/Async/CacheTest/BatchableCacheFixture.cs @@ -866,14 +866,14 @@ public async Task QueryCacheTestAsync() [TestCase(true)] [TestCase(false)] - public async Task QueryEntityBatchCacheTestAsync(bool clearEntityCacheAfterQuery, CancellationToken cancellationToken = default(CancellationToken)) + public async Task QueryEntityBatchCacheTestAsync(bool clearEntityCacheAfterQuery) { var persister = Sfi.GetEntityPersister(typeof(ReadOnlyItem).FullName); var cache = (BatchableCache) persister.Cache.Cache; var queryCache = GetDefaultQueryCache(); Sfi.Statistics.Clear(); - await (Sfi.EvictQueriesAsync(cancellationToken)); + await (Sfi.EvictQueriesAsync()); cache.ClearStatistics(); queryCache.ClearStatistics(); @@ -884,9 +884,9 @@ public async Task QueryCacheTestAsync() { items = await (s.Query() .WithOptions(o => o.SetCacheable(true)) - .ToListAsync(cancellationToken)); + .ToListAsync()); - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } Assert.That(queryCache.GetCalls, Has.Count.EqualTo(1), "Unexpected query cache GetCalls"); @@ -903,7 +903,7 @@ public async Task QueryCacheTestAsync() if (clearEntityCacheAfterQuery) { - await (cache.ClearAsync(cancellationToken)); + await (cache.ClearAsync(CancellationToken.None)); } Sfi.Statistics.Clear(); @@ -913,9 +913,9 @@ public async Task QueryCacheTestAsync() { items = await (s.Query() .WithOptions(o => o.SetCacheable(true)) - .ToListAsync(cancellationToken)); + .ToListAsync()); - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } Assert.That(queryCache.GetCalls, Has.Count.EqualTo(1), "Unexpected query cache GetCalls"); @@ -935,7 +935,7 @@ public async Task QueryCacheTestAsync() [TestCase(false, false)] [TestCase(true, true)] [TestCase(false, true)] - public async Task QueryFetchCollectionBatchCacheTestAsync(bool clearEntityCacheAfterQuery, bool future, CancellationToken cancellationToken = default(CancellationToken)) + public async Task QueryFetchCollectionBatchCacheTestAsync(bool clearEntityCacheAfterQuery, bool future) { if (future && !Sfi.ConnectionProvider.Driver.SupportsMultipleQueries) { @@ -954,19 +954,19 @@ public async Task QueryCacheTestAsync() using (var s = OpenSession()) { - var ids = await (s.Query().Select(o => o.Id).OrderBy(o => o).ToListAsync(cancellationToken)); + var ids = await (s.Query().Select(o => o.Id).OrderBy(o => o).ToListAsync()); middleId = ids[2]; } Sfi.Statistics.Clear(); - await (Sfi.EvictQueriesAsync(cancellationToken)); + await (Sfi.EvictQueriesAsync()); queryCache.ClearStatistics(); cache.ClearStatistics(); - await (cache.ClearAsync(cancellationToken)); + await (cache.ClearAsync(CancellationToken.None)); itemCache.ClearStatistics(); - await (itemCache.ClearAsync(cancellationToken)); + await (itemCache.ClearAsync(CancellationToken.None)); collectionCache.ClearStatistics(); - await (collectionCache.ClearAsync(cancellationToken)); + await (collectionCache.ClearAsync(CancellationToken.None)); List items; using (var s = OpenSession()) @@ -992,10 +992,10 @@ public async Task QueryCacheTestAsync() items = await (s.Query() .WithOptions(o => o.SetCacheable(true)) .FetchMany(o => o.Items) - .ToListAsync(cancellationToken)); + .ToListAsync()); } - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } Assert.That(queryCache.GetCalls, Has.Count.EqualTo(future ? 0 : 1), "Unexpected query cache GetCalls"); @@ -1018,9 +1018,9 @@ public async Task QueryCacheTestAsync() if (clearEntityCacheAfterQuery) { - await (cache.ClearAsync(cancellationToken)); - await (collectionCache.ClearAsync(cancellationToken)); - await (itemCache.ClearAsync(cancellationToken)); + await (cache.ClearAsync(CancellationToken.None)); + await (collectionCache.ClearAsync(CancellationToken.None)); + await (itemCache.ClearAsync(CancellationToken.None)); } Sfi.Statistics.Clear(); @@ -1048,10 +1048,10 @@ public async Task QueryCacheTestAsync() items = await (s.Query() .WithOptions(o => o.SetCacheable(true)) .FetchMany(o => o.Items) - .ToListAsync(cancellationToken)); + .ToListAsync()); } - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } Assert.That(queryCache.GetCalls, Has.Count.EqualTo(future ? 0 : 1), "Unexpected query cache GetCalls"); @@ -1080,7 +1080,7 @@ public async Task QueryCacheTestAsync() [TestCase(false, false)] [TestCase(true, true)] [TestCase(false, true)] - public async Task QueryFetchEntityBatchCacheTestAsync(bool clearEntityCacheAfterQuery, bool future, CancellationToken cancellationToken = default(CancellationToken)) + public async Task QueryFetchEntityBatchCacheTestAsync(bool clearEntityCacheAfterQuery, bool future) { if (future && !Sfi.ConnectionProvider.Driver.SupportsMultipleQueries) { @@ -1097,17 +1097,17 @@ public async Task QueryCacheTestAsync() using (var s = OpenSession()) { - var ids = await (s.Query().Select(o => o.Id).OrderBy(o => o).ToListAsync(cancellationToken)); + var ids = await (s.Query().Select(o => o.Id).OrderBy(o => o).ToListAsync()); middleId = ids[17]; } Sfi.Statistics.Clear(); - await (Sfi.EvictQueriesAsync(cancellationToken)); + await (Sfi.EvictQueriesAsync()); queryCache.ClearStatistics(); cache.ClearStatistics(); - await (cache.ClearAsync(cancellationToken)); + await (cache.ClearAsync(CancellationToken.None)); parentCache.ClearStatistics(); - await (parentCache.ClearAsync(cancellationToken)); + await (parentCache.ClearAsync(CancellationToken.None)); List items; using (var s = OpenSession()) @@ -1133,10 +1133,10 @@ public async Task QueryCacheTestAsync() items = await (s.Query() .WithOptions(o => o.SetCacheable(true)) .Fetch(o => o.Parent) - .ToListAsync(cancellationToken)); + .ToListAsync()); } - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } Assert.That(queryCache.GetCalls, Has.Count.EqualTo(future ? 0 : 1), "Unexpected query cache GetCalls"); @@ -1158,8 +1158,8 @@ public async Task QueryCacheTestAsync() if (clearEntityCacheAfterQuery) { - await (cache.ClearAsync(cancellationToken)); - await (parentCache.ClearAsync(cancellationToken)); + await (cache.ClearAsync(CancellationToken.None)); + await (parentCache.ClearAsync(CancellationToken.None)); } Sfi.Statistics.Clear(); @@ -1187,10 +1187,10 @@ public async Task QueryCacheTestAsync() items = await (s.Query() .WithOptions(o => o.SetCacheable(true)) .Fetch(o => o.Parent) - .ToListAsync(cancellationToken)); + .ToListAsync()); } - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } Assert.That(queryCache.GetCalls, Has.Count.EqualTo(future ? 0 : 1), "Unexpected query cache GetCalls"); diff --git a/src/NHibernate.Test/Async/Component/Basic/ComponentTest.cs b/src/NHibernate.Test/Async/Component/Basic/ComponentTest.cs index 62346be8e41..a3a058a3def 100644 --- a/src/NHibernate.Test/Async/Component/Basic/ComponentTest.cs +++ b/src/NHibernate.Test/Async/Component/Basic/ComponentTest.cs @@ -167,78 +167,6 @@ public async Task TestComponentStateChangeAndDirtinessAsync() } } - [Test] - [Ignore("Ported from Hibernate. Read properties not supported in NH yet.")] - public async Task TestCustomColumnReadAndWriteAsync() - { - const double HEIGHT_INCHES = 73; - const double HEIGHT_CENTIMETERS = HEIGHT_INCHES * 2.54d; - - using (ISession s = Sfi.OpenSession()) - using (ITransaction t = s.BeginTransaction()) - { - User u = new User("steve", "hibernater", new Person( "Steve Ebersole", new DateTime(1999, 12, 31), "Main St")); - u.Person.HeightInches = HEIGHT_INCHES; - await (s.PersistAsync(u)); - await (s.FlushAsync()); - - // Test value conversion during insert - double heightViaSql = (double)await (s.CreateSQLQuery("select height_centimeters from t_user where t_user.username='steve'").UniqueResultAsync()); - Assert.That(heightViaSql, Is.EqualTo(HEIGHT_CENTIMETERS).Within(0.01d)); - - // Test projection - double heightViaHql = (double)await (s.CreateQuery("select u.Person.HeightInches from User u where u.Id = 'steve'").UniqueResultAsync()); - Assert.That(heightViaHql, Is.EqualTo(HEIGHT_INCHES).Within(0.01d)); - - // Test restriction and entity load via criteria - u = (User)await (s.CreateCriteria(typeof(User)) - .Add(Restrictions.Between("Person.HeightInches", HEIGHT_INCHES - 0.01d, HEIGHT_INCHES + 0.01d)) - .UniqueResultAsync()); - Assert.That(u.Person.HeightInches, Is.EqualTo(HEIGHT_INCHES).Within(0.01d)); - - // Test predicate and entity load via HQL - u = (User)await (s.CreateQuery("from User u where u.Person.HeightInches between ? and ?") - .SetDouble(0, HEIGHT_INCHES - 0.01d) - .SetDouble(1, HEIGHT_INCHES + 0.01d) - .UniqueResultAsync()); - - Assert.That(u.Person.HeightInches, Is.EqualTo(HEIGHT_INCHES).Within(0.01d)); - - // Test update - u.Person.HeightInches = 1; - await (s.FlushAsync()); - heightViaSql = (double)await (s.CreateSQLQuery("select height_centimeters from t_user where t_user.username='steve'").UniqueResultAsync()); - Assert.That(heightViaSql, Is.EqualTo(2.54d).Within(0.01d)); - await (s.DeleteAsync(u)); - await (t.CommitAsync()); - s.Close(); - } - } - - [Test] - [Ignore("Ported from Hibernate - failing in NH")] - public async Task TestComponentQueriesAsync() - { - using (ISession s = Sfi.OpenSession()) - using (ITransaction t = s.BeginTransaction()) - { - Employee emp = new Employee(); - emp.HireDate = new DateTime(1999, 12, 31); - emp.Person = new Person(); - emp.Person.Name = "steve"; - emp.Person.Dob = new DateTime(1999, 12, 31); - await (s.SaveAsync(emp)); - - await (s.CreateQuery("from Employee e where e.Person = :p and 1=1 and 2=2").SetParameter("p", emp.Person).ListAsync()); - await (s.CreateQuery("from Employee e where :p = e.Person").SetParameter("p", emp.Person).ListAsync()); - await (s.CreateQuery("from Employee e where e.Person = ('steve', current_timestamp)").ListAsync()); - - await (s.DeleteAsync( emp )); - await (t.CommitAsync()); - s.Close(); - } - } - [Test] public async Task TestComponentFormulaQueryAsync() { diff --git a/src/NHibernate.Test/Async/Criteria/CriteriaQueryTest.cs b/src/NHibernate.Test/Async/Criteria/CriteriaQueryTest.cs index cba892a06aa..e6dbcc74f01 100644 --- a/src/NHibernate.Test/Async/Criteria/CriteriaQueryTest.cs +++ b/src/NHibernate.Test/Async/Criteria/CriteriaQueryTest.cs @@ -97,29 +97,6 @@ public async Task EscapeCharacterAsync() } } - [Test, Ignore("ScrollableResults not implemented")] - public async Task ScrollCriteriaAsync() - { - ISession session = OpenSession(); - ITransaction t = session.BeginTransaction(); - - Course course = new Course(); - course.CourseCode = "HIB"; - course.Description = "Hibernate Training"; - await (session.SaveAsync(course)); - await (session.FlushAsync()); - session.Clear(); - //IScrollableResults sr = session.CreateCriteria(typeof(Course)).Scroll(); - //Assert.IsTrue( sr.Next() ); - //course = (Course) sr[0]; - Assert.IsNotNull(course); - //sr.Close(); - await (session.DeleteAsync(course)); - - await (t.CommitAsync()); - session.Close(); - } - [Test] public async Task AllowToSetLimitOnSubqueriesAsync() { @@ -825,93 +802,6 @@ public async Task ProjectionCacheAsync() s.Close(); } - [Test, Ignore("Not supported.")] - public async Task NH_1155_ShouldNotLoadAllChildrenInPagedSubSelectAsync() - { - if (this.Dialect.GetType().Equals((typeof(MsSql2000Dialect)))) - Assert.Ignore("This is not fixed for SQL 2000 Dialect"); - - using (ISession s = OpenSession()) - using (ITransaction tx = s.BeginTransaction()) - { - Course course = new Course(); - course.CourseCode = "HIB"; - course.Description = "Hibernate Training"; - await (s.SaveAsync(course)); - - - Student gavin = new Student(); - gavin.Name = "Gavin King"; - gavin.StudentNumber = 667; - await (s.SaveAsync(gavin)); - - Student ayende = new Student(); - ayende.Name = "Ayende Rahien"; - ayende.StudentNumber = 1337; - await (s.SaveAsync(ayende)); - - - Student xam = new Student(); - xam.Name = "Max Rydahl Andersen"; - xam.StudentNumber = 101; - await (s.SaveAsync(xam)); - - Enrolment enrolment = new Enrolment(); - enrolment.Course = course; - enrolment.CourseCode = course.CourseCode; - enrolment.Semester = 1; - enrolment.Year = 1999; - enrolment.Student = xam; - enrolment.StudentNumber = xam.StudentNumber; - xam.Enrolments.Add(enrolment); - await (s.SaveAsync(enrolment)); - - enrolment = new Enrolment(); - enrolment.Course = course; - enrolment.CourseCode = course.CourseCode; - enrolment.Semester = 3; - enrolment.Year = 1998; - enrolment.Student = ayende; - enrolment.StudentNumber = ayende.StudentNumber; - ayende.Enrolments.Add(enrolment); - await (s.SaveAsync(enrolment)); - await (tx.CommitAsync()); - } - - using (ISession s = OpenSession()) - { - IList list = await (s.CreateCriteria(typeof(Student)) - .SetFirstResult(1) - .SetMaxResults(10) - .AddOrder(Order.Asc("StudentNumber")) - .ListAsync()); - foreach (Student student in list) - { - foreach (Enrolment enrolment in student.Enrolments) - { - await (NHibernateUtil.InitializeAsync(enrolment)); - } - } - - Enrolment key = new Enrolment(); - key.CourseCode = "HIB"; - key.StudentNumber = 101;// xam - //since we didn't load xam's entrollments before (skipped by orderring) - //it should not be already loaded - Enrolment shouldNotBeLoaded = (Enrolment)await (s.LoadAsync(typeof(Enrolment), key)); - Assert.IsFalse(NHibernateUtil.IsInitialized(shouldNotBeLoaded)); - } - - using (ISession s = OpenSession()) - using (ITransaction tx = s.BeginTransaction()) - { - await (s.DeleteAsync("from Enrolment")); - await (s.DeleteAsync("from Student")); - await (s.DeleteAsync("from Course")); - await (tx.CommitAsync()); - } - } - [Test] public async Task ProjectionsTestAsync() { diff --git a/src/NHibernate.Test/Async/FetchLazyProperties/FetchLazyPropertiesFixture.cs b/src/NHibernate.Test/Async/FetchLazyProperties/FetchLazyPropertiesFixture.cs index d6a85b966c0..244678c5c05 100644 --- a/src/NHibernate.Test/Async/FetchLazyProperties/FetchLazyPropertiesFixture.cs +++ b/src/NHibernate.Test/Async/FetchLazyProperties/FetchLazyPropertiesFixture.cs @@ -20,7 +20,6 @@ namespace NHibernate.Test.FetchLazyProperties { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class FetchLazyPropertiesFixtureAsync : TestCase { @@ -201,16 +200,16 @@ private static void AssertFetchProperty(Person person) [TestCase(true)] [TestCase(false)] - public async Task TestHqlFetchComponentAndFormulaTwoQueryReadOnlyAsync(bool readOnly, CancellationToken cancellationToken = default(CancellationToken)) + public async Task TestHqlFetchComponentAndFormulaTwoQueryReadOnlyAsync(bool readOnly) { Person person; using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { - person = await (s.CreateQuery("from Person fetch Address where Id = 1").SetReadOnly(readOnly).UniqueResultAsync(cancellationToken)); - person = await (s.CreateQuery("from Person fetch Formula where Id = 1").SetReadOnly(readOnly).UniqueResultAsync(cancellationToken)); + person = await (s.CreateQuery("from Person fetch Address where Id = 1").SetReadOnly(readOnly).UniqueResultAsync()); + person = await (s.CreateQuery("from Person fetch Formula where Id = 1").SetReadOnly(readOnly).UniqueResultAsync()); - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } AssertFetchComponentAndFormulaTwoQuery(person); @@ -218,16 +217,16 @@ private static void AssertFetchProperty(Person person) [TestCase(true)] [TestCase(false)] - public async Task TestLinqFetchComponentAndFormulaTwoQueryAsync(bool readOnly, CancellationToken cancellationToken = default(CancellationToken)) + public async Task TestLinqFetchComponentAndFormulaTwoQueryAsync(bool readOnly) { Person person; using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { - person = await (s.Query().Fetch(o => o.Address).WithOptions(o => o.SetReadOnly(readOnly)).FirstOrDefaultAsync(o => o.Id == 1, cancellationToken)); - person = await (s.Query().Fetch(o => o.Formula).WithOptions(o => o.SetReadOnly(readOnly)).FirstOrDefaultAsync(o => o.Id == 1, cancellationToken)); + person = await (s.Query().Fetch(o => o.Address).WithOptions(o => o.SetReadOnly(readOnly)).FirstOrDefaultAsync(o => o.Id == 1)); + person = await (s.Query().Fetch(o => o.Formula).WithOptions(o => o.SetReadOnly(readOnly)).FirstOrDefaultAsync(o => o.Id == 1)); - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } AssertFetchComponentAndFormulaTwoQuery(person); @@ -373,13 +372,13 @@ private static void AssertFetchFormulaAndManyToOneComponent(Person person) [TestCase(true)] [TestCase(false)] - public async Task TestHqlFetchFormulaAndManyToOneComponentListAsync(bool descending, CancellationToken cancellationToken = default(CancellationToken)) + public async Task TestHqlFetchFormulaAndManyToOneComponentListAsync(bool descending) { Person person; using (var s = OpenSession()) { person = (await (s.CreateQuery("from Person p fetch p.Formula left join fetch p.BestFriend bf fetch bf.Address order by p.Id" + (descending ? " desc" : "")) - .ListAsync(cancellationToken))).FirstOrDefault(o => o.Id == 1); + .ListAsync())).FirstOrDefault(o => o.Id == 1); } AssertFetchFormulaAndManyToOneComponentList(person); @@ -387,7 +386,7 @@ private static void AssertFetchFormulaAndManyToOneComponent(Person person) [TestCase(true)] [TestCase(false)] - public async Task TestLinqFetchFormulaAndManyToOneComponentListAsync(bool descending, CancellationToken cancellationToken = default(CancellationToken)) + public async Task TestLinqFetchFormulaAndManyToOneComponentListAsync(bool descending) { Person person; using (var s = OpenSession()) @@ -397,7 +396,7 @@ private static void AssertFetchFormulaAndManyToOneComponent(Person person) .Fetch(o => o.BestFriend).ThenFetch(o => o.Address); query = descending ? query.OrderByDescending(o => o.Id) : query.OrderBy(o => o.Id); person = (await (query - .ToListAsync(cancellationToken))) + .ToListAsync())) .FirstOrDefault(o => o.Id == 1); } @@ -838,17 +837,17 @@ public async Task TestHqlFetchComponentAliasAsync() [TestCase(true)] [TestCase(false)] - public async Task TestFetchComponentAndFormulaTwoQueryCacheAsync(bool readOnly, CancellationToken cancellationToken = default(CancellationToken)) + public async Task TestFetchComponentAndFormulaTwoQueryCacheAsync(bool readOnly) { - await (TestLinqFetchComponentAndFormulaTwoQueryAsync(readOnly, cancellationToken)); + await (TestLinqFetchComponentAndFormulaTwoQueryAsync(readOnly)); Person person; using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { - person = await (s.GetAsync(1, cancellationToken)); + person = await (s.GetAsync(1)); - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } AssertFetchComponentAndFormulaTwoQuery(person); @@ -893,17 +892,17 @@ public async Task TestFetchComponentCacheAsync() [TestCase(true)] [TestCase(false)] - public async Task TestFetchAfterPropertyIsInitializedAsync(bool readOnly, CancellationToken cancellationToken = default(CancellationToken)) + public async Task TestFetchAfterPropertyIsInitializedAsync(bool readOnly) { Person person; using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { - person = await (s.CreateQuery("from Person fetch Address where Id = 1").SetReadOnly(readOnly).UniqueResultAsync(cancellationToken)); + person = await (s.CreateQuery("from Person fetch Address where Id = 1").SetReadOnly(readOnly).UniqueResultAsync()); person.Image = new byte[10]; - person = await (s.CreateQuery("from Person fetch Image where Id = 1").SetReadOnly(readOnly).UniqueResultAsync(cancellationToken)); + person = await (s.CreateQuery("from Person fetch Image where Id = 1").SetReadOnly(readOnly).UniqueResultAsync()); - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } Assert.That(NHibernateUtil.IsPropertyInitialized(person, "Image"), Is.True); @@ -915,10 +914,10 @@ public async Task TestFetchComponentCacheAsync() using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { - person = await (s.CreateQuery("from Person where Id = 1").SetReadOnly(readOnly).UniqueResultAsync(cancellationToken)); + person = await (s.CreateQuery("from Person where Id = 1").SetReadOnly(readOnly).UniqueResultAsync()); person.Image = new byte[1]; - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } Assert.That(NHibernateUtil.IsPropertyInitialized(person, "Image"), Is.True); @@ -928,17 +927,17 @@ public async Task TestFetchComponentCacheAsync() [TestCase(true)] [TestCase(false)] - public async Task TestFetchAfterEntityIsInitializedAsync(bool readOnly, CancellationToken cancellationToken = default(CancellationToken)) + public async Task TestFetchAfterEntityIsInitializedAsync(bool readOnly) { Person person; using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { - person = await (s.CreateQuery("from Person where Id = 1").SetReadOnly(readOnly).UniqueResultAsync(cancellationToken)); + person = await (s.CreateQuery("from Person where Id = 1").SetReadOnly(readOnly).UniqueResultAsync()); var image = person.Image; - person = await (s.CreateQuery("from Person fetch Image where Id = 1").SetReadOnly(readOnly).UniqueResultAsync(cancellationToken)); + person = await (s.CreateQuery("from Person fetch Image where Id = 1").SetReadOnly(readOnly).UniqueResultAsync()); - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } Assert.That(NHibernateUtil.IsPropertyInitialized(person, "Image"), Is.True); diff --git a/src/NHibernate.Test/Async/Generatedkeys/Identity/IdentityGeneratedKeysTest.cs b/src/NHibernate.Test/Async/Generatedkeys/Identity/IdentityGeneratedKeysTest.cs index 5fc2a393c04..655ecdbe9cf 100644 --- a/src/NHibernate.Test/Async/Generatedkeys/Identity/IdentityGeneratedKeysTest.cs +++ b/src/NHibernate.Test/Async/Generatedkeys/Identity/IdentityGeneratedKeysTest.cs @@ -52,127 +52,5 @@ public async Task IdentityColumnGeneratedIdsAsync() await (s.Transaction.CommitAsync()); s.Close(); } - - [Test, Ignore("Not supported yet.")] - public async Task PersistOutsideTransactionAsync() - { - ISession s = OpenSession(); - - // first test save() which should force an immediate insert... - MyEntity myEntity1 = new MyEntity("test-save"); - long id = (long)await (s.SaveAsync(myEntity1)); - Assert.IsNotNull(id, "identity column did not force immediate insert"); - Assert.AreEqual(id, myEntity1.Id); - - // next test persist() which should cause a delayed insert... - long initialInsertCount = Sfi.Statistics.EntityInsertCount; - MyEntity myEntity2 = new MyEntity("test-persist"); - await (s.PersistAsync(myEntity2)); - Assert.AreEqual(initialInsertCount, Sfi.Statistics.EntityInsertCount, "persist on identity column not delayed"); - Assert.AreEqual(0,myEntity2.Id); - - // an explicit flush should cause execution of the delayed insertion - await (s.FlushAsync()); - Assert.AreEqual(initialInsertCount + 1, Sfi.Statistics.EntityInsertCount, "delayed persist insert not executed on flush"); - s.Close(); - - s = OpenSession(); - s.BeginTransaction(); - await (s.DeleteAsync(myEntity1)); - await (s.DeleteAsync(myEntity2)); - await (s.Transaction.CommitAsync()); - s.Close(); - } - - [Test, Ignore("Not supported yet.")] - public async Task PersistOutsideTransactionCascadedToNonInverseCollectionAsync() - { - long initialInsertCount = Sfi.Statistics.EntityInsertCount; - ISession s = OpenSession(); - MyEntity myEntity = new MyEntity("test-persist"); - myEntity.NonInverseChildren.Add(new MyChild("test-child-persist-non-inverse")); - await (s.PersistAsync(myEntity)); - Assert.AreEqual(initialInsertCount, Sfi.Statistics.EntityInsertCount, "persist on identity column not delayed"); - Assert.AreEqual(0, myEntity.Id); - await (s.FlushAsync()); - Assert.AreEqual(initialInsertCount + 2, Sfi.Statistics.EntityInsertCount,"delayed persist insert not executed on flush"); - s.Close(); - - s = OpenSession(); - s.BeginTransaction(); - await (s.DeleteAsync("from MyChild")); - await (s.DeleteAsync("from MyEntity")); - await (s.Transaction.CommitAsync()); - s.Close(); - } - - [Test, Ignore("Not supported yet.")] - public async Task PersistOutsideTransactionCascadedToInverseCollectionAsync() - { - long initialInsertCount = Sfi.Statistics.EntityInsertCount; - ISession s = OpenSession(); - MyEntity myEntity2 = new MyEntity("test-persist-2"); - MyChild child = new MyChild("test-child-persist-inverse"); - myEntity2.InverseChildren.Add(child); - child.InverseParent= myEntity2; - await (s.PersistAsync(myEntity2)); - Assert.AreEqual(initialInsertCount, Sfi.Statistics.EntityInsertCount,"persist on identity column not delayed"); - Assert.AreEqual(0, myEntity2.Id); - await (s.FlushAsync()); - Assert.AreEqual(initialInsertCount + 2, Sfi.Statistics.EntityInsertCount,"delayed persist insert not executed on flush"); - s.Close(); - - s = OpenSession(); - s.BeginTransaction(); - await (s.DeleteAsync("from MyChild")); - await (s.DeleteAsync("from MyEntity")); - await (s.Transaction.CommitAsync()); - s.Close(); - } - - [Test, Ignore("Not supported yet.")] - public async Task PersistOutsideTransactionCascadedToManyToOneAsync() - { - long initialInsertCount = Sfi.Statistics.EntityInsertCount; - ISession s = OpenSession(); - MyEntity myEntity = new MyEntity("test-persist"); - myEntity.Sibling=new MySibling("test-persist-sibling-out"); - await (s.PersistAsync(myEntity)); - Assert.AreEqual(initialInsertCount, Sfi.Statistics.EntityInsertCount, "persist on identity column not delayed"); - Assert.AreEqual(0, myEntity.Id); - await (s.FlushAsync()); - Assert.AreEqual(initialInsertCount + 2, Sfi.Statistics.EntityInsertCount, "delayed persist insert not executed on flush"); - s.Close(); - - s = OpenSession(); - s.BeginTransaction(); - await (s.DeleteAsync("from MyEntity")); - await (s.DeleteAsync("from MySibling")); - await (s.Transaction.CommitAsync()); - s.Close(); - } - - [Test, Ignore("Not supported yet.")] - public async Task PersistOutsideTransactionCascadedFromManyToOneAsync() - { - long initialInsertCount = Sfi.Statistics.EntityInsertCount; - ISession s = OpenSession(); - MyEntity myEntity2 = new MyEntity("test-persist-2"); - MySibling sibling = new MySibling("test-persist-sibling-in"); - sibling.Entity= myEntity2; - await (s.PersistAsync(sibling)); - Assert.AreEqual(initialInsertCount, Sfi.Statistics.EntityInsertCount, "persist on identity column not delayed"); - Assert.AreEqual(0, myEntity2.Id); - await (s.FlushAsync()); - Assert.AreEqual(initialInsertCount + 2, Sfi.Statistics.EntityInsertCount, "delayed persist insert not executed on flush"); - s.Close(); - - s = OpenSession(); - s.BeginTransaction(); - await (s.DeleteAsync("from MySibling")); - await (s.DeleteAsync("from MyEntity")); - await (s.Transaction.CommitAsync()); - s.Close(); - } } } diff --git a/src/NHibernate.Test/Async/GhostProperty/GhostPropertyFixture.cs b/src/NHibernate.Test/Async/GhostProperty/GhostPropertyFixture.cs index 5a0aac53159..85d00197b0e 100644 --- a/src/NHibernate.Test/Async/GhostProperty/GhostPropertyFixture.cs +++ b/src/NHibernate.Test/Async/GhostProperty/GhostPropertyFixture.cs @@ -180,18 +180,6 @@ public async Task GhostPropertyMaintainIdentityMapAsync() } } - [Test, Ignore("This shows an expected edge case")] - public async Task GhostPropertyMaintainIdentityMapUsingGetAsync() - { - using (ISession s = OpenSession()) - { - var payment = await (s.LoadAsync(1)); - var order = await (s.GetAsync(1)); - - Assert.AreSame(order.Payment, payment); - } - } - [Test] public async Task WillLoadGhostAssociationOnAccessAsync() { diff --git a/src/NHibernate.Test/Async/Hql/Ast/HqlFixture.cs b/src/NHibernate.Test/Async/Hql/Ast/HqlFixture.cs index 3a0c9a92244..b397e9412b4 100644 --- a/src/NHibernate.Test/Async/Hql/Ast/HqlFixture.cs +++ b/src/NHibernate.Test/Async/Hql/Ast/HqlFixture.cs @@ -234,31 +234,6 @@ public async Task SubselectAdditionAsync() } } - [Test, Ignore("Not fixed yet.")] - public async Task SumShouldReturnDoubleAsync() - { - // NH-1734 - using (ISession s = OpenSession()) - using (s.BeginTransaction()) - { - await (s.SaveAsync(new Human{ IntValue = 11, BodyWeight = 12.5f, Description = "Polliwog" })); - await (s.Transaction.CommitAsync()); - } - - using (ISession s = OpenSession()) - { - var l = await (s.CreateQuery("select sum(a.intValue * a.bodyWeight) from Animal a group by a.id").ListAsync()); - Assert.That(l[0], Is.InstanceOf()); - } - - using (ISession s = OpenSession()) - using (s.BeginTransaction()) - { - await (s.CreateQuery("delete from Animal").ExecuteUpdateAsync()); - await (s.Transaction.CommitAsync()); - } - } - [Test] public async Task CanParseMaxLongAsync() { diff --git a/src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs b/src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs index 596ab76b218..25e443759d1 100644 --- a/src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs +++ b/src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs @@ -213,23 +213,6 @@ public async Task EntityJoinWithEntityAssociationComparison2ShouldAddJoinAsync() } } - - [Test, Ignore("Failing for unrelated reasons")] - public async Task CrossJoinAndWithClauseAsync() - { - //This is about complex theta style join fix that was implemented in hibernate along with entity join functionality - //https://hibernate.atlassian.net/browse/HHH-7321 - using (var sqlLog = new SqlLogSpy()) - using (var session = OpenSession()) - { - await (session.CreateQuery( - "SELECT s " + - "FROM EntityComplex s, EntityComplex q " + - "LEFT JOIN s.SameTypeChild AS sa WITH sa.SameTypeChild.Id = q.SameTypeChild.Id" - ).ListAsync()); - } - } - #region Test Setup protected override HbmMapping GetMappings() diff --git a/src/NHibernate.Test/Async/Hql/HQLFunctions.cs b/src/NHibernate.Test/Async/Hql/HQLFunctions.cs index a67a8ad518a..74df40cd536 100644 --- a/src/NHibernate.Test/Async/Hql/HQLFunctions.cs +++ b/src/NHibernate.Test/Async/Hql/HQLFunctions.cs @@ -1257,40 +1257,6 @@ public async Task NH1725Async() } } - [Test, Ignore("Not supported yet!")] - public async Task ParameterLikeArgumentAsync() - { - using (ISession s = OpenSession()) - { - Animal a1 = new Animal("abcdef", 1.3f); - await (s.SaveAsync(a1)); - await (s.FlushAsync()); - } - - using (ISession s = OpenSession()) - { - string hql; - IList l; - Animal result; - - // Render in WHERE - hql = "from Animal a where cast(:aParam as Double)>0"; - result = (Animal)await (s.CreateQuery(hql).SetDouble("aParam", 2D).UniqueResultAsync()); - Assert.IsNotNull(result); - - // Render in WHERE with math operation - hql = "from Animal a where cast(:aParam+a.BodyWeight as Double)>3"; - result = (Animal) await (s.CreateQuery(hql).SetDouble("aParam", 2D).UniqueResultAsync()); - Assert.IsNotNull(result); - - // Render in all clauses - hql = - "select cast(:aParam+a.BodyWeight as int) from Animal a group by cast(:aParam+a.BodyWeight as int) having cast(:aParam+a.BodyWeight as Double)>0"; - l = await (s.CreateQuery(hql).SetInt32("aParam", 10).ListAsync()); - Assert.AreEqual(1, l.Count); - } - } - [Test] public async Task BitwiseAndAsync() { diff --git a/src/NHibernate.Test/Async/LazyGroup/LazyGroupFixture.cs b/src/NHibernate.Test/Async/LazyGroup/LazyGroupFixture.cs index 149e7b001f7..4ec41663136 100644 --- a/src/NHibernate.Test/Async/LazyGroup/LazyGroupFixture.cs +++ b/src/NHibernate.Test/Async/LazyGroup/LazyGroupFixture.cs @@ -99,14 +99,14 @@ public async Task TestGroupsAsync() [TestCase(true)] [TestCase(false)] - public async Task TestUpdateAsync(bool fetchBeforeUpdate, CancellationToken cancellationToken = default(CancellationToken)) + public async Task TestUpdateAsync(bool fetchBeforeUpdate) { Sfi.Statistics.Clear(); using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { - var person = await (s.GetAsync(1, cancellationToken)); + var person = await (s.GetAsync(1)); if (fetchBeforeUpdate) { var nickName = person.NickName; @@ -114,7 +114,7 @@ public async Task TestGroupsAsync() person.NickName = "test"; - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(1)); @@ -122,12 +122,12 @@ public async Task TestGroupsAsync() using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { - var person = await (s.GetAsync(1, cancellationToken)); + var person = await (s.GetAsync(1)); Assert.That(person.NickName, Is.EqualTo("test")); person.NickName = "NickName1"; // reset name - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } } diff --git a/src/NHibernate.Test/Async/LazyProperty/LazyPropertyFixture.cs b/src/NHibernate.Test/Async/LazyProperty/LazyPropertyFixture.cs index cb8dc0298de..3b4405eb6a7 100644 --- a/src/NHibernate.Test/Async/LazyProperty/LazyPropertyFixture.cs +++ b/src/NHibernate.Test/Async/LazyProperty/LazyPropertyFixture.cs @@ -21,7 +21,6 @@ namespace NHibernate.Test.LazyProperty { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class LazyPropertyFixtureAsync : TestCase { @@ -152,25 +151,25 @@ public async Task CanSetValueForLazyPropertyAsync() [TestCase(false)] [TestCase(true)] - public async Task CanUpdateValueForLazyPropertyAsync(bool initializeAfterSet, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CanUpdateValueForLazyPropertyAsync(bool initializeAfterSet) { Book book; using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { - book = await (s.GetAsync(1, cancellationToken)); + book = await (s.GetAsync(1)); book.ALotOfText = "update-text"; if (initializeAfterSet) { var image = book.Image; } - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } using (var s = OpenSession()) { - book = await (s.GetAsync(1, cancellationToken)); + book = await (s.GetAsync(1)); var text = book.ALotOfText; } @@ -182,14 +181,14 @@ public async Task CanSetValueForLazyPropertyAsync() [TestCase(false)] [TestCase(true)] - public async Task UpdateValueForLazyPropertyToSameValueAsync(bool initializeAfterSet, CancellationToken cancellationToken = default(CancellationToken)) + public async Task UpdateValueForLazyPropertyToSameValueAsync(bool initializeAfterSet) { Book book; string text; using (var s = OpenSession()) { - book = await (s.GetAsync(1, cancellationToken)); + book = await (s.GetAsync(1)); text = book.ALotOfText; } @@ -198,14 +197,14 @@ public async Task CanSetValueForLazyPropertyAsync() using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { - book = await (s.GetAsync(1, cancellationToken)); + book = await (s.GetAsync(1)); book.ALotOfText = text; if (initializeAfterSet) { var image = book.Image; } - await (tx.CommitAsync(cancellationToken)); + await (tx.CommitAsync()); } Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(initializeAfterSet ? 0 : 1)); @@ -215,7 +214,7 @@ public async Task CanSetValueForLazyPropertyAsync() using (var s = OpenSession()) { - book = await (s.GetAsync(1, cancellationToken)); + book = await (s.GetAsync(1)); text = book.ALotOfText; } diff --git a/src/NHibernate.Test/Async/Legacy/ABCProxyTest.cs b/src/NHibernate.Test/Async/Legacy/ABCProxyTest.cs index 135f8876840..3804e300925 100644 --- a/src/NHibernate.Test/Async/Legacy/ABCProxyTest.cs +++ b/src/NHibernate.Test/Async/Legacy/ABCProxyTest.cs @@ -275,39 +275,6 @@ public async Task SubclassMapAsync() s.Close(); } - [Test, Ignore("ANTLR parser : Not supported ")] - public async Task OnoToOneComparingAsync() - { - A a = new A(); - E d1 = new E(); - C1 c = new C1(); - E d2 = new E(); - a.Forward = d1; - d1.Reverse = a; - c.Forward = d2; - d2.Reverse = c; - - using (ISession s = OpenSession()) - using (ITransaction t = s.BeginTransaction()) - { - await (s.SaveAsync(a)); - await (s.SaveAsync(d2)); - await (t.CommitAsync()); - } - using (ISession s = OpenSession()) - { - IList l = await (s.CreateQuery("from E e, A a where e.Reverse = a.Forward and a = ?").SetEntity(0, a).ListAsync()); - Assert.AreEqual(1, l.Count); - } - using (ISession s = OpenSession()) - using (ITransaction t = s.BeginTransaction()) - { - await (s.DeleteAsync("from A")); - await (s.DeleteAsync("from E")); - await (t.CommitAsync()); - } - } - [Test] public async Task OneToOneAsync() { diff --git a/src/NHibernate.Test/Async/Legacy/SQLFunctionsTest.cs b/src/NHibernate.Test/Async/Legacy/SQLFunctionsTest.cs index 44a9c7d1556..ff9e5bf2d20 100644 --- a/src/NHibernate.Test/Async/Legacy/SQLFunctionsTest.cs +++ b/src/NHibernate.Test/Async/Legacy/SQLFunctionsTest.cs @@ -115,23 +115,6 @@ public async Task DialectSQLFunctionsAsync() s.Close(); } - [Test] - [Ignore("NH-3893 is not fixed")] - public async Task LeftAndRightAsync() - { - // As of NH-3893, left and right functions are broken. Seemed confused with join keyword, and not - // supported on Hibernate side. - using (var s = OpenSession()) - using (var t = s.BeginTransaction()) - { - var rset = await (s.CreateQuery("select left('abc', 2), right('abc', 2) from s in class Simple").ListAsync()); - var row = rset[0]; - Assert.AreEqual("ab", row[0], "Left function is broken."); - Assert.AreEqual("bc", row[1], "Right function is broken."); - await (t.CommitAsync()); - } - } - [Test] public async Task SetPropertiesAsync() { diff --git a/src/NHibernate.Test/Async/Legacy/SQLLoaderTest.cs b/src/NHibernate.Test/Async/Legacy/SQLLoaderTest.cs index ac6cef6520a..7edc752c28d 100644 --- a/src/NHibernate.Test/Async/Legacy/SQLLoaderTest.cs +++ b/src/NHibernate.Test/Async/Legacy/SQLLoaderTest.cs @@ -291,57 +291,6 @@ public async Task FindBySQLParametersAsync() s.Close(); } - [Test] - [Ignore("Escaping not implemented. Need to test with ODBC/OLEDB when implemented.")] - public async Task EscapedODBCAsync() - { - if (Dialect is MySQLDialect || Dialect is PostgreSQLDialect) return; - - ISession session = OpenSession(); - - A savedA = new A(); - savedA.Name = "Max"; - await (session.SaveAsync(savedA)); - - B savedB = new B(); - await (session.SaveAsync(savedB)); - await (session.FlushAsync()); - - session.Close(); - - session = OpenSession(); - - IQuery query; - - query = - session.CreateSQLQuery( - "select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.Count}, name as {a.Name} from A where {fn ucase(Name)} like {fn ucase('max')}") - .AddEntity("a", typeof(A)); - - // NH: Replaced the whole if by the line above - /* - if( dialect is Dialect.TimesTenDialect) - { - // TimesTen does not permit general expressions (like UPPER) in the second part of a LIKE expression, - // so we execute a similar test - query = session.CreateSQLQuery("select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.Count}, name as {a.Name} from A where {fn ucase(name)} like 'MAX'", "a", typeof( A )); - } - else - { - query = session.CreateSQLQuery("select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.Count}, name as {a.Name} from A where {fn ucase(name)} like {fn ucase('max')}", "a", typeof( A )); - } - */ - - IList list = await (query.ListAsync()); - - Assert.IsNotNull(list); - Assert.AreEqual(1, list.Count); - - await (session.DeleteAsync("from A")); - await (session.FlushAsync()); - session.Close(); - } - [Test] public async Task DoubleAliasingAsync() { diff --git a/src/NHibernate.Test/Async/Linq/BooleanMethodExtensionExample.cs b/src/NHibernate.Test/Async/Linq/BooleanMethodExtensionExample.cs deleted file mode 100644 index f08ca9aebe7..00000000000 --- a/src/NHibernate.Test/Async/Linq/BooleanMethodExtensionExample.cs +++ /dev/null @@ -1,55 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by AsyncGenerator. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; -using NHibernate.Cfg; -using NHibernate.Hql.Ast; -using NHibernate.Linq.Functions; -using NHibernate.Linq.Visitors; -using NHibernate.DomainModel.Northwind.Entities; -using NUnit.Framework; -using NHibernate.Util; -using NHibernate.Linq; - -namespace NHibernate.Test.Linq -{ - using System.Threading.Tasks; - - [TestFixture] - public class BooleanMethodExtensionExampleAsync : LinqTestCase - { - public class MyLinqToHqlGeneratorsRegistry : DefaultLinqToHqlGeneratorsRegistry - { - public MyLinqToHqlGeneratorsRegistry() - { - RegisterGenerator(ReflectHelper.GetMethodDefinition(() => BooleanLinqExtensions.FreeText(null, null)), - new FreetextGenerator()); - } - } - - protected override void Configure(Configuration configuration) - { - configuration.LinqToHqlGeneratorsRegistry(); - } - - [Test, Ignore("It work only with full-text indexes enabled.")] - public async Task CanUseMyCustomExtensionAsync() - { - List contacts = await ((from c in db.Customers where c.ContactName.FreeText("Thomas") select c).ToListAsync()); - Assert.That(contacts.Count, Is.GreaterThan(0)); - Assert.That(contacts.Select(c => c.ContactName).All(c => c.Contains("Thomas")), Is.True); - } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/Async/Linq/ByMethod/CastTests.cs b/src/NHibernate.Test/Async/Linq/ByMethod/CastTests.cs index 94f958ee645..0ddc287bd9d 100644 --- a/src/NHibernate.Test/Async/Linq/ByMethod/CastTests.cs +++ b/src/NHibernate.Test/Async/Linq/ByMethod/CastTests.cs @@ -57,14 +57,5 @@ public void OrderByAfterCastAsync() var query = session.Query().Cast().OrderBy(a=> a.BodyWeight); Assert.That(() => query.ToListAsync(), Throws.Nothing); } - - [Test, Ignore("Not fixed yet. The method OfType does not work as expected.")] - public void CastDowncastUsingOfTypeAsync() - { - var query = session.Query().OfType().Cast(); - // the list contains at least one Cat then should Throws - // Do not use bare Throws.Exception due to https://github.com/nunit/nunit/issues/1899 - Assert.That(() => query.ToListAsync(), Throws.InstanceOf()); - } } } diff --git a/src/NHibernate.Test/Async/Linq/ConstantTest.cs b/src/NHibernate.Test/Async/Linq/ConstantTest.cs index 718ac40fdc2..64d7037be80 100644 --- a/src/NHibernate.Test/Async/Linq/ConstantTest.cs +++ b/src/NHibernate.Test/Async/Linq/ConstantTest.cs @@ -25,19 +25,6 @@ namespace NHibernate.Test.Linq [TestFixture] public class ConstantTestAsync : LinqTestCase { - [Test] - [Ignore("Linq query not supported yet")] - public async Task ConstantNonCachedAsync() - { - var c1 = await ((from c in db.Customers - select "customer1").FirstAsync()); - - var c2 = await ((from c in db.Customers - select "customer2").FirstAsync()); - - Assert.That(c1, Is.EqualTo("customer1")); - Assert.That(c2, Is.EqualTo("customer2")); - } [Test] public async Task ConstantNonCachedInAnonymousNewExpressionAsync() diff --git a/src/NHibernate.Test/Async/Linq/JoinTests.cs b/src/NHibernate.Test/Async/Linq/JoinTests.cs index aeff80c56b4..4582dd7652b 100644 --- a/src/NHibernate.Test/Async/Linq/JoinTests.cs +++ b/src/NHibernate.Test/Async/Linq/JoinTests.cs @@ -285,21 +285,6 @@ public async Task OrderLinesWithSelectingCustomerIdInCaseShouldProduceOneJoinAsy } } - [Test(Description = "NH-3801"), Ignore("This is an ideal case, but not possible without better join detection")] - public async Task OrderLinesWithSelectingCustomerInCaseShouldProduceOneJoinAsync() - { - using (var spy = new SqlLogSpy()) - { - // Without nominating the conditional to the select clause (and placing it in SQL) - // [l.Order.Customer] will be selected in its entirety, creating a second join - await ((from l in db.OrderLines - select new { CustomerKnown = l.Order.Customer == null ? 0 : 1, l.Order.OrderDate }).ToListAsync()); - - var countJoins = CountJoins(spy); - Assert.That(countJoins, Is.EqualTo(1)); - } - } - [Test(Description = "NH-3801")] public async Task OrderLinesWithSelectingCustomerNameInCaseShouldProduceTwoJoinsAsync() { @@ -313,21 +298,6 @@ public async Task OrderLinesWithSelectingCustomerNameInCaseShouldProduceTwoJoins } } - [Test(Description = "NH-3801"), Ignore("This is an ideal case, but not possible without better join detection")] - public async Task OrderLinesWithSelectingCustomerNameInCaseShouldProduceTwoJoinsAlternateAsync() - { - using (var spy = new SqlLogSpy()) - { - // Without nominating the conditional to the select clause (and placing it in SQL) - // [l.Order.Customer] will be selected in its entirety, creating a second join - await ((from l in db.OrderLines - select new { CustomerKnown = l.Order.Customer == null ? "unknown" : l.Order.Customer.CompanyName, l.Order.OrderDate }).ToListAsync()); - - var countJoins = CountJoins(spy); - Assert.That(countJoins, Is.EqualTo(2)); - } - } - private static int CountJoins(LogSpy sqlLog) { return Count(sqlLog, "join"); diff --git a/src/NHibernate.Test/Async/Linq/LinqQuerySamples.cs b/src/NHibernate.Test/Async/Linq/LinqQuerySamples.cs index 736ba204739..45ebaa923ab 100644 --- a/src/NHibernate.Test/Async/Linq/LinqQuerySamples.cs +++ b/src/NHibernate.Test/Async/Linq/LinqQuerySamples.cs @@ -135,131 +135,6 @@ from c in db.Customers await (ObjectDumper.WriteAsync(q, 1)); } - [Category("SELECT/DISTINCT")] - [Test(Description = "This sample uses nested queries to return a sequence of " + - "all orders containing their OrderId, a subsequence of the " + - "items in the order where there is a discount, and the money " + - "saved if shipping is not included.")] - [Ignore("TODO - nested select")] - public async Task DLinq17Async() - { - using (ISession s = OpenSession()) - { - ///////////// - ///// Flattened Select - ///////////// - - //// In HQL select, get all the data that's needed - //var dbOrders = - // s.CreateQuery("select o.OrderId, od, o.Freight from Order o join o.OrderLines od").List(); - - //// Now group by the items in the parent select, grouping the items in the child select (note lookups on object[], ala SelectClauseVisitor) - //// Note the casts to get the types correct. Need to check if SelectClauseVisitor handles that, but think it does - //var a = from o in dbOrders - // group new { OrderLine = (OrderLine)o[1], Freight = (Decimal?)o[2] } by new { OrderId = (int) o[0] } - // into g - // select - // // Select the parent items, and the child items in a nested select - // new { g.Key.OrderId, DiscountedProducts = from e in g select new { e.OrderLine, FreeShippingDiscount = e.Freight } }; - - //a.ToList(); - - ///////////// - ///// Nested Select - ///////////// - //var dbOrders2 = s.CreateQuery("select o.OrderId from Order o").List(); - - //var q2 = from o in dbOrders2 - // select new - // { - // OrderId = o, - // DiscountedProducts = - // from subO in db.Orders - // where subO.OrderId == o - // from orderLine in subO.OrderLines - // select new { orderLine, FreeShippingDiscount = subO.Freight } - // }; - - //q2.ToList(); - - /////////// - ///// Batching Select - /////////// - var dbOrders3 = await (s.CreateQuery("select o.OrderId from Order o").ListAsync()); - - //var q3 = dbOrders3.SubQueryBatcher(orderId => orderId, - // ids => from subO in db.Orders.ToList() // Note that ToList is just because current group by code is incorrent in our linq provider - // where ids.Contains(subO.OrderId) - // from orderLine in subO.OrderLines - // group new {orderLine, FreeShippingDiscount = subO.Freight} - // by subO.OrderId - // into g - // select g - // ) - // .Select((input, index) => new - // { - // OrderId = input.Item, - // DiscountedProducts = input.Batcher.GetData(index) - // }); - - // This is what we want: - //var q3 = dbOrders3.SubQueryBatcher(orderId => orderId, - // ids => db.Orders - // .Where(o => ids.Contains(o.OrderId)) - // .Select(o => new {o.OrderId, o.OrderLines, o.Freight}).ToList() - // .GroupBy(k => k.OrderId, e => new { e.OrderLines, FreeShippingDiscount = e.Freight}) - // ) - // .Select((input, index) => new - // { - // OrderId = input.Item, - // DiscountedProducts = input.Batcher.GetData(index) - // }); - - // This is what we're using since our provider can't yet handle the in or the group by clauses correctly (note the ToList and the Where clause moving to get us into Linq to Objects world) - var q3 = dbOrders3.SubQueryBatcher(orderId => orderId, - ids => - (from o in db.Orders - from ol in o.OrderLines - select new { OrderLines = ol, FreeShippingDiscount = o.Freight, o.OrderId }) - .ToList() - .Where(o => ids.Contains(o.OrderId)) - .GroupBy(k => k.OrderId, e => new { e.OrderLines, e.FreeShippingDiscount }) - ) - .Select((input, index) => new - { - OrderId = input.Item, - DiscountedProducts = input.Batcher.GetData(index) - }); - - - foreach (var x in q3) - { - Console.WriteLine(x.OrderId); - - foreach (var y in x.DiscountedProducts) - { - Console.WriteLine(y.FreeShippingDiscount); - } - } - - q3.ToList(); - } - - var q = - from o in db.Orders - select new - { - o.OrderId, - DiscountedProducts = - from od in o.OrderLines -// from od in o.OrderLines.Cast() - where od.Discount > 0.0m - select od, FreeShippingDiscount = o.Freight - }; - - await (ObjectDumper.WriteAsync(q, 1)); - } - [Category("SELECT/DISTINCT")] [Test(Description = "This sample uses nested queries to return a sequence of " + "all orders containing their OrderId, a subsequence of the " + @@ -282,31 +157,6 @@ where od.Discount > 0.0m await (ObjectDumper.WriteAsync(q, 1)); } - [Category("SELECT/DISTINCT")] - [Test(Description = "This sample uses nested queries to return a sequence of " + - "all orders containing their OrderId, a subsequence of the " + - "items in the order where there is a discount, and the money " + - "saved if shipping is not included.")] - [Ignore("TODO - nested select")] - public async Task DLinq17cAsync() - { - var q = - from o in db.Orders - select new - { - o.OrderId, - DiscountedProducts = - from od in o.OrderLines -// from od in o.OrderLines.Cast() - where od.Discount > 0.0m - orderby od.Discount descending - select od, - FreeShippingDiscount = o.Freight - }; - - await (ObjectDumper.WriteAsync(q, 1)); - } - [Category("SELECT/DISTINCT")] [Test(Description = "This sample uses Distinct to select a sequence of the unique cities " + "that have Customers.")] @@ -369,64 +219,6 @@ public async Task DLinq24Async() Console.WriteLine(q); } - [Category("COUNT/SUM/MIN/MAX/AVG")] - [Test(Description = "This sample uses Min to find the Products that have the lowest unit price " + - "in each category.")] - [Ignore("TODO nested aggregating group by")] - public async Task DLinq25Async() - { - using (var session = OpenSession()) - { - var output = (await (session - .CreateQuery( - "select p.Category.CategoryId, p from Product p where p.UnitPrice = (select min(p2.UnitPrice) from Product p2 where p.Category.CategoryId = p2.Category.CategoryId)" - ) - .ListAsync())) - .GroupBy(input => input[0]) - .Select(input => new {CategoryId = (int) input.Key, CheapestProducts = from g in input select (Product) g[1]}); - } - - /* - * From g, only using g.Key, min(UnitPrice), g - * - g.Key is fine - * - min(UnitPrice) is fine - * - g is the problem. Can't just issue a single select since it's non-aggregating - * However, don't want to loose the aggregate; need that processed in the DB - * - * To get additional information over and above g.Key and any aggregates, need a where clause against the aggregate: - * - * select xxx, yyy, zzz from Product p where p.UnitPrice = (select min(p2.UnitPrice) from Product p2) - * - * the outer where comes from the inner where in the queryModel: - * - * where p2.UnitPrice == g.Min(p3 => p3.UnitPrice) - * - * also need additional constraints on the aggregate to fulfil the groupby requirements: - * - * where p.Category.CategoryId = p2.Category.CategoryId - * - * so join the inner select to the outer select using the group by criteria - * - * finally, need to do some client-side processing to get the "shape" correct - * - */ - - var categories = - from p in db.Products - group p by p.Category.CategoryId - into g - select new - { - CategoryId = g.Key, - CheapestProducts = - (IEnumerable) (from p2 in g - where p2.UnitPrice == g.Min(p3 => p3.UnitPrice) - select p2) - }; - - Console.WriteLine(await (ObjectDumper.WriteAsync(categories, 1))); - } - [Category("COUNT/SUM/MIN/MAX/AVG")] [Test(Description = "This sample uses Max to find the latest hire date of any Employee.")] public async Task DLinq26Async() @@ -443,28 +235,6 @@ public async Task DLinq27Async() Console.WriteLine(q); } - [Category("COUNT/SUM/MIN/MAX/AVG")] - [Test(Description = "This sample uses Max to find the Products that have the highest unit price " + - "in each category.")] - [Ignore("TODO nested aggregating group by")] - public async Task DLinq28Async() - { - var categories = - from p in db.Products - group p by p.Category.CategoryId - into g - select new - { - g.Key, - MostExpensiveProducts = - from p2 in g - where p2.UnitPrice == g.Max(p3 => p3.UnitPrice) - select p2 - }; - - await (ObjectDumper.WriteAsync(categories, 1)); - } - [Category("COUNT/SUM/MIN/MAX/AVG")] [Test(Description = "This sample uses Average to find the average freight of all Orders.")] public async Task DLinq29Async() @@ -481,28 +251,6 @@ public async Task DLinq30Async() Console.WriteLine(q); } - [Category("COUNT/SUM/MIN/MAX/AVG")] - [Test(Description = "This sample uses Average to find the Products that have unit price higher than " + - "the average unit price of the category for each category.")] - [Ignore("TODO nested aggregating group by")] - public async Task DLinq31Async() - { - var categories = - from p in db.Products - group p by p.Category.CategoryId - into g - select new - { - g.Key, - ExpensiveProducts = - from p2 in g - where p2.UnitPrice > g.Average(p3 => p3.UnitPrice) - select p2 - }; - - await (ObjectDumper.WriteAsync(categories, 1)); - } - [Category("ORDER BY")] [Test(Description = "This sample uses orderby to sort Employees by hire date.")] public async Task DLinq36Async() @@ -569,30 +317,6 @@ from o in db.Orders await (ObjectDumper.WriteAsync(q)); } - - [Category("ORDER BY")] - [Test(Description = "This sample uses Orderby, Max and Group By to find the Products that have " + - "the highest unit price in each category, and sorts the group by category id.")] - [Ignore("TODO nested aggregating group by")] - public async Task DLinq41Async() - { - var categories = - from p in db.Products - group p by p.Category.CategoryId - into g - orderby g.Key - select new - { - g.Key, - MostExpensiveProducts = - from p2 in g - where p2.UnitPrice == g.Max(p3 => p3.UnitPrice) - select p2 - }; - - await (ObjectDumper.WriteAsync(categories, 1)); - } - [Category("GROUP BY/HAVING")] [Test(Description = "This sample uses group by to partition Products by " + "CategoryId.")] @@ -925,94 +649,6 @@ where c.Orders.All(o => o.ShippingAddress.City == c.Address.City) } } - [Category("UNION ALL/UNION/INTERSECT")] - [Test(Description = "This sample uses Concat to return a sequence of all Customer and Employee " + - "phone/fax numbers.")] - [Ignore("TODO set operations")] - public async Task DLinq55Async() - { - IQueryable q = ( - from c in db.Customers - select c.Address.PhoneNumber - ).Concat( - from c in db.Customers - select c.Address.Fax - ).Concat( - from e in db.Employees - select e.Address.PhoneNumber - ); - - await (ObjectDumper.WriteAsync(q)); - } - - [Category("UNION ALL/UNION/INTERSECT")] - [Test(Description = "This sample uses Concat to return a sequence of all Customer and Employee " + - "name and phone number mappings.")] - [Ignore("TODO set operations")] - public async Task DLinq56Async() - { - var q = ( - from c in db.Customers - select new {Name = c.CompanyName, Phone = c.Address.PhoneNumber} - ).Concat( - from e in db.Employees - select new {Name = e.FirstName + " " + e.LastName, Phone = e.Address.PhoneNumber} - ); - - await (ObjectDumper.WriteAsync(q)); - } - - [Category("UNION ALL/UNION/INTERSECT")] - [Test(Description = "This sample uses Union to return a sequence of all countries that either " + - "Customers or Employees are in.")] - [Ignore("TODO set operations")] - public async Task DLinq57Async() - { - IQueryable q = ( - from c in db.Customers - select c.Address.Country - ).Union( - from e in db.Employees - select e.Address.Country - ); - - await (ObjectDumper.WriteAsync(q)); - } - - [Category("UNION ALL/UNION/INTERSECT")] - [Test(Description = "This sample uses Intersect to return a sequence of all countries that both " + - "Customers and Employees live in.")] - [Ignore("TODO set operations")] - public async Task DLinq58Async() - { - IQueryable q = ( - from c in db.Customers - select c.Address.Country - ).Intersect( - from e in db.Employees - select e.Address.Country - ); - - await (ObjectDumper.WriteAsync(q)); - } - - [Category("UNION ALL/UNION/INTERSECT")] - [Test(Description = "This sample uses Except to return a sequence of all countries that " + - "Customers live in but no Employees live in.")] - [Ignore("TODO set operations")] - public async Task DLinq59Async() - { - IQueryable q = ( - from c in db.Customers - select c.Address.Country - ).Except( - from e in db.Employees - select e.Address.Country - ); - - await (ObjectDumper.WriteAsync(q)); - } - [Category("WHERE")] [Test(Description = "This sample uses First to select the first Shipper in the table.")] public async Task DLinq6Async() @@ -1350,23 +986,6 @@ join e in db.Employees on c.Address.City equals e.Address.City into emps await (ObjectDumper.WriteAsync(q)); } - [Category("JOIN")] - [Test( - Description = - "This sample shows how to get LEFT OUTER JOIN by using DefaultIfEmpty(). The DefaultIfEmpty() method returns null when there is no Order for the Employee." - )] - [Ignore("TODO left outer join")] - public async Task DLinqJoin7Async() - { - var q = - from e in db.Employees - join o in db.Orders on e equals o.Employee into ords - from o in ords.DefaultIfEmpty() - select new {e.FirstName, e.LastName, Order = o}; - - await (ObjectDumper.WriteAsync(q)); - } - [Category("JOIN")] [Test(Description = "This sample projects a 'let' expression resulting from a join.")] public async Task DLinqJoin8Async() diff --git a/src/NHibernate.Test/Async/Linq/PagingTests.cs b/src/NHibernate.Test/Async/Linq/PagingTests.cs index bce2a5d9ff8..6c72ddd1f4d 100644 --- a/src/NHibernate.Test/Async/Linq/PagingTests.cs +++ b/src/NHibernate.Test/Async/Linq/PagingTests.cs @@ -121,106 +121,6 @@ public async Task PageBetweenProjectionsReturningOrderedConstrainedNestedClassAs Assert.That(list, Has.Count.EqualTo(10)); } - [Test, Ignore("Not supported")] - public async Task PagedProductsWithOuterWhereClauseOrderedNestedAnonymousAsync() - { - // NH-2588 and NH-3326 - var inMemoryIds = (await (db.Products.ToListAsync())) - .OrderByDescending(x => x.ProductId) - .Select(p => new { p.ProductId, p.Name, p.UnitsInStock }) - .Skip(10).Take(20) - .Select(a => new { ExpandedElement = a, a.Name, a.ProductId }) - .Where(x => x.ProductId > 0) - .ToList(); - - var ids = await (db.Products - .OrderByDescending(x => x.ProductId) - .Select(p => new { p.ProductId, p.Name, p.UnitsInStock }) - .Skip(10).Take(20) - .Where(x => x.ProductId > 0) - .Select(a => new { ExpandedElement = a, a.Name, a.ProductId }) - .ToListAsync()); - - Assert.That(ids, Is.EqualTo(inMemoryIds)); - } - - [Test, Ignore("Not supported")] - public async Task PagedProductsWithOuterWhereClauseOrderedNestedAnonymousEquivalentAsync() - { - // NH-2588 and NH-3326 - var inMemoryIds = (await (db.Products.ToListAsync())) - .OrderByDescending(x => x.ProductId) - .Select(p => new { p.ProductId, p.Name, p.UnitsInStock }) - .Skip(10).Take(20) - .Select(a => new { ExpandedElement = a, a.Name, a.ProductId }) - .Where(x => x.ProductId > 0) - .ToList(); - - var subquery = db.Products - .OrderByDescending(x => x.ProductId) - .Select(p => new { p.ProductId, p.Name, p.UnitsInStock }) - .Skip(10).Take(20); - - var ids = await (db.Products - .Select(p => new { p.ProductId, p.Name, p.UnitsInStock }) - .Where(x => subquery.Contains(x)) - .Where(x => x.ProductId > 0) - .Select(a => new { ExpandedElement = a, a.Name, a.ProductId }) - .ToListAsync()); - - Assert.That(ids, Is.EqualTo(inMemoryIds)); - } - - [Test, Ignore("Not supported")] - public async Task PagedProductsWithOuterWhereClauseOrderedNestedClassAsync() - { - // NH-2588 and NH-3326 - var inMemoryIds = (await (db.Products.ToListAsync())) - .OrderByDescending(x => x.ProductId) - .Select(p => new ProductProjection { ProductId = p.ProductId, Name = p.Name }) - .Skip(10).Take(20) - .Select(a => new { ExpandedElement = a, a.Name, a.ProductId }) - .Where(x => x.ProductId > 0) - .ToList(); - - var ids = await (db.Products - .OrderByDescending(x => x.ProductId) - .Select(p => new ProductProjection { ProductId = p.ProductId, Name = p.Name }) - .Skip(10).Take(20) - .Select(a => new { ExpandedElement = a, a.Name, a.ProductId }) - .Where(x => x.ProductId > 0) - .ToListAsync()); - - Assert.That(ids, Is.EqualTo(inMemoryIds)); - } - - [Test, Ignore("Not supported")] - public async Task PagedProductsWithOuterWhereClauseOrderedNestedClassEquivalentAsync() - { - // NH-2588 and NH-3326 - var inMemoryIds = (await (db.Products.ToListAsync())) - .OrderByDescending(x => x.ProductId) - .Select(p => new ProductProjection { ProductId = p.ProductId, Name = p.Name }) - .Skip(10).Take(20) - .Select(a => new { ExpandedElement = a, a.Name, a.ProductId }) - .Where(x => x.ProductId > 0) - .ToList(); - - var subquery = db.Products - .OrderByDescending(x => x.ProductId) - .Select(p => new ProductProjection { ProductId = p.ProductId, Name = p.Name }) - .Skip(10).Take(20); - - var ids = await (db.Products - .Select(p => new ProductProjection { ProductId = p.ProductId, Name = p.Name }) - .Where(x => subquery.Contains(x)) - .Where(x => x.ProductId > 0) - .Select(a => new { ExpandedElement = a, a.Name, a.ProductId }) - .ToListAsync()); - - Assert.That(ids, Is.EqualTo(inMemoryIds)); - } - [Test] public async Task Customers1to5Async() { @@ -262,39 +162,6 @@ orderby c.CustomerId Assert.AreEqual(20, query.Count); } - [Test] - [Ignore("Multiple Takes (or Skips) not handled correctly")] - public async Task CustomersChainedTakeAsync() - { - var q = (from c in db.Customers - orderby c.CustomerId - select c.CustomerId).Take(5).Take(6); - - var query = await (q.ToListAsync()); - - Assert.AreEqual(5, query.Count); - Assert.AreEqual("ALFKI", query[0]); - Assert.AreEqual("BLAUS", query[4]); - } - - [Test] - [Ignore("Multiple Takes (or Skips) not handled correctly")] - public async Task CustomersChainedSkipAsync() - { - var q = (from c in db.Customers select c.CustomerId).Skip(10).Skip(5); - var query = await (q.ToListAsync()); - Assert.AreEqual(query[0], "CONSH"); - Assert.AreEqual(76, query.Count); - } - - [Test] - [Ignore("Count with Skip or Take is incorrect (Skip / Take done on the query not the HQL, so get applied at the wrong point")] - public async Task CountAfterTakeShouldReportTheCorrectNumberAsync() - { - var users = db.Customers.Skip(3).Take(10); - Assert.AreEqual(10, await (users.CountAsync())); - } - [Test] public async Task OrderedPagedProductsWithOuterProjectionAsync() { diff --git a/src/NHibernate.Test/Async/Linq/WhereSubqueryTests.cs b/src/NHibernate.Test/Async/Linq/WhereSubqueryTests.cs index 7ec1685319a..70047db447d 100644 --- a/src/NHibernate.Test/Async/Linq/WhereSubqueryTests.cs +++ b/src/NHibernate.Test/Async/Linq/WhereSubqueryTests.cs @@ -113,34 +113,6 @@ public async Task TimeSheetsWithAverageSubqueryReversedAsync() Assert.That(query.Count, Is.EqualTo(1)); } - [Test] - [Ignore("Need to coalesce the subquery - timesheet with no entries should return average of 0, not null")] - public async Task TimeSheetsWithAverageSubqueryComparedToPropertyAsync() - { - if (!Dialect.SupportsScalarSubSelects) - Assert.Ignore(Dialect.GetType().Name + " does not support scalar sub-queries"); - - var query = await ((from timesheet in db.Timesheets - where timesheet.Entries.Average(e => e.NumberOfHours) < timesheet.Id - select timesheet).ToListAsync()); - - Assert.That(query.Count, Is.EqualTo(1)); - } - - [Test] - [Ignore("Need to coalesce the subquery - timesheet with no entries should return average of 0, not null")] - public async Task TimeSheetsWithAverageSubqueryComparedToPropertyReversedAsync() - { - if (!Dialect.SupportsScalarSubSelects) - Assert.Ignore(Dialect.GetType().Name + " does not support scalar sub-queries"); - - var query = await ((from timesheet in db.Timesheets - where timesheet.Id > timesheet.Entries.Average(e => e.NumberOfHours) - select timesheet).ToListAsync()); - - Assert.That(query.Count, Is.EqualTo(1)); - } - [Test] public async Task TimeSheetsWithMaxSubqueryAsync() { @@ -271,34 +243,6 @@ public async Task TimeSheetsWithSumSubqueryReversedAsync() Assert.That(query.Count, Is.EqualTo(1)); } - [Test] - [Ignore("Need to coalesce the subquery - timesheet with no entries should return sum of 0, not null")] - public async Task TimeSheetsWithSumSubqueryComparedToPropertyAsync() - { - if (!Dialect.SupportsScalarSubSelects) - Assert.Ignore(Dialect.GetType().Name + " does not support scalar sub-queries"); - - var query = await ((from timesheet in db.Timesheets - where timesheet.Entries.Sum(e => e.NumberOfHours) <= timesheet.Id - select timesheet).ToListAsync()); - - Assert.That(query.Count, Is.EqualTo(1)); - } - - [Test] - [Ignore("Need to coalesce the subquery - timesheet with no entries should return sum of 0, not null")] - public async Task TimeSheetsWithSumSubqueryComparedToPropertyReversedAsync() - { - if (!Dialect.SupportsScalarSubSelects) - Assert.Ignore(Dialect.GetType().Name + " does not support scalar sub-queries"); - - var query = await ((from timesheet in db.Timesheets - where timesheet.Id >= timesheet.Entries.Sum(e => e.NumberOfHours) - select timesheet).ToListAsync()); - - Assert.That(query.Count, Is.EqualTo(1)); - } - [Test] public async Task TimeSheetsWithStringContainsSubQueryAsync() { @@ -592,21 +536,6 @@ where categories.Contains(p.Category) Assert.That(result.Count, Is.EqualTo(13)); } - [Test(Description = "NH-3155"), Ignore("Not fixed yet.")] - public async Task SubqueryWithGroupByAsync() - { - var sq = db.Orders - .GroupBy(x => x.ShippingDate) - .Select(x => x.Max(o => o.OrderId)); - - var result = await (db.Orders - .Where(x => sq.Contains(x.OrderId)) - .Select(x => x.OrderId) - .ToListAsync()); - - Assert.That(result.Count, Is.EqualTo(388)); - } - [Test(Description = "NH-3111")] public async Task SubqueryWhereFailingTestAsync() { @@ -709,28 +638,6 @@ where c.Products.OrderBy(p => p.ProductId).Select(p => p.Discontinued).FirstOrDe Assert.That(result.Count, Is.EqualTo(7)); } - [Test(Description = "NH-3190")] - [Ignore("Not fixed yet.")] - public async Task ProductsWithSubqueryReturningProjectionBoolFirstOrDefaultEqAsync() - { - if (!Dialect.SupportsScalarSubSelects) - Assert.Ignore(Dialect.GetType().Name + " does not support scalar sub-queries"); - - if (!TestDialect.SupportsOrderByAndLimitInSubQueries) - Assert.Ignore("Dialect does not support sub-selects with order by or limit/top"); - - //NH-3190 - var result = await ((from p in db.Products - where (from c in db.Categories - where c.Name == "Confections" - && c == p.Category - select new{R=p.Discontinued}).FirstOrDefault().R == false - select p) - .ToListAsync()); - - Assert.That(result.Count, Is.EqualTo(13)); - } - [Test(Description = "NH-3190")] public async Task ProductsWithSubqueryReturningStringFirstOrDefaultEqAsync() { diff --git a/src/NHibernate.Test/Async/Linq/WhereTests.cs b/src/NHibernate.Test/Async/Linq/WhereTests.cs index c5a293f03d9..5f09970ea4c 100644 --- a/src/NHibernate.Test/Async/Linq/WhereTests.cs +++ b/src/NHibernate.Test/Async/Linq/WhereTests.cs @@ -510,19 +510,6 @@ where names.Contains(user.Name) Assert.That(query.Count, Is.EqualTo(0)); } - [Test] - [Ignore("Inline empty list expression does not evaluate correctly")] - public async Task UsersWithEmptyInlineEnumerableAsync() - { - var allNames = new List { "ayende", "rahien" }; - - var query = await ((from user in db.Users - where allNames.Where(n => n == "does not exist").Contains(user.Name) - select user).ToListAsync()); - - Assert.That(query.Count, Is.EqualTo(0)); - } - [Test] public void WhenTheSourceOfConstantIsICollectionThenNoThrowsAsync() { diff --git a/src/NHibernate.Test/Async/NHSpecificTest/CriteriaQueryOnComponentCollection/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/CriteriaQueryOnComponentCollection/Fixture.cs index 71e0c986851..0e37f90e566 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/CriteriaQueryOnComponentCollection/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/CriteriaQueryOnComponentCollection/Fixture.cs @@ -19,7 +19,6 @@ namespace NHibernate.Test.NHSpecificTest.CriteriaQueryOnComponentCollection { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class FixtureAsync : TestCase { @@ -109,7 +108,7 @@ public async Task CanQueryByCriteriaOnSetOfElementAsync() [TestCase(JoinType.LeftOuterJoin)] [TestCase(JoinType.InnerJoin)] - public async Task CanQueryByCriteriaOnSetOfElementByCreateAliasAsync(JoinType joinType, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CanQueryByCriteriaOnSetOfElementByCreateAliasAsync(JoinType joinType) { using (var s = Sfi.OpenSession()) { @@ -117,7 +116,7 @@ public async Task CanQueryByCriteriaOnSetOfElementAsync() .CreateAlias("x.Amounts", "amount", joinType) .Add(Restrictions.Gt("amount.Amount", 5m)) .SetResultTransformer(new RootEntityResultTransformer()) - .ListAsync(cancellationToken)); + .ListAsync()); Assert.That(list, Has.Count.EqualTo(1)); Assert.That(list[0], Is.Not.Null); Assert.That(list[0], Is.TypeOf()); diff --git a/src/NHibernate.Test/Async/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/Fixture.cs index 29ac552b705..a8051706adc 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/Fixture.cs @@ -96,21 +96,6 @@ public async Task EqualityWorksForUserTypeAsync() } } - [Test, Ignore("Not implemented yet")] - public async Task LinqMethodWorksForUserTypeAsync() - { - using (var session = OpenSession()) - using (session.BeginTransaction()) - { - var newItem = new BarExample { Value = "Larry" }; - var entities = await (session.Query() - .Where(x => x.Example.IsEquivalentTo(newItem)) - .ToListAsync()); - - Assert.AreEqual(2, entities.Count); - } - } - [Test] public async Task EqualityWorksForExplicitUserTypeAsync() { diff --git a/src/NHibernate.Test/Async/NHSpecificTest/GH1300/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/GH1300/Fixture.cs index 11f20de84c2..3ead1a0369d 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/GH1300/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/GH1300/Fixture.cs @@ -25,7 +25,6 @@ namespace NHibernate.Test.NHSpecificTest.GH1300 { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class FixtureAsync : BugTestCase { @@ -121,7 +120,7 @@ public void InsertWithTooLongValuesShouldThrowAsync() [TestCase("Name", SqlDbType.NVarChar)] [TestCase("AnsiName", SqlDbType.VarChar)] - public async Task LinqEqualsShouldUseMappedSizeAsync(string property, SqlDbType expectedDbType, CancellationToken cancellationToken = default(CancellationToken)) + public async Task LinqEqualsShouldUseMappedSizeAsync(string property, SqlDbType expectedDbType) { Driver.ClearCommands(); @@ -130,11 +129,11 @@ public void InsertWithTooLongValuesShouldThrowAsync() { if (property == "Name") { - await (session.Query().Where(x => x.Name == "Bob").ToListAsync(cancellationToken)); + await (session.Query().Where(x => x.Name == "Bob").ToListAsync()); } else { - await (session.Query().Where(x => x.AnsiName == "Bob").ToListAsync(cancellationToken)); + await (session.Query().Where(x => x.AnsiName == "Bob").ToListAsync()); } Assert.That(Driver.LastCommandParameters.First().Size, Is.EqualTo(3)); Assert.That(Driver.LastCommandParameters.First().SqlDbType, Is.EqualTo(expectedDbType)); @@ -158,14 +157,14 @@ public async Task MappedAsShouldUseExplicitSizeAsync() [TestCase("Name", SqlDbType.NVarChar)] [TestCase("AnsiName", SqlDbType.VarChar)] - public async Task HqlLikeShouldUseLargerSizeAsync(string property, SqlDbType expectedDbType, CancellationToken cancellationToken = default(CancellationToken)) + public async Task HqlLikeShouldUseLargerSizeAsync(string property, SqlDbType expectedDbType) { Driver.ClearCommands(); using (var session = OpenSession()) using (var transaction = session.BeginTransaction()) { - await (session.CreateQuery("from Entity where " + property + " like :name").SetParameter("name", "%Bob%").ListAsync(cancellationToken)); + await (session.CreateQuery("from Entity where " + property + " like :name").SetParameter("name", "%Bob%").ListAsync()); Assert.That(Driver.LastCommandParameters.First().Size, Is.GreaterThanOrEqualTo(5)); Assert.That(Driver.LastCommandParameters.First().SqlDbType, Is.EqualTo(expectedDbType)); @@ -174,7 +173,7 @@ public async Task MappedAsShouldUseExplicitSizeAsync() [TestCase("Name", SqlDbType.NVarChar)] [TestCase("AnsiName", SqlDbType.VarChar)] - public async Task CriteriaEqualsShouldUseMappedSizeAsync(string property, SqlDbType expectedDbType, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CriteriaEqualsShouldUseMappedSizeAsync(string property, SqlDbType expectedDbType) { Driver.ClearCommands(); @@ -184,7 +183,7 @@ public async Task MappedAsShouldUseExplicitSizeAsync() Driver.ClearCommands(); await (session.CreateCriteria().Add(Restrictions.Eq(property, "Bob")) - .ListAsync(cancellationToken)); + .ListAsync()); Assert.That(Driver.LastCommandParameters.First().Size, Is.GreaterThanOrEqualTo(3)); Assert.That(Driver.LastCommandParameters.First().SqlDbType, Is.EqualTo(expectedDbType)); @@ -193,7 +192,7 @@ public async Task MappedAsShouldUseExplicitSizeAsync() [TestCase("Name", SqlDbType.NVarChar)] [TestCase("AnsiName", SqlDbType.VarChar)] - public async Task CriteriaLikeShouldUseLargerSizeAsync(string property, SqlDbType expectedDbType, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CriteriaLikeShouldUseLargerSizeAsync(string property, SqlDbType expectedDbType) { Driver.ClearCommands(); @@ -201,7 +200,7 @@ public async Task MappedAsShouldUseExplicitSizeAsync() using (var transaction = session.BeginTransaction()) { await (session.CreateCriteria().Add(Restrictions.Like(property, "%Bob%")) - .ListAsync(cancellationToken)); + .ListAsync()); Assert.That(Driver.LastCommandParameters.First().Size, Is.GreaterThanOrEqualTo(5)); Assert.That(Driver.LastCommandParameters.First().SqlDbType, Is.EqualTo(expectedDbType)); diff --git a/src/NHibernate.Test/Async/NHSpecificTest/GH1920/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/GH1920/Fixture.cs index 75693b26430..e740a2abd59 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/GH1920/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/GH1920/Fixture.cs @@ -14,7 +14,6 @@ namespace NHibernate.Test.NHSpecificTest.GH1920 { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class FixtureAsync : BugTestCase { @@ -35,15 +34,15 @@ protected override void OnSetUp() [TestCase(true)] [TestCase(false)] - public async Task CanLoadEntityAsync(bool loadProxyOfOtherEntity, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CanLoadEntityAsync(bool loadProxyOfOtherEntity) { using (var session = OpenSession()) using (session.BeginTransaction()) { if (loadProxyOfOtherEntity) - await (session.LoadAsync(someOtherEntityId, cancellationToken)); + await (session.LoadAsync(someOtherEntityId)); - var result = await (session.GetAsync(entityId, cancellationToken)); + var result = await (session.GetAsync(entityId)); Assert.That(result.Name, Is.Not.Null); } diff --git a/src/NHibernate.Test/Async/NHSpecificTest/GH1921/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/GH1921/Fixture.cs index 06469395f15..b8575b49ed4 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/GH1921/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/GH1921/Fixture.cs @@ -15,7 +15,6 @@ namespace NHibernate.Test.NHSpecificTest.GH1921 { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class FixtureAsync : BugTestCase { @@ -105,7 +104,7 @@ public async Task DmlDeleteAsync(bool filtered) [TestCase(null)] [TestCase("NameFilter")] [TestCase("OtherNameFilter")] - public async Task MultiTableDmlInsertAsync(string filter, CancellationToken cancellationToken = default(CancellationToken)) + public async Task MultiTableDmlInsertAsync(string filter) { var isFiltered = !string.IsNullOrEmpty(filter); @@ -119,8 +118,8 @@ public async Task DmlDeleteAsync(bool filtered) .CreateQuery( // No insert of OtherName: not supported (INSERT statements cannot refer to superclass/joined properties) "insert into MultiTableEntity (Name) select e.Name from MultiTableEntity e") - .ExecuteUpdateAsync(cancellationToken)); - await (transaction.CommitAsync(cancellationToken)); + .ExecuteUpdateAsync()); + await (transaction.CommitAsync()); Assert.That(rowCount, Is.EqualTo(isFiltered ? 1 : 2), "ResultCount"); } @@ -129,19 +128,19 @@ public async Task DmlDeleteAsync(bool filtered) using (var transaction = session.BeginTransaction()) { Assert.That( - await (session.Query().CountAsync(e => e.Name != "Bob", cancellationToken)), + await (session.Query().CountAsync(e => e.Name != "Bob")), Is.EqualTo(isFiltered ? 1 : 2), "Name != \"Bob\""); Assert.That( - await (session.Query().CountAsync(e => e.OtherName == null, cancellationToken)), + await (session.Query().CountAsync(e => e.OtherName == null)), Is.EqualTo(isFiltered ? 1 : 2), "OtherName is null"); - await (transaction.CommitAsync(cancellationToken)); + await (transaction.CommitAsync()); } } [TestCase(null)] [TestCase("NameFilter")] [TestCase("OtherNameFilter")] - public async Task MultiTableDmlUpdateAsync(string filter, CancellationToken cancellationToken = default(CancellationToken)) + public async Task MultiTableDmlUpdateAsync(string filter) { var isFiltered = !string.IsNullOrEmpty(filter); @@ -157,8 +156,8 @@ public async Task DmlDeleteAsync(bool filtered) " set Name = 'newName', OtherName = 'newOtherName'" + // Check referencing columns is supported " where e.Name is not null and e.OtherName is not null") - .ExecuteUpdateAsync(cancellationToken)); - await (transaction.CommitAsync(cancellationToken)); + .ExecuteUpdateAsync()); + await (transaction.CommitAsync()); Assert.That(rowCount, Is.EqualTo(isFiltered ? 1 : 2), "ResultCount"); } @@ -167,19 +166,19 @@ public async Task DmlDeleteAsync(bool filtered) using (var transaction = session.BeginTransaction()) { Assert.That( - await (session.Query().CountAsync(e => e.Name == "newName", cancellationToken)), + await (session.Query().CountAsync(e => e.Name == "newName")), Is.EqualTo(isFiltered ? 1 : 2), "Name == \"newName\""); Assert.That( - await (session.Query().CountAsync(e => e.OtherName == "newOtherName", cancellationToken)), + await (session.Query().CountAsync(e => e.OtherName == "newOtherName")), Is.EqualTo(isFiltered ? 1 : 2), "Name == \"newOtherName\""); - await (transaction.CommitAsync(cancellationToken)); + await (transaction.CommitAsync()); } } [TestCase(null)] [TestCase("NameFilter")] [TestCase("OtherNameFilter")] - public async Task MultiTableDmlDeleteAsync(string filter, CancellationToken cancellationToken = default(CancellationToken)) + public async Task MultiTableDmlDeleteAsync(string filter) { var isFiltered = !string.IsNullOrEmpty(filter); @@ -194,8 +193,8 @@ public async Task DmlDeleteAsync(bool filtered) "delete MultiTableEntity e" + // Check referencing columns is supported " where e.Name is not null and e.OtherName is not null") - .ExecuteUpdateAsync(cancellationToken)); - await (transaction.CommitAsync(cancellationToken)); + .ExecuteUpdateAsync()); + await (transaction.CommitAsync()); Assert.That(rowCount, Is.EqualTo(isFiltered ? 1 : 2), "ResultCount"); } @@ -204,12 +203,12 @@ public async Task DmlDeleteAsync(bool filtered) using (var transaction = session.BeginTransaction()) { Assert.That( - await (session.Query().CountAsync(e => e.Name != "Bob", cancellationToken)), + await (session.Query().CountAsync(e => e.Name != "Bob")), Is.EqualTo(isFiltered ? 1 : 0), "Name != \"Bob\""); Assert.That( - await (session.Query().CountAsync(e => e.OtherName != "Bob", cancellationToken)), + await (session.Query().CountAsync(e => e.OtherName != "Bob")), Is.EqualTo(isFiltered ? 1 : 0), "OtherName != \"Bob\""); - await (transaction.CommitAsync(cancellationToken)); + await (transaction.CommitAsync()); } } } diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH1001/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH1001/Fixture.cs index f49893b5472..fce42a9f7ba 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH1001/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH1001/Fixture.cs @@ -255,20 +255,6 @@ public async Task Department5IsNullAsync() } } - [Test, Ignore("Not fixed yet")] - public void Department5IsNotFoundAsync() - { - var statistics = Sfi.Statistics; - statistics.Clear(); - - using (var session = OpenSession()) - using(var transaction = session.BeginTransaction()) - { - ExecuteStatement(session, transaction, $"UPDATE EMPLOYEES SET DEPARTMENT_ID_1 = 11, DEPARTMENT_ID_2 = 12, DEPARTMENT_ID_3 = 13, DEPARTMENT_ID_4 = 24, DEPARTMENT_ID_5 = 99999, ADDRESS_ID = 31 WHERE EMPLOYEE_ID = {employeeId}"); - Assert.That(() => session.GetAsync(employeeId), Throws.InstanceOf()); - } - } - [Test] public async Task AddressNullAsync() { diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH1985/SampleTest.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH1985/SampleTest.cs index 83f1fca21a2..11839d59e4e 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH1985/SampleTest.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH1985/SampleTest.cs @@ -39,45 +39,6 @@ protected override void OnTearDown() ExecuteStatement("DELETE FROM DomainClass WHERE Id=1;"); } - - [Test] - [Ignore("It is valid to delete immutable entities")] - public async Task AttemptToDeleteImmutableObjectShouldThrowAsync() - { - using (ISession session = OpenSession()) - { - Assert.ThrowsAsync(async () => - { - using (ITransaction trans = session.BeginTransaction()) - { - var entity = await (session.GetAsync(1)); - await (session.DeleteAsync(entity)); - - await (trans.CommitAsync()); // This used to throw... - } - }); - } - - using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties)) - { - var conn = await (prov.GetConnectionAsync(CancellationToken.None)); - - try - { - using (var comm = conn.CreateCommand()) - { - comm.CommandText = "SELECT Id FROM DomainClass WHERE Id=1 AND Label='TEST record'"; - object result = await (comm.ExecuteScalarAsync()); - - Assert.That(result != null, "Immutable object has been deleted!"); - } - } - finally - { - prov.CloseConnection(conn); - } - } - } [Test] public async Task AllowDeletionOfImmutableObjectAsync() diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2208/Filter.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2208/Filter.cs deleted file mode 100644 index 3677f3c3428..00000000000 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2208/Filter.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by AsyncGenerator. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - - -using NUnit.Framework; - -namespace NHibernate.Test.NHSpecificTest.NH2208 -{ - using System.Threading.Tasks; - [TestFixture] - public class FilterAsync : BugTestCase - { - [Test, Ignore("Not fixed yet")] - public async Task TestAsync() - { - using (ISession session = OpenSession()) - { - session.EnableFilter("myfilter"); - await (session.CreateQuery("from E1 e join fetch e.BO").ListAsync()); - } - } - } -} diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2294/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2294/Fixture.cs deleted file mode 100644 index 905cd3b3645..00000000000 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2294/Fixture.cs +++ /dev/null @@ -1,32 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by AsyncGenerator. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - - -using System.Linq; -using NHibernate.Hql.Ast.ANTLR; -using NUnit.Framework; - -namespace NHibernate.Test.NHSpecificTest.NH2294 -{ - using System.Threading.Tasks; - [TestFixture] - public class FixtureAsync : TestCase - { - protected override string[] Mappings => System.Array.Empty(); - - [Test, Ignore("External issue. The bug is inside RecognitionException of Antlr.")] - public void WhenQueryHasJustAWhereThenThrowQuerySyntaxExceptionAsync() - { - using (ISession session = OpenSession()) - { - Assert.That(() => session.CreateQuery("where").ListAsync(), Throws.TypeOf()); - } - } - } -} diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2302/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2302/Fixture.cs index 009e8c61141..3de5b772229 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2302/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH2302/Fixture.cs @@ -82,35 +82,6 @@ public async Task StringHugeLengthAsync() } } - [Test, Ignore("Not supported without specify the string length.")] - public async Task StringSqlTypeAsync() - { - int id; - // buildup a string the exceed the mapping - string str = GetFixedLengthString12000(); - - using (ISession sess = OpenSession()) - using (ITransaction tx = sess.BeginTransaction()) - { - // create and save the entity - StringLengthEntity entity = new StringLengthEntity(); - entity.StringSqlType = str; - await (sess.SaveAsync(entity)); - await (tx.CommitAsync()); - id = entity.ID; - } - - using (ISession sess = OpenSession()) - using (ITransaction tx = sess.BeginTransaction()) - { - StringLengthEntity loaded = await (sess.GetAsync(id)); - Assert.IsNotNull(loaded); - Assert.AreEqual(12000, loaded.StringSqlType.Length); - Assert.AreEqual(str, loaded.StringSqlType); - await (tx.CommitAsync()); - } - } - [Test] public async Task BlobSqlTypeAsync() { diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2583/ManualTestFixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2583/ManualTestFixture.cs index e3a1afd2f45..0059c500dcb 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2583/ManualTestFixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH2583/ManualTestFixture.cs @@ -214,44 +214,6 @@ public async Task OrShouldBeCompatibleWithAdditionForNonNullReferencesAsync() } } - [Test, Ignore("Pure Outer Join semantics has projection anomaly!")] - public async Task ProjectionDoesNotChangeResultAsync() - { - // This tests against the "projection anomaly" of (||-4) semantics. - using (var session = OpenSession()) - { - using (var tx = session.BeginTransaction()) - { - var i1001 = new MyRef1 { Id = 1001, I1 = null, I2 = 101 }; - var i1101 = new MyRef1 { Id = 1101, I1 = null, I2 = 111 }; - await (session.SaveAsync(i1001)); - await (session.SaveAsync(i1101)); - - var b1 = new MyBO { Id = 1, Name = "1:1001", BO1 = i1001 }; - var b2 = new MyBO { Id = 2, Name = "2:1101", BO1 = i1101 }; - var b3 = new MyBO { Id = 3, Name = "3:1101", BO1 = i1101 }; - var b4 = new MyBO { Id = 4, Name = "4:NULL", BO1 = null }; - await (session.SaveAsync(b1)); - await (session.SaveAsync(b2)); - await (session.SaveAsync(b3)); - await (session.SaveAsync(b4)); - await (tx.CommitAsync()); - } - } - - using (var session = OpenSession()) - { - var directResult = (await (session.Query() - .Where(bo => bo.I1 == null).ToListAsync())).Select(bo => bo.Id); - var resultViaProjection = (await ((from bo in session.Query() - where bo.BO1.I1 == null || bo.BO2.J2 == 999 - select bo.BO1).Distinct().ToListAsync())).Select(bo => bo.Id); - // With "projection anomaly", the previous Select will fail, as one "bo" is null, - // and hence bo.Id throws a NRE. - Assert.That(() => resultViaProjection.ToList(), Is.EquivalentTo(directResult.ToList())); - } - } - [Test, Explicit("Exploratory Test")] public async Task NHibernateLinqExploratoryTestWhichProvesNothingAsync() { diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2693/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2693/Fixture.cs index b3111d2e76a..865ba47293f 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2693/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH2693/Fixture.cs @@ -102,158 +102,6 @@ protected override void OnTearDown() } } - [Test, Ignore("Not fixed yet")] - public async Task _1_Querying_BasedOnFourthLevelExistence_WithIsAndCasting_ShouldReturnSameEntitiesAsLinqToObjectsAsync() - { - var expected = _firstLevels - .Where(first => first.SecondLevels - .Any(second => second.ThirdLevel is SpecificThirdLevel && - ((SpecificThirdLevel)second.ThirdLevel).FourthLevels - .Any() - ) - ) - .ToList(); - - using (ISession session = OpenSession()) - { - using (ITransaction tx = session.BeginTransaction()) - { - var result = await (session.Query() - .Where(first => first.SecondLevels - .Any(second => second.ThirdLevel is SpecificThirdLevel && - ((SpecificThirdLevel)second.ThirdLevel).FourthLevels - .Any() - ) - ) - .ToListAsync()); - - Assert.AreEqual(expected.Count, result.Count); - Assert.IsTrue(result - .All(f => f.SecondLevels - .Any(s => ((SpecificThirdLevel)s.ThirdLevel).FourthLevels - .Any() - ) - ) - ); - } - } - } - - [Test, Ignore("Not fixed yet")] - public async Task _2_Querying_BasedOnFourthLevelExistence_WithSelectAndOfType_ShouldReturnSameEntitiesAsLinqToObjectsAsync() - { - var expected = _firstLevels - .Where(first => first.SecondLevels - .Select(second => second.ThirdLevel) - .OfType() - .Any(specificThird => specificThird.FourthLevels - .Any() - ) - ) - .ToList(); - - using (ISession session = OpenSession()) - { - using (ITransaction tx = session.BeginTransaction()) - { - var result = await (session.Query() - .Where(first => first.SecondLevels - .Select(second => second.ThirdLevel) - .OfType() - .Any(specificThird => specificThird.FourthLevels - .Any() - ) - ) - .ToListAsync()); - - Assert.AreEqual(expected.Count, result.Count); - Assert.IsTrue(result - .All(f => f.SecondLevels - .Any(s => ((SpecificThirdLevel)s.ThirdLevel).FourthLevels - .Any() - ) - ) - ); - } - } - } - - [Test, Ignore("Not fixed yet")] - public async Task _3_Querying_BasedOnFourthLevelProperty_WithIsAndCasting_ShouldReturnSameEntitiesAsLinqToObjectsAsync() - { - var expected = _firstLevels - .Where(first => first.SecondLevels - .Any(second => second.ThirdLevel is SpecificThirdLevel && - ((SpecificThirdLevel)second.ThirdLevel).FourthLevels - .Any(fourth => fourth.SomeString == "first") - ) - ) - .ToList(); - - using (ISession session = OpenSession()) - { - using (ITransaction tx = session.BeginTransaction()) - { - var result = await (session.Query() - .Where(first => first.SecondLevels - .Any(second => second.ThirdLevel is SpecificThirdLevel && - ((SpecificThirdLevel)second.ThirdLevel).FourthLevels - .Any(fourth => fourth.SomeString == "first") - ) - ) - .ToListAsync()); - - Assert.AreEqual(expected.Count, result.Count); - Assert.IsTrue(result - .All(f => f.SecondLevels - .Any(s => ((SpecificThirdLevel)s.ThirdLevel).FourthLevels - .Any(fo => fo.SomeString == "first") - ) - ) - ); - } - } - } - - [Test, Ignore("Not fixed yet")] - public async Task _4_Querying_BasedOnFourthLevelProperty_WithSelectAndOfType_ShouldReturnSameEntitiesAsLinqToObjectsAsync() - { - var expected = _firstLevels - .Where(first => first.SecondLevels - .Select(second => second.ThirdLevel) - .OfType() - .Any(specificThird => specificThird.FourthLevels - .Any(fourth => fourth.SomeString == "first") - ) - ) - .ToList(); - - using (ISession session = OpenSession()) - { - using (ITransaction tx = session.BeginTransaction()) - { - var result = await (session.Query() - .Where(first => first.SecondLevels - .Select(second => second.ThirdLevel) - .OfType() - .Any(specificThird => specificThird.FourthLevels - .Any(fourth => fourth.SomeString == "first") - ) - ) - .ToListAsync()); - - Assert.AreEqual(expected.Count, result.Count); - Assert.IsTrue(result - .All(f => f.SecondLevels - .Any(s => ((SpecificThirdLevel)s.ThirdLevel).FourthLevels - .Any(fo => fo.SomeString == "first") - ) - ) - ); - } - } - } - [Test] public async Task _5_Querying_BasedOnFourthLevelExistence_ByUsingSpecificThirdLevelProperty_ShouldReturnSameEntitiesAsLinqToObjectsAsync() { diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2705/Test.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2705/Test.cs index f81135448a8..6368b60455d 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2705/Test.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH2705/Test.cs @@ -81,17 +81,5 @@ public void LinqQueryWithFetch_WhenDerivedClassesUseComponentAndManyToOne_DoesNo } } } - - [Test, Ignore("Locked by re-linq")] - public void LinqQueryWithFetch_WhenDerivedClassesUseComponentAndEagerFetchManyToOne_DoesNotGenerateInvalidSqlAsync() - { - using (ISession s = OpenSession()) - { - using (var log = new SqlLogSpy()) - { - Assert.That(() => s.Query().Fetch(p => p.SubItem.Details).ToListAsync(), Throws.Nothing); - } - } - } } } diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2721/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2721/Fixture.cs deleted file mode 100644 index e70e5245410..00000000000 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2721/Fixture.cs +++ /dev/null @@ -1,79 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by AsyncGenerator. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - - -using System.Collections.Generic; -using System.Linq; -using System.Collections; - -using NUnit.Framework; - -namespace NHibernate.Test.NHSpecificTest.NH2721 -{ - using System.Threading.Tasks; - [TestFixture] - public class FixtureAsync : BugTestCase - { - protected override void OnTearDown() - { - using( ISession s = Sfi.OpenSession() ) - { - s.Delete("from A"); - s.Flush(); - } - } - - [Test] - [Ignore("Does not work because of extraneous update that sets reference to A to null. Can be worked-around by removing not-null on reference to A.")] - public async Task ListRemoveInsertAsync() - { - A a = new A("a"); - - B b1 = new B("b1"); - a.Bs.Add(b1); - b1.A = a; - - B b2 = new B("b2"); - a.Bs.Add(b2); - b2.A = a; - - B b3 = new B("b3"); - a.Bs.Add(b3); - b3.A = a; - - using (ISession s = OpenSession()) - { - await (s.SaveOrUpdateAsync(a)); - await (s.FlushAsync()); - } - - using (ISession s = OpenSession()) - { - a = (A) await (s.LoadAsync(typeof (A), a.Id)); - CollectionAssert.AreEquivalent(new[] {"b1", "b2", "b3"}, a.Bs.Select(b => b.Name)); - - B removed = a.Bs[2]; - a.Bs.Remove(removed); - a.Bs.Insert(1, removed); - Assert.IsNotNull(a.Bs[0].A); - Assert.IsNotNull(a.Bs[1].A); - Assert.IsNotNull(a.Bs[2].A); - CollectionAssert.AreEquivalent(new[] {"b1", "b3", "b2"}, a.Bs.Select(b => b.Name)); - await (s.SaveOrUpdateAsync(a)); - await (s.FlushAsync()); - } - - using (ISession s = OpenSession()) - { - a = (A) await (s.LoadAsync(typeof (A), a.Id)); - CollectionAssert.AreEquivalent(new[] { "b1", "b3", "b2" }, a.Bs.Select(b => b.Name)); - } - } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2951/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2951/Fixture.cs deleted file mode 100644 index 7d7aa4a2aa3..00000000000 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2951/Fixture.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by AsyncGenerator. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - - -using System.Linq; -using NHibernate.Linq; -using NUnit.Framework; - -namespace NHibernate.Test.NHSpecificTest.NH2951 -{ - using System.Threading.Tasks; - [TestFixture] - public class FixtureAsync : BugTestCase - { - protected override void OnTearDown() - { - using (ISession session = OpenSession()) - using (ITransaction transaction = session.BeginTransaction()) - { - session.Delete("from System.Object"); - - session.Flush(); - transaction.Commit(); - } - } - - [Test] - [Ignore("Not working.")] - public async Task UpdateWithSubqueryToJoinedSubclassAsync() - { - using (ISession session = OpenSession()) - using (ITransaction transaction = session.BeginTransaction()) - { - - var c = new Customer { Name = "Bob" }; - await (session.SaveAsync(c)); - - var i = new Invoice { Amount = 10 }; - await (session.SaveAsync(i)); - - await (session.FlushAsync()); - await (transaction.CommitAsync()); - } - - using (ISession session = OpenSession()) - using (session.BeginTransaction()) - { - // Using (select c.Id ...) works. - string hql = "update Invoice i set i.Customer = (select c from Customer c where c.Name = 'Bob')"; - - int result = await (session.CreateQuery(hql).ExecuteUpdateAsync()); - - Assert.AreEqual(1, result); - } - } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3037/FixtureByCode.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3037/FixtureByCode.cs index 404d0c5a6b6..a47d5d6230d 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3037/FixtureByCode.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH3037/FixtureByCode.cs @@ -19,7 +19,6 @@ namespace NHibernate.Test.NHSpecificTest.NH3037 { using System.Threading.Tasks; - using System.Threading; [TestFixture, Explicit("This is a performance test and may take a while.")] public class ByCodeFixtureAsync : TestCaseMappingByCode { @@ -42,14 +41,14 @@ protected override HbmMapping GetMappings() [TestCase(20000)] [TestCase(30000)] [TestCase(40000)] - public async Task SortInsertionActionsAsync(int iterations, CancellationToken cancellationToken = default(CancellationToken)) + public async Task SortInsertionActionsAsync(int iterations) { using (ISession session = OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { for (int i = 1; i <= iterations; i++) { - await (session.SaveAsync(new Entity() { Id = i, Name = i.ToString() }, cancellationToken)); + await (session.SaveAsync(new Entity() { Id = i, Name = i.ToString() })); } var impl = ((NHibernate.Impl.SessionImpl)session); diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3074/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3074/Fixture.cs deleted file mode 100644 index 1ceb87fc686..00000000000 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3074/Fixture.cs +++ /dev/null @@ -1,90 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by AsyncGenerator. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - - -using NHibernate.Cfg.MappingSchema; -using NHibernate.Criterion; -using NHibernate.Mapping.ByCode; -using NUnit.Framework; - -namespace NHibernate.Test.NHSpecificTest.NH3074 -{ - using System.Threading.Tasks; - [TestFixture] - public class FixtureAsync : TestCaseMappingByCode - { - private const int Id = 123; - - protected override HbmMapping GetMappings() - { - var mapper = new ModelMapper(); - mapper.Class(rc => - { - rc.Id(x => x.Id, m => m.Generator(Generators.Assigned)); - rc.Property(x => x.Weight); - }); - - mapper.UnionSubclass(x => x.Property(p => p.NumberOfLegs)); - - return mapper.CompileMappingForAllExplicitlyAddedEntities(); - } - - protected override void OnSetUp() - { - using (var s = OpenSession()) - using (var tx = s.BeginTransaction()) - { - var cat = new Cat { Id = Id, NumberOfLegs = 2, Weight = 100 }; - s.Save(cat); - tx.Commit(); - } - } - - [Test] - [Ignore("Fails on at least Oracle and PostgreSQL. See NH-3074 and NH-2408.")] - public async Task HqlCanSetLockModeAsync() - { - using (var s = OpenSession()) - using (s.BeginTransaction()) - { - var cats = await (s.CreateQuery("select c from Animal c where c.Id=:id") - .SetInt32("id", Id) - .SetLockMode("c", LockMode.Upgrade) - .ListAsync()); - - Assert.That(cats, Is.Not.Empty); - } - } - - [Test, Ignore("Not fixed yet")] - public async Task CritriaCanSetLockModeAsync() - { - using (var s = OpenSession()) - using (s.BeginTransaction()) - { - var cats = await (s.CreateCriteria("c") - .Add(Restrictions.IdEq(Id)) - .SetLockMode("c", LockMode.Upgrade) - .ListAsync()); - - Assert.That(cats, Is.Not.Empty); - } - } - - protected override void OnTearDown() - { - using (var s = OpenSession()) - using (var tx = s.BeginTransaction()) - { - s.Delete(s.Get(Id)); - tx.Commit(); - } - } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3138/FixtureByCode.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3138/FixtureByCode.cs index b4faa0ee71f..a3ddbe62d6c 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3138/FixtureByCode.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH3138/FixtureByCode.cs @@ -45,20 +45,5 @@ public void PageQueryWithDistinctAndOrderByContainingFunctionWithCommaSeparatedP .ListAsync()); } } - - [Test] - [Ignore("Failing")] - public void PageQueryWithDistinctAndOrderByContainingAliasedFunctionAsync() - { - using (var session = OpenSession()) - { - Assert.DoesNotThrowAsync(() => - session - .CreateQuery("select distinct e.Id, coalesce(e.EnglishName, e.GermanName) as LocalizedName from Entity e order by LocalizedName asc") - .SetFirstResult(10) - .SetMaxResults(20) - .ListAsync()); - } - } } } \ No newline at end of file diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3401/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3401/Fixture.cs deleted file mode 100644 index 728f2592a6b..00000000000 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3401/Fixture.cs +++ /dev/null @@ -1,64 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by AsyncGenerator. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - - -using System.Linq; -using NHibernate.Linq; -using NUnit.Framework; - -namespace NHibernate.Test.NHSpecificTest.NH3401 -{ - using System.Threading.Tasks; - [TestFixture] - public class FixtureAsync : BugTestCase - { - protected override void OnTearDown() - { - using (ISession session = OpenSession()) - using (ITransaction transaction = session.BeginTransaction()) - { - session.Delete("from System.Object"); - - session.Flush(); - transaction.Commit(); - } - } - - [Test(Description = "NH-3401")] - [Ignore("Test not implemented - this can be used a base for a proper test case for NH-3401.")] - public async Task YesNoParameterLengthShouldBe1Async() - { - // MISSING PART: Asserts for the SQL parameter sizes in the generated commands. - - using (ISession session = OpenSession()) - using (ITransaction transaction = session.BeginTransaction()) - { - var e1 = new Entity {Name = "Bob"}; - await (session.SaveAsync(e1)); - - var e2 = new Entity {Name = "Sally", YesNo = true}; - await (session.SaveAsync(e2)); - - await (session.FlushAsync()); - await (transaction.CommitAsync()); - } - - - using (ISession session = OpenSession()) - using (session.BeginTransaction()) - { - var result = from e in session.Query() - where e.YesNo - select e; - - Assert.AreEqual(1, (await (result.ToListAsync())).Count); - } - } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3850/MainFixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3850/MainFixture.cs index d4c40c427c5..ecbd2e774d1 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3850/MainFixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH3850/MainFixture.cs @@ -43,25 +43,6 @@ public async Task AggregateGBaseAsync() } } - // Failing case due to lack of polymorphic results ordering. - [Test, Ignore("Polymorphic results sets are unioned without reordering, whatever the API")] - public async Task AggregateGBaseOrderingMismatchAsync() - { - using (var session = OpenSession()) - { - // This case cannot work because the aggregate is sensitive to ordering, and NHibernate currently always order polymorphic queries by class names, - // then only honors query ordering as secondary order criteria. - var query = session.Query() - .OrderByDescending(dc => dc.Id) - .Select(dc => dc.Id.ToString()); - var result = query.Aggregate((p, n) => p + "," + n); - // Currently yields "2,1,4,3" instead. - Assert.That(result, Is.EqualTo("4,3,2,1")); - var futureQuery = query.ToFutureValue(qdc => qdc.Aggregate((p, n) => p + "," + n)); - Assert.That(await (futureQuery.GetValueAsync()), Is.EqualTo("4,3,2,1"), "Future"); - } - } - // Non-reg case [Test] public async Task AggregateMutableSeedGBaseAsync() @@ -323,18 +304,6 @@ public async Task AnyObjectAsync() } } - [Test, Ignore("Won't fix: requires reshaping the query")] - public async Task AverageBBaseAsync() - { - await (AverageAsync(1.5m)); - } - - [Test, Ignore("Won't fix: requires reshaping the query")] - public async Task AverageCBaseAsync() - { - await (AverageAsync(1.5m)); - } - // Non-reg case [Test] public async Task AverageEAsync() @@ -349,12 +318,6 @@ public async Task AverageFAsync() await (AverageAsync(null)); } - [Test, Ignore("Won't fix: requires reshaping the query")] - public async Task AverageGBaseAsync() - { - await (AverageAsync(2.5m)); - } - private async Task AverageAsync(decimal? expectedResult, CancellationToken cancellationToken = default(CancellationToken)) where DC : DomainClassBase { using (var session = OpenSession()) @@ -411,18 +374,6 @@ public async Task AverageGBaseAsync() } } - [Test, Ignore("Won't fix: requires reshaping the query")] - public async Task AverageObjectAsync() - { - using (var session = OpenSession()) - { - var result = await (session.Query().AverageAsync(o => (int?)2)); - Assert.That(result, Is.EqualTo(2)); - result = await (session.Query().ToFutureValue(qdc => qdc.Average(o => (int?)2)).GetValueAsync()); - Assert.That(result, Is.EqualTo(2), "Future"); - } - } - // Failing case till NH-3850 is fixed [Test] public async Task CountBBaseAsync() diff --git a/src/NHibernate.Test/Async/Operations/MergeFixture.cs b/src/NHibernate.Test/Async/Operations/MergeFixture.cs index 125950bd47d..6b79816c78f 100644 --- a/src/NHibernate.Test/Async/Operations/MergeFixture.cs +++ b/src/NHibernate.Test/Async/Operations/MergeFixture.cs @@ -150,41 +150,6 @@ public async Task MergeBidiForeignKeyOneToOneAsync() } } - [Test, Ignore("Need some more investigation about id sync.")] - public async Task MergeBidiPrimayKeyOneToOneAsync() - { - Person p; - using (ISession s = OpenSession()) - using (ITransaction tx = s.BeginTransaction()) - { - p = new Person {Name = "steve"}; - new PersonalDetails {SomePersonalDetail = "I have big feet", Person = p}; - await (s.PersistAsync(p)); - await (tx.CommitAsync()); - } - - ClearCounts(); - - p.Details.SomePersonalDetail = p.Details.SomePersonalDetail + " and big hands too"; - using (ISession s = OpenSession()) - using (ITransaction tx = s.BeginTransaction()) - { - p = (Person) await (s.MergeAsync(p)); - await (tx.CommitAsync()); - } - - AssertInsertCount(0); - AssertUpdateCount(1); - AssertDeleteCount(0); - - using (ISession s = OpenSession()) - using (ITransaction tx = s.BeginTransaction()) - { - await (s.DeleteAsync(p)); - await (tx.CommitAsync()); - } - } - [Test] public async Task MergeDeepTreeAsync() { diff --git a/src/NHibernate.Test/Async/ReadOnly/ReadOnlyProxyTest.cs b/src/NHibernate.Test/Async/ReadOnly/ReadOnlyProxyTest.cs index 4e1c7f0a5fd..e0a8a0d2690 100644 --- a/src/NHibernate.Test/Async/ReadOnly/ReadOnlyProxyTest.cs +++ b/src/NHibernate.Test/Async/ReadOnly/ReadOnlyProxyTest.cs @@ -585,106 +585,6 @@ public async Task ModifiableViaLazyInitializerAfterInitAsync() s.Close(); } - [Test] - [Ignore("Failing test. See HHH-4642")] - public async Task ModifyToReadOnlyToModifiableIsUpdatedFailureExpectedAsync() - { - DataPoint dpOrig = await (CreateDataPointAsync(CacheMode.Ignore)); - - ISession s = OpenSession(); - s.CacheMode = CacheMode.Ignore; - s.BeginTransaction(); - DataPoint dp = await (s.LoadAsync(dpOrig.Id)); - Assert.That(dp, Is.InstanceOf()); - Assert.That(NHibernateUtil.IsInitialized(dp), Is.False); - await (CheckReadOnlyAsync(s, dp, false)); - dp.Description = "changed"; - Assert.That(NHibernateUtil.IsInitialized(dp), Is.True); - Assert.That(dp.Description, Is.EqualTo("changed")); - s.SetReadOnly(dp, true); - await (CheckReadOnlyAsync(s, dp, true)); - s.SetReadOnly(dp, false); - await (CheckReadOnlyAsync(s, dp, false)); - Assert.That(dp.Description, Is.EqualTo("changed")); - await (s.FlushAsync()); - await (s.Transaction.CommitAsync()); - s.Close(); - - s = OpenSession(); - s.BeginTransaction(); - dp = await (s.GetAsync(dpOrig.Id)); - Assert.That(dp.Id, Is.EqualTo(dpOrig.Id)); - Assert.That(dp.Description, Is.EqualTo(dpOrig.Description)); - Assert.That(dp.X, Is.EqualTo(dpOrig.X)); - Assert.That(dp.Y, Is.EqualTo(dpOrig.Y)); - - try - { - Assert.That(dp.Description, Is.EqualTo("changed")); - // should fail due to HHH-4642 - } - finally - { - await (s.Transaction.RollbackAsync()); - s.Close(); - s = OpenSession(); - s.BeginTransaction(); - await (s.DeleteAsync(dp)); - await (s.Transaction.CommitAsync()); - s.Close(); - } - } - - [Test] - [Ignore("Failing test. See HHH-4642")] - public async Task ReadOnlyModifiedToModifiableIsUpdatedFailureExpectedAsync() - { - DataPoint dpOrig = await (CreateDataPointAsync(CacheMode.Ignore)); - - ISession s = OpenSession(); - s.CacheMode = CacheMode.Ignore; - s.BeginTransaction(); - DataPoint dp = await (s.LoadAsync(dpOrig.Id)); - Assert.That(dp, Is.InstanceOf()); - Assert.That(NHibernateUtil.IsInitialized(dp), Is.False); - await (CheckReadOnlyAsync(s, dp, false)); - s.SetReadOnly(dp, true); - await (CheckReadOnlyAsync(s, dp, true)); - dp.Description = "changed"; - Assert.That(NHibernateUtil.IsInitialized(dp), Is.True); - Assert.That(dp.Description, Is.EqualTo("changed")); - s.SetReadOnly(dp, false); - await (CheckReadOnlyAsync(s, dp, false)); - Assert.That(dp.Description, Is.EqualTo("changed")); - await (s.FlushAsync()); - await (s.Transaction.CommitAsync()); - s.Close(); - - s = OpenSession(); - s.BeginTransaction(); - dp = await (s.GetAsync(dpOrig.Id)); - Assert.That(dp.Id, Is.EqualTo(dpOrig.Id)); - Assert.That(dp.Description, Is.EqualTo(dpOrig.Description)); - Assert.That(dp.X, Is.EqualTo(dpOrig.X)); - Assert.That(dp.Y, Is.EqualTo(dpOrig.Y)); - - try - { - Assert.That(dp.Description, Is.EqualTo("changed")); - // should fail due to HHH-4642 - } - finally - { - await (s.Transaction.RollbackAsync()); - s.Close(); - s = OpenSession(); - s.BeginTransaction(); - await (s.DeleteAsync(dp)); - await (s.Transaction.CommitAsync()); - s.Close(); - } - } - [Test] public async Task ReadOnlyChangedEvictedUpdateAsync() { diff --git a/src/NHibernate.Test/Async/ReadOnly/ReadOnlyVersionedNodes.cs b/src/NHibernate.Test/Async/ReadOnly/ReadOnlyVersionedNodes.cs index ea677098be3..ea6f2d38aba 100644 --- a/src/NHibernate.Test/Async/ReadOnly/ReadOnlyVersionedNodes.cs +++ b/src/NHibernate.Test/Async/ReadOnly/ReadOnlyVersionedNodes.cs @@ -197,80 +197,6 @@ public async Task UpdateSetModifiableAsync() AssertDeleteCount(1); } - [Test] - [Ignore("Failure expected")] - public async Task UpdateSetReadOnlySetModifiableFailureExpectedAsync() - { - VersionedNode node = new VersionedNode("node", "node"); - using (ISession s = OpenSession()) - { - s.BeginTransaction(); - await (s.PersistAsync(node)); - await (s.Transaction.CommitAsync()); - } - - ClearCounts(); - - using (ISession s = OpenSession()) - { - s.BeginTransaction(); - node = await (s.GetAsync(node.Id)); - node.Name = "node-name"; - s.SetReadOnly(node, true); - s.SetReadOnly(node, false); - await (s.Transaction.CommitAsync()); - } - - AssertUpdateCount(1); - AssertInsertCount(0); - - using (ISession s = OpenSession()) - { - s.BeginTransaction(); - node = await (s.GetAsync(node.Id)); - Assert.That(node.Name, Is.EqualTo("node-name")); - Assert.That(node.Version, Is.EqualTo(2)); - await (s.DeleteAsync(node)); - await (s.Transaction.CommitAsync()); - } - } - - [Test] - [Ignore("Failure expected")] - public async Task SetReadOnlyUpdateSetModifiableFailureExpectedAsync() - { - ISession s = OpenSession(); - s.BeginTransaction(); - VersionedNode node = new VersionedNode("node", "node"); - await (s.PersistAsync(node)); - await (s.Transaction.CommitAsync()); - s.Close(); - - ClearCounts(); - - s = OpenSession(); - - s.BeginTransaction(); - node = await (s.GetAsync(node.Id)); - s.SetReadOnly(node, true); - node.Name = "node-name"; - s.SetReadOnly(node, false); - await (s.Transaction.CommitAsync()); - s.Close(); - - AssertUpdateCount(1); - AssertInsertCount(0); - - s = OpenSession(); - s.BeginTransaction(); - node = await (s.GetAsync(node.Id)); - Assert.That(node.Name, Is.EqualTo("node-name")); - Assert.That(node.Version, Is.EqualTo(2)); - await (s.DeleteAsync(node)); - await (s.Transaction.CommitAsync()); - s.Close(); - } - [Test] public async Task AddNewChildToReadOnlyParentAsync() { diff --git a/src/NHibernate.Test/Async/SqlTest/Query/NativeSQLQueriesFixture.cs b/src/NHibernate.Test/Async/SqlTest/Query/NativeSQLQueriesFixture.cs index d2f9c921855..92f307a14c7 100644 --- a/src/NHibernate.Test/Async/SqlTest/Query/NativeSQLQueriesFixture.cs +++ b/src/NHibernate.Test/Async/SqlTest/Query/NativeSQLQueriesFixture.cs @@ -410,80 +410,6 @@ public async Task MappedAliasStrategyAsync() s.Close(); } - /* test for native sql composite id joins which has never been implemented */ - - [Test, Ignore("Failure expected")] - public async Task CompositeIdJoinsFailureExpectedAsync() - { - ISession s = OpenSession(); - ITransaction t = s.BeginTransaction(); - Person person = new Person(); - person.Name = "Noob"; - - Product product = new Product(); - product.ProductId = new Product.ProductIdType(); - product.ProductId.Orgid = "x"; - product.ProductId.Productnumber = "1234"; - product.Name = "Hibernate 3"; - - Order order = new Order(); - order.OrderId = new Order.OrderIdType(); - order.OrderId.Ordernumber = "1"; - order.OrderId.Orgid = "y"; - - product.Orders.Add(order); - order.Product = product; - order.Person = person; - - await (s.SaveAsync(product)); - await (s.SaveAsync(order)); - await (s.SaveAsync(person)); - - await (t.CommitAsync()); - s.Close(); - - s = OpenSession(); - t = s.BeginTransaction(); - Product p = (Product) (await (s.CreateQuery("from Product p join fetch p.orders").ListAsync()))[0]; - Assert.IsTrue(NHibernateUtil.IsInitialized(p.Orders)); - await (t.CommitAsync()); - s.Close(); - - s = OpenSession(); - t = s.BeginTransaction(); - object[] o = (object[]) (await (s.CreateSQLQuery( - "select\r\n" + - " product.orgid as {product.id.orgid}," + - " product.productnumber as {product.id.productnumber}," + - " {prod_orders}.orgid as orgid3_1_,\r\n" + - " {prod_orders}.ordernumber as ordernum2_3_1_,\r\n" + - " product.name as {product.name}," + - " {prod_orders.element.*}," + - /*" orders.PROD_NO as PROD4_3_1_,\r\n" + - " orders.person as person3_1_,\r\n" + - " orders.PROD_ORGID as PROD3_0__,\r\n" + - " orders.PROD_NO as PROD4_0__,\r\n" + - " orders.orgid as orgid0__,\r\n" + - " orders.ordernumber as ordernum2_0__ \r\n" +*/ - " from\r\n" + - " Product product \r\n" + - " inner join\r\n" + - " TBL_ORDER {prod_orders} \r\n" + - " on product.orgid={prod_orders}.PROD_ORGID \r\n" + - " and product.productnumber={prod_orders}.PROD_NO") - .AddEntity("product", typeof(Product)) - .AddJoin("prod_orders", "product.orders") - .ListAsync()))[0]; - - p = (Product) o[0]; - Assert.IsTrue(NHibernateUtil.IsInitialized(p.Orders)); - IEnumerator en = p.Orders.GetEnumerator(); - Assert.IsTrue(en.MoveNext()); - Assert.IsNotNull(en.Current); - await (t.CommitAsync()); - s.Close(); - } - [Test] public async Task AutoDetectAliasingAsync() { From d62f0dd7adfa3fceaf5c0ab0bced56dc24a03cf3 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Mon, 6 May 2019 10:45:45 +1200 Subject: [PATCH 2/2] Regenerate Async Code --- src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs b/src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs index 7fd908fd58e..17b11403da4 100644 --- a/src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs +++ b/src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs @@ -213,6 +213,7 @@ public async Task EntityJoinWithEntityAssociationComparison2ShouldAddJoinAsync() } } + [Test] public async Task WithClauseOnOtherAssociationAsync() {