public virtual void ExpireAt() { 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.ExpireAt(entity1.Id, DateTime.Now.AddSeconds(2)); var itemsInDatabase2 = entityRepo.GetAll(); Assert.IsTrue(itemsInDatabase.Count == itemsInDatabase2.Count, "entityRepo has not been physically deleted after compact"); Thread.Sleep(4000); // 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"); }
/// <summary> /// Init Set demo /// => Copy files in : C:\Users\abala\AppData\Roaming /// </summary> public virtual void GetAll() { entityRepo.TruncateCollection(); var entity1 = TestHelper.GetEntity1(); entityRepo.InsertOne(entity1); var entity2 = TestHelper.GetEntity2(); entityRepo.InsertOne(entity2); var entity3 = TestHelper.GetEntity3(); entityRepo.InsertOne(entity3); var entity4 = TestHelper.GetEntity4(); entityRepo.InsertOne(entity4); entityRepo.Delete(entity3.Id); var entitylist = entityRepo.GetAll(); Assert.AreEqual(3, entitylist.Count, "Invalide number. The expected result is " + entitylist.Count); foreach (var e in entitylist) { Assert.IsNotNull(e, "Entity returned should not be null"); } var collectionTest = new CollectionTest(); collectionTest.PolymorphCollection.Add(entity1); // TestExtraEltEntity instance var collectionTest2 = new CollectionTest(); collectionTest2.PolymorphCollection.Add(entity2); // TestExtraEltEntity instance collectionEntityRepo.InsertOne(collectionTest); collectionEntityRepo.InsertOne(collectionTest2); var entityCollectionlist = collectionEntityRepo.GetAll(); Assert.AreEqual(2, entityCollectionlist.Count, "Bad number of doc. We should not return entities of an other collection"); var entitylist2 = entityRepo.GetAll(); Assert.AreEqual(3, entitylist2.Count, "Bad number of doc. We should not return entities of an other collection"); collectionEntityRepo.TruncateCollection(); entitylist2 = entityRepo.GetAll(); Assert.AreEqual(3, entitylist2.Count, "Truncate of a collection should not affect other collections"); }
public IReadOnlyCollection <StateModel> ReadAll() { return(NoSQLRepository.GetAll(state => state != null).ToList()); }
/// <summary> /// Charge la liste des logs /// </summary> public IList <Log> GetLogs(IList <LogLevel> filters) { return(repo.GetAll().Where(log => !filters.Any(filter => filter == log.Level)).ToList()); }