Exemple #1
0
 public void Dispose()
 {
     if (IsValueCreated)
     {
         VerifyDisposed();
         Value.TryDispose();
     }
     _disposableTracker.Dispose();
 }
        public void AddAfterTrackerDisposedDisposesObjectImmediately()
        {
            var tracker    = new DisposableTracker();
            var disposable = new Disposable();

            tracker.Dispose();
            tracker.Track(disposable);

            Assert.IsTrue(
                disposable.IsDisposed,
                "the disposable should be disposed immediately when added to a disposed tracker");
        }
 public void Dispose()
 {
     lock (_handlers)
     {
         VerifyDisposed();
         foreach (GatewayStream stream in _streams)
         {
             stream.Dispose();
         }
         for (short i = 0; i < DataHandlersMaxCount; i++)
         {
             _handlers[i] = null;
         }
         _streams.Clear();
         _disposableTracker.Dispose();
     }
 }
Exemple #4
0
 public void Dispose()
 {
     lock (_handlers)
     {
         VerifyDisposed();
         foreach (INativeDataHandler handler in _handlers.Values)
         {
             //We should dispose routers created by us because they contain unmanaged memory that should be removed
             NativeDataHandlerRouter router = handler as NativeDataHandlerRouter;
             if (router != null)
             {
                 router.Dispose();
             }
         }
         _agentLibrary.GatewayServerDestroy(_token);
         _disposableTracker.Dispose();
     }
 }
        public void DisposingTrackerDisposesTrackedObjects()
        {
            var tracker = new DisposableTracker();

            var disposableA = new Disposable();
            var disposableB = new Disposable();

            tracker.Track(disposableA);
            tracker.Track(disposableB);

            Assert.IsFalse(disposableA.IsDisposed);
            Assert.IsFalse(disposableB.IsDisposed);

            tracker.Dispose();

            Assert.IsTrue(disposableA.IsDisposed, "the tracker should dispose all tracked objects (A) when disposed");
            Assert.IsTrue(disposableB.IsDisposed, "the tracker should dispose all tracked objects (B) when disposed");
        }
        public void DisposeRemovesAllDisposables()
        {
            // Arrange
            var builder = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => new DisposableSpy()
            };
            var sut = new DisposableTracker(builder);

            var dummyRequest = new object();
            var dummyContext = new DelegatingSpecimenContext();

            sut.Create(dummyRequest, dummyContext);
            sut.Create(dummyRequest, dummyContext);
            sut.Create(dummyRequest, dummyContext);
            // Act
            sut.Dispose();
            // Assert
            Assert.Empty(sut.Disposables);
        }
        public void DisposeRemovesAllDisposables()
        {
            // Fixture setup
            var builder = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => new DisposableSpy()
            };
            var sut = new DisposableTracker(builder);

            var dummyRequest = new object();
            var dummyContext = new DelegatingSpecimenContext();

            sut.Create(dummyRequest, dummyContext);
            sut.Create(dummyRequest, dummyContext);
            sut.Create(dummyRequest, dummyContext);
            // Exercise system
            sut.Dispose();
            // Verify outcome
            Assert.Empty(sut.Disposables);
            // Teardown
        }
        public void DisposeDisposesAllDisposables()
        {
            // Arrange
            var disposables = Enumerable.Repeat <Func <DisposableSpy> >(() => new DisposableSpy(), 3).Select(f => f()).ToList();
            var q           = new Queue <DisposableSpy>(disposables);
            var builder     = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => q.Dequeue()
            };

            var sut = new DisposableTracker(builder);

            var dummyRequest = new object();
            var dummyContext = new DelegatingSpecimenContext();

            disposables.ForEach(d => sut.Create(dummyRequest, dummyContext));
            // Act
            sut.Dispose();
            // Assert
            Assert.True(sut.Disposables.Cast <DisposableSpy>().All(ds => ds.Disposed));
        }
 public void Dispose() => tracker.Dispose();
 public void Dispose()
 {
     clearLayout();
     dt.Dispose();
 }
Exemple #11
0
 public virtual void Dispose()
 {
     _disposableTracker.Dispose();
 }
Exemple #12
0
 public void destroy()
 {
     dt.Dispose();
     java.Call("destroy");
 }
Exemple #13
0
 public void Dispose()
 {
     tracker.Dispose();
 }
Exemple #14
0
 public void OnDisable()
 {
     dt.Dispose();
 }
Exemple #15
0
 public virtual void Dispose()
 {
     VerifyDisposed();
     UninitializeSponsorship(RemoteObject, _sponsorshipCookie);
     _disposableTracker.Dispose();
 }