public void Does_Not_Share_Failed_Tasks_Untyped_2()
        {
            IResolveFieldContext <int?> rfc1 = null;
            IResolveFieldContext <int?> rfc2 = null;
            var ffr1 = new FuncFieldResolver <int?, object>(context =>
            {
                rfc1 = context;
                throw new Exception();
            });
            var ffr2 = new FuncFieldResolver <int?, object>(context =>
            {
                rfc2 = context;
                return(Task.FromResult("ok"));
            });

            try
            {
                ffr1.Resolve(_context);
            }
            catch { }
            ffr2.Resolve(_context);
            rfc1.ShouldNotBeNull();
            rfc1.ShouldNotBeSameAs(_context);
            rfc2.ShouldNotBeNull();
            rfc2.ShouldNotBeSameAs(_context);
            rfc1.ShouldNotBe(rfc2);
        }
        public void Does_Not_Share_Incomplete_Tasks_Untyped()
        {
            IResolveFieldContext <int?> rfc1 = null;
            IResolveFieldContext <int?> rfc2 = null;
            Func <IResolveFieldContext <int?>, Task <string> > fn1 = async context =>
            {
                rfc1 = context;
                await Task.Delay(100);

                return("ok");
            };
            var ffr1 = new FuncFieldResolver <int?, object>(context => fn1(context));
            Func <IResolveFieldContext <int?>, Task <string> > fn2 = async context =>
            {
                rfc2 = context;
                await Task.Delay(100);

                return("ok");
            };
            var ffr2 = new FuncFieldResolver <int?, object>(context => fn2(context));

            ffr1.Resolve(_context);
            ffr2.Resolve(_context);
            rfc1.ShouldNotBeNull();
            rfc1.ShouldNotBeSameAs(_context);
            rfc2.ShouldNotBeNull();
            rfc2.ShouldNotBeSameAs(_context);
            rfc1.ShouldNotBe(rfc2);
        }
    public async Task Does_Not_Share_Failed_Typed()
    {
        IResolveFieldContext <int?> rfc1 = null;
        IResolveFieldContext <int?> rfc2 = null;
        Func <IResolveFieldContext <int?>, string> func1 = context =>
        {
            rfc1 = context;
            throw new Exception();
        };
        var ffr1 = new FuncFieldResolver <int?, string>(func1);
        var ffr2 = new FuncFieldResolver <int?, string>(context =>
        {
            rfc2 = context;
            return("ok");
        });

        try
        {
            await ffr1.ResolveAsync(_context).ConfigureAwait(false);
        }
        catch { }
        await ffr2.ResolveAsync(_context).ConfigureAwait(false);

        rfc1.ShouldNotBeNull();
        rfc1.ShouldNotBeSameAs(_context);
        rfc2.ShouldNotBeNull();
        rfc2.ShouldNotBeSameAs(_context);
        rfc1.ShouldNotBe(rfc2);
    }
        public void Pass_Through_Object_Source()
        {
            IResolveFieldContext <object> rfc1 = null;
            var ffr1 = new FuncFieldResolver <object, string>(context =>
            {
                rfc1 = context;
                return("ok");
            });

            ffr1.Resolve(_context);
            rfc1.ShouldNotBeNull();
            rfc1.ShouldBeSameAs(_context);
        }
    public async Task Pass_Through_Object_Source()
    {
        IResolveFieldContext <object> rfc1 = null;
        var ffr1 = new FuncFieldResolver <object, string>(context =>
        {
            rfc1 = context;
            return("ok");
        });
        await ffr1.ResolveAsync(_context).ConfigureAwait(false);

        rfc1.ShouldNotBeNull();
        rfc1.ShouldBeSameAs(_context);
    }
        public void Shares_Complete_Untyped()
        {
            IResolveFieldContext <int?> rfc1 = null;
            IResolveFieldContext <int?> rfc2 = null;
            var ffr1 = new FuncFieldResolver <int?, object>(context =>
            {
                rfc1 = context;
                return("ok");
            });
            var ffr2 = new FuncFieldResolver <int?, object>(context =>
            {
                rfc2 = context;
                return("ok");
            });

            ffr1.Resolve(_context);
            ffr2.Resolve(_context);
            rfc1.ShouldNotBeNull();
            rfc1.ShouldNotBeSameAs(_context);
            rfc2.ShouldNotBeNull();
            rfc2.ShouldNotBeSameAs(_context);
            rfc1.ShouldBe(rfc2);
        }
        public void Does_Not_Share_Dataloader_Tasks_Untyped_Derived()
        {
            IResolveFieldContext <int?> rfc1 = null;
            IResolveFieldContext <int?> rfc2 = null;
            var ffr1 = new FuncFieldResolver <int?, object>(context =>
            {
                rfc1 = context;
                return(Task.FromResult(_okDataLoader));
            });
            var ffr2 = new FuncFieldResolver <int?, object>(context =>
            {
                rfc2 = context;
                return(Task.FromResult(_okDataLoader));
            });

            ffr1.Resolve(_context);
            ffr2.Resolve(_context);
            rfc1.ShouldNotBeNull();
            rfc1.ShouldNotBeSameAs(_context);
            rfc2.ShouldNotBeNull();
            rfc2.ShouldNotBeSameAs(_context);
            rfc1.ShouldNotBe(rfc2);
        }
        public void Does_Not_Share_Dataloader_Typed()
        {
            IResolveFieldContext <int?> rfc1 = null;
            IResolveFieldContext <int?> rfc2 = null;
            var ffr1 = new FuncFieldResolver <int?, IDataLoaderResult>(context =>
            {
                rfc1 = context;
                return(_okDataLoader);
            });
            var ffr2 = new FuncFieldResolver <int?, IDataLoaderResult>(context =>
            {
                rfc2 = context;
                return(_okDataLoader);
            });

            ffr1.Resolve(_context);
            ffr2.Resolve(_context);
            rfc1.ShouldNotBeNull();
            rfc1.ShouldNotBeSameAs(_context);
            rfc2.ShouldNotBeNull();
            rfc2.ShouldNotBeSameAs(_context);
            rfc1.ShouldNotBe(rfc2);
        }
        public void Does_Not_Share_Failed_Tasks_Typed_1()
        {
            IResolveFieldContext <int?> rfc1 = null;
            IResolveFieldContext <int?> rfc2 = null;
            var ffr1 = new FuncFieldResolver <int?, Task <string> >(context =>
            {
                rfc1 = context;
                return(Task.FromException <string>(new Exception()));
            });
            var ffr2 = new FuncFieldResolver <int?, Task <string> >(context =>
            {
                rfc2 = context;
                return(Task.FromResult("ok"));
            });

            ffr1.Resolve(_context);
            ffr2.Resolve(_context);
            rfc1.ShouldNotBeNull();
            rfc1.ShouldNotBeSameAs(_context);
            rfc2.ShouldNotBeNull();
            rfc2.ShouldNotBeSameAs(_context);
            rfc1.ShouldNotBe(rfc2);
        }
        public void Shares_Complete_Tasks_Typed()
        {
            IResolveFieldContext <int?> rfc1 = null;
            IResolveFieldContext <int?> rfc2 = null;
            var ffr1 = new FuncFieldResolver <int?, Task <string> >(context =>
            {
                rfc1 = context;
                return(Task.FromResult("ok"));
            });
            var ffr2 = new FuncFieldResolver <int?, Task <string> >(context =>
            {
                rfc2 = context;
                return(Task.FromResult("ok"));
            });

            ffr1.Resolve(_context);
            ffr2.Resolve(_context);
            rfc1.ShouldNotBeNull();
            rfc1.ShouldNotBeSameAs(_context);
            rfc2.ShouldNotBeNull();
            rfc2.ShouldNotBeSameAs(_context);
            rfc1.ShouldBe(rfc2);
        }
        public void Does_Not_Share_Enumerable_Tasks_Untyped()
        {
            IResolveFieldContext <int?> rfc1 = null;
            IResolveFieldContext <int?> rfc2 = null;
            var ffr1 = new FuncFieldResolver <int?, object>(context =>
            {
                rfc1 = context;
                return(Task.FromResult <IEnumerable <int> >(new[] { 1, 2 }));
            });
            var ffr2 = new FuncFieldResolver <int?, object>(context =>
            {
                rfc2 = context;
                return(Task.FromResult <IEnumerable <int> >(new[] { 1, 2 }));
            });

            ffr1.Resolve(_context);
            ffr2.Resolve(_context);
            rfc1.ShouldNotBeNull();
            rfc1.ShouldNotBeSameAs(_context);
            rfc2.ShouldNotBeNull();
            rfc2.ShouldNotBeSameAs(_context);
            rfc1.ShouldNotBe(rfc2);
        }
    public async Task Shares_Complete_Untyped()
    {
        IResolveFieldContext <int?> rfc1 = null;
        IResolveFieldContext <int?> rfc2 = null;
        var ffr1 = new FuncFieldResolver <int?, object>(context =>
        {
            rfc1 = context;
            return("ok");
        });
        var ffr2 = new FuncFieldResolver <int?, object>(context =>
        {
            rfc2 = context;
            return("ok");
        });
        await ffr1.ResolveAsync(_context).ConfigureAwait(false);

        await ffr2.ResolveAsync(_context).ConfigureAwait(false);

        rfc1.ShouldNotBeNull();
        rfc1.ShouldNotBeSameAs(_context);
        rfc2.ShouldNotBeNull();
        rfc2.ShouldNotBeSameAs(_context);
        rfc1.ShouldBe(rfc2);
    }
    public async Task Does_Not_Share_Enumerable_Untyped()
    {
        IResolveFieldContext <int?> rfc1 = null;
        IResolveFieldContext <int?> rfc2 = null;
        var ffr1 = new FuncFieldResolver <int?, object>(context =>
        {
            rfc1 = context;
            return(new[] { 1, 2 });
        });
        var ffr2 = new FuncFieldResolver <int?, object>(context =>
        {
            rfc2 = context;
            return(new[] { 1, 2 });
        });
        await ffr1.ResolveAsync(_context).ConfigureAwait(false);

        await ffr2.ResolveAsync(_context).ConfigureAwait(false);

        rfc1.ShouldNotBeNull();
        rfc1.ShouldNotBeSameAs(_context);
        rfc2.ShouldNotBeNull();
        rfc2.ShouldNotBeSameAs(_context);
        rfc1.ShouldNotBe(rfc2);
    }
    public async Task Does_Not_Share_Dataloader_Typed()
    {
        IResolveFieldContext <int?> rfc1 = null;
        IResolveFieldContext <int?> rfc2 = null;
        var ffr1 = new FuncFieldResolver <int?, IDataLoaderResult>(context =>
        {
            rfc1 = context;
            return(_okDataLoader);
        });
        var ffr2 = new FuncFieldResolver <int?, IDataLoaderResult>(context =>
        {
            rfc2 = context;
            return(_okDataLoader);
        });
        await ffr1.ResolveAsync(_context).ConfigureAwait(false);

        await ffr2.ResolveAsync(_context).ConfigureAwait(false);

        rfc1.ShouldNotBeNull();
        rfc1.ShouldNotBeSameAs(_context);
        rfc2.ShouldNotBeNull();
        rfc2.ShouldNotBeSameAs(_context);
        rfc1.ShouldNotBe(rfc2);
    }