public void Delete_Should_Wait_To_Remove_Item_If_Item_Exists_In_BatchMode(IRepository <Contact, string> repository) { var contact = new Contact { Name = "Test User" }; repository.Add(contact); var result = repository.Find(c => c.Name == "Test User"); result.ShouldNotBeNull(); using (var batch = repository.BeginBatch()) { batch.Delete(contact); // not really delete until call Save, because in BatchMode result = repository.Find(c => c.Name == "Test User"); result.ShouldNotBeNull(); batch.Commit(); // actually do the delete } result = repository.Get(contact.ContactId); result.ShouldBeNull(); }
public void Add_InBatchMode_Should_Delay_The_Action(IRepository<Contact, string> repository) { using (var batch = repository.BeginBatch()) { batch.Add(new Contact { Name = "Test User 1" }); repository.GetAll().Count().ShouldEqual(0); // shouldn't have really been added yet batch.Add(new Contact { Name = "Test User 2" }); repository.GetAll().Count().ShouldEqual(0); // shouldn't have really been added yet batch.Commit(); } repository.GetAll().Count().ShouldEqual(2); }
public void Add_InBatchMode_Should_Delay_The_Action(IRepository <Contact, string> repository) { using (var batch = repository.BeginBatch()) { batch.Add(new Contact { Name = "Test User 1" }); repository.GetAll().Count().ShouldEqual(0); // shouldn't have really been added yet batch.Add(new Contact { Name = "Test User 2" }); repository.GetAll().Count().ShouldEqual(0); // shouldn't have really been added yet batch.Commit(); } repository.GetAll().Count().ShouldEqual(2); }
public void Delete_Should_Wait_To_Remove_Item_If_Item_Exists_In_BatchMode(IRepository<Contact, string> repository) { var contact = new Contact { Name = "Test User" }; repository.Add(contact); var result = repository.Get(contact.ContactId); result.ShouldNotBeNull(); using (var batch = repository.BeginBatch()) { batch.Delete(contact); // not really delete until call Save, because in BatchMode result = repository.Get(contact.ContactId); result.ShouldNotBeNull(); batch.Commit(); // actually do the delete } result = repository.Get(contact.ContactId); result.ShouldBeNull(); }
public IBatch <T> BeginBatch() { return(Repository.BeginBatch()); }