public static async Task Verify <TElement>(this IGremlinQueryBase <TElement> query)
        {
            var testBase = GremlinqTestBase.Current;

            if (testBase is QuerySerializationTest && typeof(TElement) != typeof(object))
            {
                await query.Cast <object>().Verify();
            }
            else if (testBase is QueryIntegrationTest && typeof(TElement) != typeof(JToken))
            {
                await query.Cast <JToken>().Verify();
            }
            else
            {
                var serialized = JsonConvert.SerializeObject(
                    await query
                    .ToArrayAsync(),
                    Formatting.Indented);

                var scrubbed = testBase
                               .Scrubbers()
                               .Aggregate(serialized, (s, func) => func(s));

                await testBase.Verify(scrubbed);
            }
        }
示例#2
0
 public static async Task Verify(this IGremlinQueryBase query, VerifyBase verifyBase)
 {
     await verifyBase.Verify(
         JsonConvert.SerializeObject(
             await query
             .Cast <object>()
             .ToArrayAsync(),
             Formatting.Indented),
         Settings);
 }
 public override Task Verify <TElement>(IGremlinQueryBase <TElement> query) => base.Verify(query.Cast <string>());
 public static async ValueTask <TElement?> SingleOrDefaultAsync <TElement>(this IGremlinQueryBase <TElement> query, CancellationToken ct = default)
 {
     return(await query.Cast <TElement>().Limit(1).ToAsyncEnumerable().SingleOrDefaultAsync(ct));
 }
 public static ValueTask <TElement> FirstAsync <TElement>(this IGremlinQueryBase <TElement> query, CancellationToken ct = default)
 {
     return(query.Cast <TElement>().Limit(1).ToAsyncEnumerable().FirstAsync(ct));
 }
 public static ValueTask <TElement> SingleAsync <TElement>(this IGremlinQueryBase <TElement> query, CancellationToken ct = default) => query
 .Cast <TElement>()
 .Limit(1)
 .ToAsyncEnumerable()
 .SingleAsync(ct);