public virtual void CompactDatabase() { entityRepo.TruncateCollection(); var entity1 = TestHelper.GetEntity1(); entityRepo.InsertOne(entity1); Assert.IsFalse(string.IsNullOrEmpty(entity1.Id), "DocId has not been set during insert"); var itemsInDatabase = entityRepo.GetAll(); // We try to delete the item : entityRepo.Delete(entity1.Id, false); // We compact the database : entityRepo.CompactDatabase(); var itemsInDatabaseAfterCompact = entityRepo.GetAll(); Assert.IsTrue(itemsInDatabaseAfterCompact.Count == itemsInDatabase.Count - 1, "entityRepo has not been physically deleted after compact"); }