|
| 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 NHibernate.Cfg.MappingSchema; |
| 12 | +using NHibernate.Dialect; |
| 13 | +using NHibernate.Mapping.ByCode; |
| 14 | +using NUnit.Framework; |
| 15 | + |
| 16 | +namespace NHibernate.Test.DialectTest.SchemaTests |
| 17 | +{ |
| 18 | + using System.Threading.Tasks; |
| 19 | + [TestFixture] |
| 20 | + public class NullInUniqueFixtureAsync: TestCaseMappingByCode |
| 21 | + { |
| 22 | + protected override HbmMapping GetMappings() |
| 23 | + { |
| 24 | + var mapper = new ModelMapper(); |
| 25 | + mapper.Class<Entity>( |
| 26 | + rc => |
| 27 | + { |
| 28 | + rc.Id(x => x.Id, m => m.Generator(Generators.GuidComb)); |
| 29 | + rc.Property(x => x.Name, m => m.Unique(true)); |
| 30 | + rc.Property( |
| 31 | + x => x.Name1, |
| 32 | + m => |
| 33 | + { |
| 34 | + m.NotNullable(true); |
| 35 | + m.UniqueKey("Test"); |
| 36 | + }); |
| 37 | + rc.Property(x => x.Name2, m => m.UniqueKey("Test")); |
| 38 | + }); |
| 39 | + |
| 40 | + return mapper.CompileMappingForAllExplicitlyAddedEntities(); |
| 41 | + } |
| 42 | + |
| 43 | + protected override void OnTearDown() |
| 44 | + { |
| 45 | + using (var session = Sfi.OpenSession()) |
| 46 | + using (var transaction = session.BeginTransaction()) |
| 47 | + { |
| 48 | + session.CreateQuery("delete from Entity").ExecuteUpdate(); |
| 49 | + transaction.Commit(); |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + [Test] |
| 54 | + public async Task InsertNullInUniqueAsync() |
| 55 | + { |
| 56 | + using (var session = OpenSession()) |
| 57 | + using (var transaction = session.BeginTransaction()) |
| 58 | + { |
| 59 | + await (session.SaveAsync(new Entity { Name1 = "1" })); |
| 60 | + await (session.SaveAsync(new Entity { Name = "N", Name1 = "1", Name2 = "2"})); |
| 61 | + await (session.SaveAsync(new Entity { Name = "Na", Name1 = "2", Name2 = "1"})); |
| 62 | + await (session.SaveAsync(new Entity { Name = "Nam", Name1 = "2"})); |
| 63 | + await (transaction.CommitAsync()); |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | +} |
0 commit comments