[source,vbnet] ---- Public Sub UsingTest() Console.ForegroundColor = ConsoleColor.Black Try Using alert As New ConsoleAlert() Assert.AreEqual(ConsoleColor.Red, Console.ForegroundColor) Throw New InvalidOperationException() End Using Finally Assert.AreEqual(ConsoleColor.Black, Console.ForegroundColor) ' The exception itself is not relevant for the test. End Try End Sub Public NotInheritable Class ConsoleAlert Implements IDisposable Private ReadOnly previous As ConsoleColor Public Sub New() previous = Console.ForegroundColor Console.ForegroundColor = ConsoleColor.Red End Sub Public Sub Dispose() Implements IDisposable.Dispose Console.ForegroundColor = previous End Sub End Class ----