public void Delete_MultipleRowsWithSameValues_DeletesBoth(UserHeapEntity entity) { // Arrange _repository.Insert(entity); _repository.Insert(entity); // Act var deletedEntity = _repository.Delete(entity); // Assert var gotten = _repository.Get(entity); Assert.Null(gotten); }
public void Insert_PreInsertCancels_IsCancelled(UserHeapEntity entity) { // Arrange var repository = new UserHeapRepository(); repository.PreInsert += (preInsertEntity, cancelArgs) => { cancelArgs.Cancel = true; }; // Act && Assert Assert.Throws <CanceledException>(() => repository.Insert(entity)); var gotten = repository.Get(entity); Assert.Null(gotten); }
public void Delete_PreInsertCancels_IsCanceled(UserHeapEntity entity) { // Arrange var repository = new UserHeapRepository(); var insertedEntity = repository.Insert(entity); var shouldCancel = true; repository.PreDelete += (inputEntity, cancelArgs) => { cancelArgs.Cancel = shouldCancel; }; // Act && Assert Assert.Throws <CanceledException>(() => repository.Delete(insertedEntity)); // Assert Assert.NotNull(repository.Get(insertedEntity)); // Cleanup shouldCancel = false; repository.Delete(insertedEntity); }
public void Insert_PostInsertThrows_IsInserted(UserHeapEntity entity) { // Arrange var repository = new UserHeapRepository(); repository.PostInsert += (tmpEntity) => { throw new InvalidOperationException(); }; // Act var insertedEntity = repository.Insert(entity); // Assert try { Assert.Equal(insertedEntity, repository.Get(entity)); } finally { repository.Delete(insertedEntity); } }