public void NoteHistoryIsSaved()
{
var sample_notes = DbStorageTests.GetSampleNotes ();
using (var storage = new DbStorage (this.connFactory, this.testUser.Username, this.testUser.Manifest, use_history: true)) {
foreach(var note in sample_notes) {
storage.SaveNote (note);
}
}
// modify the notes
using (var storage = new DbStorage (this.connFactory, this.testUser.Username, this.testUser.Manifest, use_history: true)) {
foreach(var note in sample_notes) {
note.Title = "Random new title";
storage.SaveNote (note);
}
}
// for each note there should exist a backup copy
foreach (var note in sample_notes) {
using (var db = connFactory.OpenDbConnection ()) {
var archived_note = db.FirstOrDefault<DBArchivedNote> (n => n.Guid == note.Guid);
Assert.IsNotNull (archived_note);
Assert.AreNotEqual ("Random new title", archived_note.Title);
}
}
}