When writing a test for persistent data, I come up with a test line by line:
[TestMethod]
public void DoCreateDeleteTest() {
PersistentDataStore pds = new PersistentDataStore();
bool createSuccess = pds.Save("id", "payload");
Assert.AreEqual(true, createSuccess);
bool deleteSuccess = pds.Delete("id");
Assert.AreEqual(true, deleteSuccess);
}
While everything works, it seems perfect. The function has no previous dependencies and clears it itself. The problem is this: when the .Save () method performs a save but returns false / failure. The approval error and deletion are not called, so it is not cleared after itself.
After that, data with the name "id" is saved in the database, and all subsequent failures saved.
The only way I can get around this is to do a precautionary deletion before saving, but this seems like a hacking way.
source
share