|
| 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 System; |
| 12 | +using System.Collections; |
| 13 | +using System.Collections.Generic; |
| 14 | +using NUnit.Framework; |
| 15 | + |
| 16 | +namespace NHibernate.Test.CollectionTest |
| 17 | +{ |
| 18 | + using System.Threading.Tasks; |
| 19 | + [TestFixture] |
| 20 | + public class IdBagRelaxedFixtureAsync : TestCase |
| 21 | + { |
| 22 | + protected override string[] Mappings |
| 23 | + { |
| 24 | + get { return new string[] { "CollectionTest.IdBagRelaxedFixture.hbm.xml" }; } |
| 25 | + } |
| 26 | + |
| 27 | + protected override string MappingsAssembly |
| 28 | + { |
| 29 | + get { return "NHibernate.Test"; } |
| 30 | + } |
| 31 | + |
| 32 | + protected override void OnTearDown() |
| 33 | + { |
| 34 | + using( ISession s = OpenSession() ) |
| 35 | + { |
| 36 | + s.Delete( "from A" ); |
| 37 | + s.Flush(); |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + [Test] |
| 42 | + public async Task SimpleAsync() |
| 43 | + { |
| 44 | + A a = new A(); |
| 45 | + a.Name = "first generic type"; |
| 46 | + a.Items = new List<string>(); |
| 47 | + a.Items.Add( "first string" ); |
| 48 | + a.Items.Add( "second string" ); |
| 49 | + |
| 50 | + ISession s = OpenSession(); |
| 51 | + await (s.SaveOrUpdateAsync( a )); |
| 52 | + // this flush should test how NH wraps a generic collection with its |
| 53 | + // own persistent collection |
| 54 | + await (s.FlushAsync()); |
| 55 | + s.Close(); |
| 56 | + Assert.IsNotNull( a.Id ); |
| 57 | + Assert.AreEqual( "first string", ( string ) a.Items[ 0 ] ); |
| 58 | + |
| 59 | + s = OpenSession(); |
| 60 | + a = ( A ) await (s.LoadAsync( typeof( A ), a.Id )); |
| 61 | + Assert.AreEqual( "first string", ( string ) a.Items[ 0 ], "first item should be 'first string'" ); |
| 62 | + Assert.AreEqual( "second string", ( string ) a.Items[ 1 ], "second item should be 'second string'" ); |
| 63 | + // ensuring the correct generic type was constructed |
| 64 | + a.Items.Add( "third string" ); |
| 65 | + Assert.AreEqual( 3, a.Items.Count, "3 items in the list now" ); |
| 66 | + |
| 67 | + a.Items[ 1 ] = "new second string"; |
| 68 | + await (s.FlushAsync()); |
| 69 | + s.Close(); |
| 70 | + } |
| 71 | + } |
| 72 | +} |
0 commit comments