public async Task CountAsync_NoValues() { EntityMapping.RegisterType(typeof(QueryableAsyncModel)); var connection = TestConfiguration.GetConnection(); var context = new MongoDbContext(connection); var provider = new MongoFrameworkQueryProvider <QueryableAsyncModel>(connection); var queryable = new MongoFrameworkQueryable <QueryableAsyncModel>(provider); context.SaveChanges(); var result = await queryable.CountAsync(); Assert.AreEqual(0, result); }
public async Task CountAsync_WithPredicate() { EntityMapping.RegisterType(typeof(QueryableAsyncModel)); var connection = TestConfiguration.GetConnection(); var context = new MongoDbContext(connection); var provider = new MongoFrameworkQueryProvider <QueryableAsyncModel>(connection); var queryable = new MongoFrameworkQueryable <QueryableAsyncModel>(provider); context.ChangeTracker.SetEntityState(new QueryableAsyncModel { Title = "CountAsync_WithPredicate.1" }, EntityEntryState.Added); context.ChangeTracker.SetEntityState(new QueryableAsyncModel { Title = "CountAsync_WithPredicate.2" }, EntityEntryState.Added); context.SaveChanges(); var result = await queryable.CountAsync(e => e.Title == "CountAsync_WithPredicate.2"); Assert.AreEqual(1, result); }