public async Task AppliesOptionsToQueryAsync()
        {
            var session = Substitute.For <ISessionImplementor>();

            session.Factory.Settings.Returns(new Settings());

            var query = Substitute.For <IQuery>();

            query.ListAsync().Returns(Task.FromResult((IList) new List <Order>()));

            session.CreateQuery(Arg.Any <IQueryExpression>()).Returns(query);

            var queryable = new NhQueryable <Order>(session)
                            .WithOptions(
                x => x
                .SetCacheable(true)
                .SetCacheMode(CacheMode.Normal)
                .SetCacheRegion("testregion")
                .SetTimeout(10)
                );

            var t = await(queryable.ToListAsync());

            query.Received(1).SetCacheable(true);
            query.Received(1).SetCacheMode(CacheMode.Normal);
            query.Received(1).SetCacheRegion("testregion");
            query.Received(1).SetTimeout(10);

            // Prevent garbage collection of session substitute before end of test, since the Linq query provider
            // only has a weak reference on it.
            Assert.That(session, Is.Not.Null);
        }
        public async Task AppliesOptionsToQueryAsync()
        {
            var session = Substitute.For <ISessionImplementor>();

            session.Factory.Settings.Returns(new Settings());

            var query = Substitute.For <IQuery>();

            query.ListAsync().Returns(Task.FromResult((IList) new List <Order>()));

            session.CreateQuery(Arg.Any <IQueryExpression>()).Returns(query);

            var queryable = new NhQueryable <Order>(session)
                            .WithOptions(
                x => x
                .SetCacheable(true)
                .SetCacheMode(CacheMode.Normal)
                .SetCacheRegion("testregion")
                .SetTimeout(10)
                );

            var t = await(queryable.ToListAsync());

            query.Received(1).SetCacheable(true);
            query.Received(1).SetCacheMode(CacheMode.Normal);
            query.Received(1).SetCacheRegion("testregion");
            query.Received(1).SetTimeout(10);
        }