|
3 | 3 | using FluentAssertions;
|
4 | 4 | using NUnit.Framework;
|
5 | 5 | using RomanticWeb.Entities;
|
| 6 | +using RomanticWeb.TestEntities; |
6 | 7 | using RomanticWeb.TestEntities.Foaf;
|
7 | 8 | using RomanticWeb.Tests.Helpers;
|
8 | 9 | using RomanticWeb.Tests.Stubs;
|
9 | 10 | using RomanticWeb.Vocabularies;
|
10 | 11 | using VDS.RDF;
|
11 | 12 | using VDS.RDF.Query.Builder;
|
| 13 | +using IPerson = RomanticWeb.TestEntities.Foaf.IPerson; |
12 | 14 |
|
13 | 15 | namespace RomanticWeb.Tests.IntegrationTests
|
14 | 16 | {
|
@@ -353,6 +355,49 @@ public void Should_allow_modifying_retrieved_nodes_where_some_are_blank()
|
353 | 355 | eb => eb.Str(eb.Variable("street")) == "Litzmannstadt");
|
354 | 356 | }
|
355 | 357 |
|
| 358 | + [Test] |
| 359 | + public void Shoud_not_commit_volatile_deleted_entity() |
| 360 | + { |
| 361 | + // given |
| 362 | + var entityId = new Uri("http://magi/people/Tomasz"); |
| 363 | + var tempId = new Uri("http://magi/people/TomaszTwo"); |
| 364 | + |
| 365 | + // when |
| 366 | + var person = EntityContext.Create<IPerson>(entityId); |
| 367 | + var tempPerson = EntityContext.Create<IPerson>(tempId); |
| 368 | + tempPerson.Name = "Tomasz"; |
| 369 | + person.Name = person.Name; |
| 370 | + EntityContext.Delete(tempId); |
| 371 | + EntityContext.Commit(); |
| 372 | + |
| 373 | + // then |
| 374 | + Store.Should().NotMatchAsk(tpb => tpb.Subject(tempId).Predicate("p").Object("o")); |
| 375 | + Store.Should().NotMatchAsk(tpb => tpb.Subject("s").Predicate("p").Object(tempId)); |
| 376 | + } |
| 377 | + |
| 378 | + [Test] |
| 379 | + public void Shoud_not_commit_volatile_deleted_entity_with_list() |
| 380 | + { |
| 381 | + // given |
| 382 | + var tempId = new Uri("temp://magi/people/Tomasz"); |
| 383 | + var saved = EntityContext.Create<IEntityWithCollections>(new Uri("http://magi/people/Tomasz")); |
| 384 | + var temp = EntityContext.Create<IEntityWithCollections>(tempId); |
| 385 | + temp.DefaultListMapping.Add("test 1"); |
| 386 | + temp.DefaultListMapping.Add("test 2"); |
| 387 | + foreach (var val in temp.DefaultListMapping) |
| 388 | + { |
| 389 | + saved.DefaultListMapping.Add(val); |
| 390 | + } |
| 391 | + |
| 392 | + // when |
| 393 | + EntityContext.Delete(tempId); |
| 394 | + EntityContext.Commit(); |
| 395 | + |
| 396 | + // then |
| 397 | + Store.Should().NotMatchAsk(tpb => tpb.Subject(tempId).Predicate("p").Object("o")); |
| 398 | + Store.Should().NotMatchAsk(tpb => tpb.Subject("s").Predicate("p").Object(tempId)); |
| 399 | + } |
| 400 | + |
356 | 401 | protected override void ChildSetup()
|
357 | 402 | {
|
358 | 403 | Factory.WithNamedGraphSelector(new TestGraphSelector());
|
|
0 commit comments