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))); }
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 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"); }
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))); } }
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"); }
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"); }