예제 #1
0
        private static async Task <DebugSession> CreateDebugSession(DisposableTracker tracker)
        {
            var taskTarget = tracker.Track(new HeapAnalysisTargetProcess());
            var process    = taskTarget.Start();
            await taskTarget.WaitForTask();

            return(tracker.Track(DebugSession.Create(ProcessInfo.FromProcess(process), DebugMode.Snapshot)));
        }
예제 #2
0
        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");
        }
예제 #3
0
        public void AddReturnsSameInstance()
        {
            var tracker    = new DisposableTracker();
            var disposable = new Disposable();

            Assert.AreSame(
                disposable, tracker.Track(disposable),
                "the value returned by Add should be the same as the passed object");
        }
예제 #4
0
        public static HeapAnalysisScope LoadMemoryDump(string filePath)
        {
            using (var tracker = new DisposableTracker())
            {
                var session = tracker.Track(DebugSession.Load(filePath));
                var subject = GetSubjectFromSession(session);

                return(tracker.TransferOwnershipTo(t => new HeapAnalysisScope(t, subject)));
            }
        }
예제 #5
0
        public void AddBeforeTrackerDisposedDoesNotDisposeItem()
        {
            var tracker = new DisposableTracker();

            var disposable = new Disposable();

            tracker.Track(disposable);

            Assert.IsFalse(
                disposable.IsDisposed,
                "the disposable should not be disposed until the tracker is");
        }
예제 #6
0
        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");
        }