Note that there are some explanatory texts on larger screens.

plurals
  1. POdb4o delete isn't working after unit test execution sequence
    primarykey
    data
    text
    <p>I have a small set of unit tests that are working fine until I add a test that is verifying whether my unique constraint is working properly. These aren't really unit tests, they're integration tests.</p> <p>At any rate, if I omit the test validating the unique constraint, all is well with the delete. However, if I add the SerialNumberUniqueConstraint_Test method, it fails and my item class is not null as the delete never occurs. If I move the SerialNumberUniqueConstraint_Test ahead of other tests, the subsequent tests fail with the same UniqueFieldValueConstraintValidationException as well. What am I doing incorrectly?</p> <pre><code> [TestMethod] [ExpectedException( typeof( UniqueFieldValueConstraintViolationException ) )] public void SerialNumberUniqueConstraint_Test() { using( var logic = new ItemLogic() ) { logic.Save( CreateItem() ); } } [TestMethod] public void DeleteItem_Test() { Item item = null; using( var logic = new ItemLogic() ) { logic.Delete( SerialNumber ); } using( var logic = new ItemLogic() ) { item = logic.Retrieve( SerialNumber ); } Assert.IsNull( item ); } private Item CreateItem() { return new Item { Name = "My item", Make = "make", Model = "model", SerialNumber = "1234" }; } public Item Save( Item item ) { Db4oDatabase.Database.Store( item ); Db4oDatabase.Database.Commit(); return this.Retrieve( item.SerialNumber ); } public Item Retrieve( string serialNumber ) { Item item = (from i in Db4oDatabase.Database.AsQueryable&lt;Item&gt;() where i.SerialNumber == serialNumber select i).FirstOrDefault(); return item; } public void Delete( string serialNumber ) { Db4oDatabase.Database.Delete( this.Retrieve( serialNumber ) ); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload