public void Cannot_commitsession_twice() { var key = Guid.NewGuid().ToString("N"); using (var session = new CachingRepository <string, Document>(_repo)) { session.Run(key, d => { d.Name = "test"; d.Value = "test123"; }); session.Commit(); Should.Throw <ObjectDisposedException>(() => session.Commit()); } }
public void Stores_and_deletes() { bool deleted = false; bool inserted = false; var key = Guid.NewGuid().ToString("N"); using (var session = new CachingRepository <string, Document>(_repo, _ => deleted = true, _ => inserted = true)) { session.Run(key, d => { d.Name = "test"; d.Value = "test123"; }); session.Commit(); } deleted.ShouldBeFalse(); inserted.ShouldBeTrue(); _repo.Get(key).ShouldNotBeNull(); inserted = false; using (var session = new CachingRepository <string, Document>(_repo, _ => deleted = true, _ => inserted = true)) { session.Delete(key); session.IsDeleted(key).ShouldBeTrue(); session.Commit(); } deleted.ShouldBeTrue(); inserted.ShouldBeFalse(); _repo.Get(key).ShouldBeNull(); }