|
| 1 | +//------------------------------------------------------------------------------ |
| 2 | +// <auto-generated> |
| 3 | +// This code was generated by AsyncGenerator. |
| 4 | +// |
| 5 | +// Changes to this file may cause incorrect behavior and will be lost if |
| 6 | +// the code is regenerated. |
| 7 | +// </auto-generated> |
| 8 | +//------------------------------------------------------------------------------ |
| 9 | + |
| 10 | + |
| 11 | +using NUnit.Framework; |
| 12 | + |
| 13 | +namespace NHibernate.Test.NHSpecificTest.NH3898 |
| 14 | +{ |
| 15 | + using System.Threading.Tasks; |
| 16 | + [TestFixture] |
| 17 | + public class FixtureAsync : BugTestCase |
| 18 | + { |
| 19 | + protected override void Configure(Cfg.Configuration configuration) |
| 20 | + { |
| 21 | + configuration.SetProperty(Cfg.Environment.UseQueryCache, "false"); |
| 22 | + configuration.SetProperty(Cfg.Environment.UseSecondLevelCache, "false"); |
| 23 | + } |
| 24 | + |
| 25 | + protected override void OnTearDown() |
| 26 | + { |
| 27 | + using (var s = OpenSession()) |
| 28 | + using (var tx = s.BeginTransaction()) |
| 29 | + { |
| 30 | + s.CreateQuery("delete from Employee").ExecuteUpdate(); |
| 31 | + |
| 32 | + tx.Commit(); |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + [Test] |
| 37 | + public async Task GeneratedInsertUpdateTrueAsync() |
| 38 | + { |
| 39 | + object id; |
| 40 | + using (var session = OpenSession()) |
| 41 | + using (var tx = session.BeginTransaction()) |
| 42 | + { |
| 43 | + var employee = new Employee |
| 44 | + { |
| 45 | + Name = "Employee 1", |
| 46 | + PromotionCount = 9999999 |
| 47 | + }; |
| 48 | + id = await (session.SaveAsync(employee)); |
| 49 | + Assert.That(employee.PromotionCount, Is.EqualTo(0)); |
| 50 | + await (tx.CommitAsync()); |
| 51 | + } |
| 52 | + |
| 53 | + using (var session = OpenSession()) |
| 54 | + using (var tx = session.BeginTransaction()) |
| 55 | + { |
| 56 | + var employee = await (session.GetAsync<Employee>(id)); |
| 57 | + employee.Name = "Employee 1 changed"; |
| 58 | + employee.PromotionCount++; |
| 59 | + Assert.That(employee.PromotionCount, Is.EqualTo(1)); |
| 60 | + await (tx.CommitAsync()); |
| 61 | + } |
| 62 | + |
| 63 | + using (var session = OpenSession()) |
| 64 | + using (session.BeginTransaction()) |
| 65 | + { |
| 66 | + var employee = await (session.GetAsync<Employee>(id)); |
| 67 | + Assert.That(employee.Name, Is.EqualTo("Employee 1 changed")); |
| 68 | + Assert.That(employee.PromotionCount, Is.EqualTo(1)); |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | +} |
0 commit comments