@@ -50,6 +50,8 @@ protected override void OnTearDown()
5050 await ( s . DeleteAsync ( "from Competition" , cancellationToken ) ) ;
5151
5252 await ( s . DeleteAsync ( "from Employer" , cancellationToken ) ) ;
53+ await ( s . DeleteAsync ( "from Address" , cancellationToken ) ) ;
54+ await ( s . DeleteAsync ( "from Person" , cancellationToken ) ) ;
5355
5456 await ( tx . CommitAsync ( cancellationToken ) ) ;
5557 }
@@ -76,6 +78,8 @@ private void Cleanup()
7678 s . Delete ( "from Competition" ) ;
7779
7880 s . Delete ( "from Employer" ) ;
81+ s . Delete ( "from Address" ) ;
82+ s . Delete ( "from Person" ) ;
7983
8084 tx . Commit ( ) ;
8185 }
@@ -156,6 +160,41 @@ public async Task MergeBidiForeignKeyOneToOneAsync()
156160 }
157161 }
158162
163+ [ Test ]
164+ public async Task MergeBidiPrimayKeyOneToOneAsync ( )
165+ {
166+ Person p ;
167+ using ( ISession s = OpenSession ( ) )
168+ using ( ITransaction tx = s . BeginTransaction ( ) )
169+ {
170+ p = new Person { Name = "steve" } ;
171+ new PersonalDetails { SomePersonalDetail = "I have big feet" , Person = p } ;
172+ await ( s . PersistAsync ( p ) ) ;
173+ await ( tx . CommitAsync ( ) ) ;
174+ }
175+
176+ ClearCounts ( ) ;
177+
178+ p . Details . SomePersonalDetail = p . Details . SomePersonalDetail + " and big hands too" ;
179+ using ( ISession s = OpenSession ( ) )
180+ using ( ITransaction tx = s . BeginTransaction ( ) )
181+ {
182+ p = ( Person ) await ( s . MergeAsync ( p ) ) ;
183+ await ( tx . CommitAsync ( ) ) ;
184+ }
185+
186+ AssertInsertCount ( 0 ) ;
187+ AssertUpdateCount ( 1 ) ;
188+ AssertDeleteCount ( 0 ) ;
189+
190+ using ( ISession s = OpenSession ( ) )
191+ using ( ITransaction tx = s . BeginTransaction ( ) )
192+ {
193+ await ( s . DeleteAsync ( p ) ) ;
194+ await ( tx . CommitAsync ( ) ) ;
195+ }
196+ }
197+
159198 [ Test ]
160199 public async Task MergeDeepTreeAsync ( )
161200 {
0 commit comments