From 0efecd6601a6f8e170d945e97ff6f4f9b445e7e8 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 6 May 2020 17:00:34 -0700 Subject: [PATCH] Fix tests, like the TODO said --- DICUI.Library/Data/Options.cs | 4 ++-- DICUI.Library/Utilities/DumpEnvironment.cs | 6 ------ DICUI.Test/Utilities/DumpEnvironmentTest.cs | 21 ++++++++------------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/DICUI.Library/Data/Options.cs b/DICUI.Library/Data/Options.cs index 369be6ea..5759c7a0 100644 --- a/DICUI.Library/Data/Options.cs +++ b/DICUI.Library/Data/Options.cs @@ -6,7 +6,7 @@ namespace DICUI.Data { public class Options : IDictionary { - private Dictionary _settings = new Dictionary(); + private Dictionary _settings; #region Internal Program @@ -181,7 +181,7 @@ namespace DICUI.Data /// public Options(Dictionary settings = null) { - this._settings = settings; + this._settings = settings ?? new Dictionary(); } /// diff --git a/DICUI.Library/Utilities/DumpEnvironment.cs b/DICUI.Library/Utilities/DumpEnvironment.cs index eb4b7fc5..0748f257 100644 --- a/DICUI.Library/Utilities/DumpEnvironment.cs +++ b/DICUI.Library/Utilities/DumpEnvironment.cs @@ -141,12 +141,6 @@ namespace DICUI.Utilities #endregion - /// - /// Empty constructor for testing only - /// - /// TODO: Remove this and fix tests - public DumpEnvironment() { } - /// /// Constructor for a full DumpEnvironment object from user information /// diff --git a/DICUI.Test/Utilities/DumpEnvironmentTest.cs b/DICUI.Test/Utilities/DumpEnvironmentTest.cs index 3798a95b..ff11a705 100644 --- a/DICUI.Test/Utilities/DumpEnvironmentTest.cs +++ b/DICUI.Test/Utilities/DumpEnvironmentTest.cs @@ -16,14 +16,12 @@ namespace DICUI.Test [InlineData("stop D", 'D', false, MediaType.DVD, true)] public void ParametersValidTest(string parameters, char letter, bool isFloppy, MediaType? mediaType, bool expected) { - var env = new DumpEnvironment - { - Parameters = new DiscImageCreator.Parameters(parameters), - Drive = isFloppy - ? new Drive(InternalDriveType.Floppy, new DriveInfo(letter.ToString())) - : new Drive(InternalDriveType.Optical, new DriveInfo(letter.ToString())), - Type = mediaType, - }; + var options = new Options() { InternalProgram = "dic" }; + var drive = isFloppy + ? new Drive(InternalDriveType.Floppy, new DriveInfo(letter.ToString())) + : new Drive(InternalDriveType.Optical, new DriveInfo(letter.ToString())); + + var env = new DumpEnvironment(options, string.Empty, string.Empty, drive, KnownSystem.IBMPCCompatible, mediaType, parameters); bool actual = env.ParametersValid(); Assert.Equal(expected, actual); @@ -40,11 +38,8 @@ namespace DICUI.Test [InlineData("superhero", "blah&foo.bin", "superhero", "blah&foo.bin")] public void FixOutputPathsTest(string outputDirectory, string outputFilename, string expectedOutputDirectory, string expectedOutputFilename) { - var env = new DumpEnvironment - { - OutputDirectory = outputDirectory, - OutputFilename = outputFilename, - }; + var options = new Options() { InternalProgram = "dic" }; + var env = new DumpEnvironment(options, outputDirectory, outputFilename, null, KnownSystem.IBMPCCompatible, MediaType.CDROM, string.Empty); env.FixOutputPaths(); Assert.Equal(expectedOutputDirectory, env.OutputDirectory);