Example #1
0
        public void RegisterDisposable_Disposable_Is_Null()
        {
            // arrange
            var queryResult = new Mock <IQueryResult>();
            var deferred    = new Mock <IAsyncEnumerable <IQueryResult> >();
            var result      = new DeferredQueryResult(queryResult.Object, deferred.Object);

            // act
            void Action() => result.RegisterDisposable(null !);

            // assert
            Assert.Throws <ArgumentNullException>(Action);
        }
Example #2
0
        public async Task RegisterDisposable()
        {
            // arrange
            var queryResult = new Mock <IQueryResult>();
            var deferred    = new Mock <IAsyncEnumerable <IQueryResult> >();
            var result      = new DeferredQueryResult(queryResult.Object, deferred.Object);
            var disposable  = new TestDisposable();

            // act
            result.RegisterDisposable(disposable);

            // assert
            await result.DisposeAsync();

            Assert.True(disposable.IsDisposed);
        }
        public DeferredQueryResult(DeferredQueryResult queryResult, IDisposable session)
        {
            if (queryResult is null)
            {
                throw new ArgumentNullException(nameof(queryResult));
            }

            if (session is null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            _initialResult   = queryResult._initialResult;
            _deferredResults = queryResult._deferredResults;
            Extensions       = queryResult.Extensions;
            ContextData      = queryResult.ContextData;
            _session         = queryResult._session is not null
                ? new CombinedDispose(queryResult._session, session)
                : session;
        }