public void Dispose_WhenStreamWasOpen_ShouldCloseTheStream() { string path = SpecialPathPolicy.For <LazyFileInspectorTest>().CreateTempFileWithUniqueName().FullName; File.WriteAllText(path, "Contents"); var fileInfo = new FileInfo(path); using (var inspector = new LazyFileInspector(fileInfo)) { Stream returnedStream; inspector.TryGetStream(out returnedStream); inspector.Dispose(); Assert.DoesNotThrow(() => File.Delete(path), "Should be able to delete the file because the stream was closed."); } }