public virtual void Polymorphism() { entityRepo.TruncateCollection(); collectionEntityRepo.TruncateCollection(); TestExtraEltEntity entity2 = TestHelper.GetEntity2(); entityRepo.InsertOne(entity2); Assert.IsFalse(string.IsNullOrEmpty(entity2.Id)); var entity2_repo = entityRepo.GetById(entity2.Id); //entity_repo.LookLikeEachOther(entity); AssertHelper.AreJsonEqual(entity2, entity2_repo, ErrorMsg: "Get of a TestExtraEltEntity instance from a TestEntity repo should return TestExtraEltEntity"); //Assert.AreEqual<TestEntity>(entity1, entity1_repo); var collectionTest = new CollectionTest(); collectionTest.PolymorphCollection.Add(entity2); // TestExtraEltEntity instance collectionTest.PolymorphCollection.Add(TestHelper.GetEntity1()); // TestEntity instance collectionEntityRepo.InsertOne(collectionTest); var collectionTest_fromRepo = collectionEntityRepo.GetById(collectionTest.Id); AssertHelper.AreJsonEqual(collectionTest, collectionTest_fromRepo, ErrorMsg: "Check if collection elements has the good type"); }
public virtual void InsertExtraEltEntity() { entityExtraEltRepo.TruncateCollection(); var entity = TestHelper.GetEntity2(); entityExtraEltRepo.InsertOne(entity); Assert.IsFalse(string.IsNullOrEmpty(entity.Id)); var entity_repo = entityExtraEltRepo.GetById(entity.Id); //entity_repo.LookLikeEachOther(entity); AssertHelper.AreJsonEqual(entity, entity_repo); //Assert.AreEqual<TestEntity>(entity1, entity1_repo); }
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"); }