|
| 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.Collections.Generic; |
| 12 | +using NHibernate.Dialect; |
| 13 | +using NHibernate.Type; |
| 14 | +using NUnit.Framework; |
| 15 | +using System; |
| 16 | + |
| 17 | +namespace NHibernate.Test.TypesTest |
| 18 | +{ |
| 19 | + using System.Threading.Tasks; |
| 20 | + using System.Threading; |
| 21 | + |
| 22 | + [TestFixture] |
| 23 | + public class DateTypeFixtureAsync : TypeFixtureBase |
| 24 | + { |
| 25 | + protected override string TypeName |
| 26 | + { |
| 27 | + get { return "Date"; } |
| 28 | + } |
| 29 | + |
| 30 | + [Test] |
| 31 | + public Task ReadWriteNormalAsync() |
| 32 | + { |
| 33 | + try |
| 34 | + { |
| 35 | + var expected = DateTime.Today; |
| 36 | + |
| 37 | + return ReadWriteAsync(expected); |
| 38 | + } |
| 39 | + catch (Exception ex) |
| 40 | + { |
| 41 | + return Task.FromException<object>(ex); |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + [Test] |
| 46 | + public Task ReadWriteMinAsync() |
| 47 | + { |
| 48 | + try |
| 49 | + { |
| 50 | + var expected = Sfi.ConnectionProvider.Driver.MinDate; |
| 51 | + |
| 52 | + return ReadWriteAsync(expected); |
| 53 | + } |
| 54 | + catch (Exception ex) |
| 55 | + { |
| 56 | + return Task.FromException<object>(ex); |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + private async Task ReadWriteAsync(DateTime expected, CancellationToken cancellationToken = default(CancellationToken)) |
| 61 | + { |
| 62 | + // Add an hour to check it is correctly ignored once read back from db. |
| 63 | + var basic = new DateClass { DateValue = expected.AddHours(1) }; |
| 64 | + object savedId; |
| 65 | + using (var s = OpenSession()) |
| 66 | + { |
| 67 | + savedId = await (s.SaveAsync(basic, cancellationToken)); |
| 68 | + await (s.FlushAsync(cancellationToken)); |
| 69 | + } |
| 70 | + using (var s = OpenSession()) |
| 71 | + { |
| 72 | + basic = await (s.GetAsync<DateClass>(savedId, cancellationToken)); |
| 73 | + Assert.That(basic.DateValue, Is.EqualTo(expected)); |
| 74 | + await (s.DeleteAsync(basic, cancellationToken)); |
| 75 | + await (s.FlushAsync(cancellationToken)); |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | +} |
0 commit comments