-
Notifications
You must be signed in to change notification settings - Fork 933
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into NH3864-Cacheable-Multicriteria
- Loading branch information
Showing
91 changed files
with
2,911 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version: 5.1.2.{build} | ||
version: 5.1.3.{build} | ||
image: Visual Studio 2017 | ||
environment: | ||
matrix: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/NHibernate.Test/Async/BulkManipulation/NativeSQLBulkOperationsWithCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by AsyncGenerator. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NHibernate.Cache; | ||
using NHibernate.Cfg; | ||
using NSubstitute; | ||
using NUnit.Framework; | ||
using Environment = NHibernate.Cfg.Environment; | ||
|
||
namespace NHibernate.Test.BulkManipulation | ||
{ | ||
using System.Threading.Tasks; | ||
[TestFixture] | ||
public class NativeSQLBulkOperationsWithCacheAsync : TestCase | ||
{ | ||
protected override string MappingsAssembly => "NHibernate.Test"; | ||
|
||
protected override IList Mappings => new[] { "BulkManipulation.Vehicle.hbm.xml" }; | ||
|
||
protected override void Configure(Configuration configuration) | ||
{ | ||
cfg.SetProperty(Environment.UseQueryCache, "true"); | ||
cfg.SetProperty(Environment.UseSecondLevelCache, "true"); | ||
cfg.SetProperty(Environment.CacheProvider, typeof(SubstituteCacheProvider).AssemblyQualifiedName); | ||
} | ||
|
||
[Test] | ||
public async Task SimpleNativeSQLInsert_DoesNotEvictEntireCacheWhenQuerySpacesAreAddedAsync() | ||
{ | ||
List<string> clearCalls = new List<string>(); | ||
(Sfi.Settings.CacheProvider as SubstituteCacheProvider).OnClear(x => | ||
{ | ||
clearCalls.Add(x); | ||
}); | ||
using (var s = OpenSession()) | ||
{ | ||
string ssql = "UPDATE Vehicle SET Vin='123' WHERE Vin='123c'"; | ||
|
||
using (var t = s.BeginTransaction()) | ||
{ | ||
|
||
await (s.CreateSQLQuery(ssql).ExecuteUpdateAsync()); | ||
await (t.CommitAsync()); | ||
|
||
Assert.AreEqual(1, clearCalls.Count); | ||
} | ||
|
||
clearCalls.Clear(); | ||
|
||
using (var t = s.BeginTransaction()) | ||
{ | ||
await (s.CreateSQLQuery(ssql).AddSynchronizedQuerySpace("Unknown").ExecuteUpdateAsync()); | ||
await (t.CommitAsync()); | ||
|
||
Assert.AreEqual(0, clearCalls.Count); | ||
} | ||
} | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
src/NHibernate.Test/Async/NHSpecificTest/GH1730/Fixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by AsyncGenerator. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
|
||
using NHibernate.Cfg; | ||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH1730 | ||
{ | ||
using System.Threading.Tasks; | ||
[TestFixture] | ||
public class FixtureAsync : BugTestCase | ||
{ | ||
protected override void Configure(Configuration configuration) | ||
{ | ||
cfg.SetProperty(Environment.GenerateStatistics, "true"); | ||
} | ||
|
||
protected override void OnTearDown() | ||
{ | ||
using (var session = OpenSession()) | ||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
session.CreateQuery("delete from Entity").ExecuteUpdate(); | ||
|
||
transaction.Commit(); | ||
} | ||
} | ||
|
||
[Test] | ||
public async Task HitCacheInSameSessionAsync() | ||
{ | ||
await (Sfi.EvictQueriesAsync()); | ||
Sfi.Statistics.Clear(); | ||
var entities = new System.Collections.Generic.List<Entity>(); | ||
|
||
using (var session = OpenSession()) | ||
{ | ||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
for (int i = 0; i < 3; i++) | ||
{ | ||
var e = new Entity { Name = "Name" + i }; | ||
entities.Add(e); | ||
await (session.SaveAsync(e)); | ||
} | ||
await (transaction.CommitAsync()); | ||
} | ||
|
||
var queryString = "from Entity"; | ||
|
||
using (var tx = session.BeginTransaction()) | ||
{ | ||
// this query will hit the database and create the cache | ||
await (session.CreateQuery(queryString).SetCacheable(true).ListAsync()); | ||
await (tx.CommitAsync()); | ||
} | ||
|
||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
//and this one SHOULD served by the cache | ||
await (session.CreateQuery(queryString).SetCacheable(true).ListAsync()); | ||
await (transaction.CommitAsync()); | ||
} | ||
|
||
var qs = Sfi.Statistics.GetQueryStatistics(queryString); | ||
Assert.AreEqual(1, qs.CacheHitCount); | ||
Assert.AreEqual(1, qs.CachePutCount); | ||
} | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/NHibernate.Test/Async/NHSpecificTest/NH1039Generic/Fixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by AsyncGenerator. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
|
||
using System; | ||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
|
||
|
||
namespace NHibernate.Test.NHSpecificTest.NH1039Generic | ||
{ | ||
using System.Threading.Tasks; | ||
[TestFixture] | ||
public class FixtureAsync : BugTestCase | ||
{ | ||
public override string BugNumber | ||
{ | ||
get { return "NH1039Generic"; } | ||
} | ||
|
||
protected override void OnTearDown() | ||
{ | ||
base.OnTearDown(); | ||
using (ISession s = OpenSession()) | ||
using (ITransaction tx = s.BeginTransaction()) | ||
{ | ||
s.Delete("from Person"); | ||
tx.Commit(); | ||
} | ||
} | ||
|
||
[Test] | ||
public async Task testAsync() | ||
{ | ||
using (ISession s = OpenSession()) | ||
using (ITransaction tx = s.BeginTransaction()) | ||
{ | ||
Person person = new Person("1"); | ||
person.Name = "John Doe"; | ||
var set = new HashSet<object>(); | ||
set.Add("555-1234"); | ||
set.Add("555-4321"); | ||
person.Properties.Add("Phones", set); | ||
|
||
await (s.SaveAsync(person)); | ||
await (tx.CommitAsync()); | ||
} | ||
using (ISession s = OpenSession()) | ||
using (ITransaction tx = s.BeginTransaction()) | ||
{ | ||
Person person = (Person)await (s.CreateCriteria(typeof(Person)).UniqueResultAsync()); | ||
|
||
Assert.AreEqual("1", person.ID); | ||
Assert.AreEqual("John Doe", person.Name); | ||
Assert.AreEqual(1, person.Properties.Count); | ||
Assert.That(person.Properties["Phones"], Is.InstanceOf<ISet<object>>()); | ||
Assert.IsTrue(((ISet<object>) person.Properties["Phones"]).Contains("555-1234")); | ||
Assert.IsTrue(((ISet<object>) person.Properties["Phones"]).Contains("555-4321")); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.