public async Task FirstAsync_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 = "FirstAsync_WithPredicate.1" }, EntityEntryState.Added); context.ChangeTracker.SetEntityState(new QueryableAsyncModel { Title = "FirstAsync_WithPredicate.2" }, EntityEntryState.Added); context.SaveChanges(); var result = await queryable.FirstAsync(e => e.Title == "FirstAsync_WithPredicate.2"); Assert.AreEqual("FirstAsync_WithPredicate.2", result.Title); }
public async Task FirstAsync_NoValue() { EntityMapping.RegisterType(typeof(QueryableAsyncModel)); var connection = TestConfiguration.GetConnection(); var provider = new MongoFrameworkQueryProvider <QueryableAsyncModel>(connection); var queryable = new MongoFrameworkQueryable <QueryableAsyncModel>(provider); await Assert.ThrowsExceptionAsync <InvalidOperationException>(async() => await queryable.FirstAsync()); }