public async Task ExistsEntityTest() { IAsyncRepositoryFactory factory = new MongoAsyncRepositoryFactory(connectionString, "testDb"); IAsyncRepository <Entity> entityRepository = factory.CreateAsyncRepository <Entity>("testCollection"); var initial = new Entity() { Id = Guid.NewGuid(), Name = "created" }; await entityRepository.Create(initial); var actual = await entityRepository.Exists(x => x.Id == initial.Id); Assert.True(actual); var deleted = await entityRepository.Delete(x => x.Id == initial.Id); actual = await entityRepository.Exists(x => x.Id == initial.Id); Assert.True(!actual); }
public async Task FindEntityTest() { IAsyncRepositoryFactory factory = new MongoAsyncRepositoryFactory(connectionString, "testDb"); IAsyncRepository <Entity> entityRepository = factory.CreateAsyncRepository <Entity>("testCollection"); var list = await entityRepository.Find(x => true); var actual = list.Count; for (int i = 0; i < 10; i++) { await entityRepository.Create(new Entity() { Id = Guid.NewGuid(), Name = "created" }); } list = await entityRepository.Find(x => true); var expected = list.Count; Assert.Equal(actual + 10, expected); }