diff --git a/Intel8080/Intel8080.Test/Program.cs b/Intel8080/Intel8080.Test/Program.cs index 1cff8a4..e5e4b10 100644 --- a/Intel8080/Intel8080.Test/Program.cs +++ b/Intel8080/Intel8080.Test/Program.cs @@ -14,10 +14,8 @@ namespace Intel8080.Test configuration.DebugMode = true; #endif - using (var harness = new TestHarness(configuration)) - { - harness.Run(); - } + var harness = new TestHarness(configuration); + harness.Run(); } } } diff --git a/Intel8080/Intel8080.Test/TestHarness.cs b/Intel8080/Intel8080.Test/TestHarness.cs index ffdad45..46e8cc2 100644 --- a/Intel8080/Intel8080.Test/TestHarness.cs +++ b/Intel8080/Intel8080.Test/TestHarness.cs @@ -4,24 +4,13 @@ namespace Intel8080.Test { - using System; using System.Diagnostics; - internal class TestHarness : IDisposable + internal class TestHarness(Configuration configuration) { - private readonly Stopwatch timer = new Stopwatch(); - private readonly Board board; - private long totalCycles = 0; - - private bool disposed = false; - - public TestHarness(Configuration configuration) => this.board = new Board(configuration); - - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } + private readonly Stopwatch timer = new(); + private readonly Board board = new(configuration); + private long totalCycles; public void Run() { @@ -37,20 +26,9 @@ namespace Intel8080.Test } this.timer.Stop(); - } - protected virtual void Dispose(bool disposing) - { - if (!this.disposed) - { - if (disposing) - { - System.Console.Out.WriteLine($"\n\nGuest cycles = {this.totalCycles}"); - System.Console.Out.WriteLine($"Seconds = {this.timer.ElapsedMilliseconds / 1000.0}"); - } - - this.disposed = true; - } + System.Console.Out.WriteLine($"\n\nGuest cycles = {this.totalCycles}"); + System.Console.Out.WriteLine($"Seconds = {this.timer.ElapsedMilliseconds / 1000.0}"); } } } diff --git a/M6502/M6502.Test/Program.cs b/M6502/M6502.Test/Program.cs index 618fd1b..e57b7f8 100644 --- a/M6502/M6502.Test/Program.cs +++ b/M6502/M6502.Test/Program.cs @@ -11,12 +11,10 @@ namespace M6502.Test var configuration = new Configuration(); #if DEBUG - configuration.DebugMode; + configuration.DebugMode = false; #endif - using (var harness = new TestHarness(configuration)) - { - harness.Run(); - } + var harness = new TestHarness(configuration); + harness.Run(); } } } diff --git a/MC6809/MC6809.Test/Program.cs b/MC6809/MC6809.Test/Program.cs index 5d6c992..c9d10fd 100644 --- a/MC6809/MC6809.Test/Program.cs +++ b/MC6809/MC6809.Test/Program.cs @@ -14,10 +14,8 @@ namespace EightBit configuration.DebugMode = true; #endif - using (var harness = new TestHarness(configuration)) - { - harness.Run(); - } + var harness = new TestHarness(configuration); + harness.Run(); } } } diff --git a/MC6809/MC6809.Test/TestHarness.cs b/MC6809/MC6809.Test/TestHarness.cs index 86fc582..d9dd6f8 100644 --- a/MC6809/MC6809.Test/TestHarness.cs +++ b/MC6809/MC6809.Test/TestHarness.cs @@ -4,24 +4,13 @@ namespace EightBit { - using System; using System.Diagnostics; - internal class TestHarness : IDisposable + internal sealed class TestHarness(Configuration configuration) { - private readonly Stopwatch timer = new Stopwatch(); - private readonly Board board; - private long totalCycles = 0; - - private bool disposed = false; - - public TestHarness(Configuration configuration) => this.board = new Board(configuration); - - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } + private readonly Stopwatch timer = new(); + private readonly Board board = new(configuration); + private long totalCycles; public void Run() { @@ -37,20 +26,9 @@ namespace EightBit } this.timer.Stop(); - } - protected virtual void Dispose(bool disposing) - { - if (!this.disposed) - { - if (disposing) - { - System.Console.Out.WriteLine($"\n\nGuest cycles = {this.totalCycles}"); - System.Console.Out.WriteLine($"Seconds = {this.timer.ElapsedMilliseconds / 1000.0}"); - } - - this.disposed = true; - } + System.Console.Out.WriteLine($"\n\nGuest cycles = {this.totalCycles}"); + System.Console.Out.WriteLine($"Seconds = {this.timer.ElapsedMilliseconds / 1000.0}"); } } }