Ejemplo n.º 1
0
        public Task ExecuteAsync(SpecContext context, CancellationToken cancellation)
        {
            var record = context.Timings.Subject("Grammar", _grammar.Key, _maximumRuntimeInMilliseconds);


            var fetch = _comparison.Fetch(context);

            if (!convertData(context, record))
            {
                return(Task.CompletedTask);
            }


            return(fetch.ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    // TODO -- do the Flatten() trick here on the aggregated exception
                    context.LogException(_section.id, t.Exception, record, Stage.before);

                    return;
                }

                if (t.IsCompleted)
                {
                    var result = CreateResults(_expected, t.Result);
                    result.id = _section.id;
                    context.LogResult(result, record);

                    context.Timings.End(record, result);
                }
            }, cancellation));
        }
Ejemplo n.º 2
0
        public void Execute(SpecContext context)
        {
            using (context.Timings.Subject("Grammar", _section.Key))
            {
                var fetch = _comparison.Fetch(context);

                _expected.Each(x =>
                {
                    x.DoDelayedConversions(context);
                    if (!x.Errors.Any())
                    {
                        return;
                    }

                    context.LogResult(x.ToConversionErrorResult());
                });

                if (_expected.Any(x => x.HasErrors()))
                {
                    return;
                }

                fetch.ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        // TODO -- do the Flatten() trick here on the aggregated exception
                        context.LogException(_section.id, t.Exception, Stage.before);
                        return;
                    }

                    if (t.IsCompleted)
                    {
                        var result = CreateResults(_expected, t.Result);
                        result.id  = _section.id;
                        context.LogResult(result);
                    }
                }).Wait();
            }
        }