public void DeleteByIdentityId_WhenItemExists_ItemIsDeletedFromAllTables() { var id = 1; var item = new SimpleIdentityItem { Id = 1, Key = "A" }; using (var unitOfWork = Database.CreateUnitOfWork()) { unitOfWork.Insert(item); unitOfWork.Commit(); } using (var unitOfWork = Database.CreateUnitOfWork()) { unitOfWork.DeleteById<SimpleIdentityItem>(id); unitOfWork.Commit(); } var structureTable = GetStructureTableName<SimpleIdentityItem>(); var structureRowCount = DbHelper.RowCount(structureTable, "Id = '{0}'".Inject(id)); Assert.AreEqual(0, structureRowCount); var indexesTable = GetIndexesTableName<SimpleIdentityItem>(); var indexesRowCount = DbHelper.RowCount(indexesTable, "StructureId = '{0}'".Inject(id)); Assert.AreEqual(0, indexesRowCount); var uniquesTable = GetUniquesTableName<SimpleIdentityItem>(); var uniquesRowCount = DbHelper.RowCount(uniquesTable, "StructureId = '{0}'".Inject(id)); Assert.AreEqual(0, uniquesRowCount); }
public void DeleteByIdentityId_WhenItemExists_ReturnsTrue() { bool wasDeleted; using (var unitOfWork = Database.CreateUnitOfWork()) { var item = new SimpleIdentityItem { Key = "A" }; unitOfWork.Insert(item); unitOfWork.Commit(); wasDeleted = unitOfWork.DeleteById<SimpleIdentityItem>(item.Id); unitOfWork.Commit(); } Assert.IsTrue(wasDeleted); }