public async Task CanProcessQueryAsync(string query, string expected, bool isValid, bool usesPremiumFeatures) { var context = new ElasticQueryVisitorContext(); IQueryNode result; try { result = await _parser.ParseAsync(query, QueryType.Query, context).AnyContext(); } catch (Exception ex) { _logger.Error(ex, $"Error parsing query: {query}. Message: {ex.Message}"); if (isValid) { throw; } return; } // NOTE: we have to do this because we don't have access to the right query parser instance. result = await EventFieldsQueryVisitor.RunAsync(result, context); Assert.Equal(expected, await GenerateQueryVisitor.RunAsync(result, context)); var info = await _validator.ValidateQueryAsync(result); _logger.Info(() => $"UsesPremiumFeatures: {info.UsesPremiumFeatures} IsValid: {info.IsValid} Message: {info.Message}"); Assert.Equal(isValid, info.IsValid); Assert.Equal(usesPremiumFeatures, info.UsesPremiumFeatures); }