2019-11-17 01:06:41 -05:00
|
|
|
|
using System.IO;
|
2021-09-29 11:48:37 -07:00
|
|
|
|
using MPF.Core.Data;
|
2021-09-29 15:05:17 -07:00
|
|
|
|
using MPF.Library;
|
2023-09-05 00:08:09 -04:00
|
|
|
|
using SabreTools.RedumpLib.Data;
|
2018-06-28 19:41:18 -07:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
2021-11-24 22:19:57 -08:00
|
|
|
|
namespace MPF.Test.Library
|
2018-06-28 19:41:18 -07:00
|
|
|
|
{
|
2021-11-24 22:19:57 -08:00
|
|
|
|
public class DumpEnvironmentTests
|
2018-06-28 19:41:18 -07:00
|
|
|
|
{
|
|
|
|
|
|
[Theory]
|
2018-07-05 20:30:52 +02:00
|
|
|
|
[InlineData(null, 'D', false, MediaType.NONE, false)]
|
|
|
|
|
|
[InlineData("", 'D', false, MediaType.NONE, false)]
|
2018-09-20 21:25:22 -07:00
|
|
|
|
[InlineData("cd F test.bin 8 /c2 20", 'F', false, MediaType.CDROM, true)]
|
2018-09-20 21:30:13 -07:00
|
|
|
|
[InlineData("fd A test.img", 'A', true, MediaType.FloppyDisk, true)]
|
|
|
|
|
|
[InlineData("dvd X test.iso 8 /raw", 'X', false, MediaType.FloppyDisk, false)]
|
2018-07-05 20:30:52 +02:00
|
|
|
|
[InlineData("stop D", 'D', false, MediaType.DVD, true)]
|
More and more cleanup (#86)
* Namespace cleanups
* Make dump validation instanced
* Add note to Tasks
* Move stuff to DumpEnvironment
Most of the stuff in Tasks.cs acted on a single input parameter, namely a DumpEnvironment. Since that's the case, it was more logical to wrap those into DumpEnvironment and make them instance methods rather than keep them static. Due to this change, quite a few methods changed access, and some had to be marked internal due to wanting them to be tested separately.
* Gut Tasks
* One less thing in MainWindow
* Remove explicit cast
* Wrong check
* Create helper method
* Disable scan button on dump
* Remove unnecessary getters/setters
* Method name/description cleanup
* Address TODO
* Namespace cleanups
* Make dump validation instanced
* Add note to Tasks
* Move stuff to DumpEnvironment
Most of the stuff in Tasks.cs acted on a single input parameter, namely a DumpEnvironment. Since that's the case, it was more logical to wrap those into DumpEnvironment and make them instance methods rather than keep them static. Due to this change, quite a few methods changed access, and some had to be marked internal due to wanting them to be tested separately.
* Gut Tasks
* One less thing in MainWindow
* Remove explicit cast
* Wrong check
* Create helper method
* Disable scan button on dump
* Remove unnecessary getters/setters
* Method name/description cleanup
* Address TODO
* Clean up OnContentRendered
* Namespace cleanups
* Make dump validation instanced
* Add note to Tasks
* Move stuff to DumpEnvironment
Most of the stuff in Tasks.cs acted on a single input parameter, namely a DumpEnvironment. Since that's the case, it was more logical to wrap those into DumpEnvironment and make them instance methods rather than keep them static. Due to this change, quite a few methods changed access, and some had to be marked internal due to wanting them to be tested separately.
* Gut Tasks
* One less thing in MainWindow
* Remove explicit cast
* Wrong check
* Create helper method
* Disable scan button on dump
* Remove unnecessary getters/setters
* Method name/description cleanup
* Address TODO
* Clean up OnContentRendered
* Update event handlers
2018-07-05 21:34:04 -07:00
|
|
|
|
public void ParametersValidTest(string parameters, char letter, bool isFloppy, MediaType? mediaType, bool expected)
|
2018-06-28 19:41:18 -07:00
|
|
|
|
{
|
2021-03-08 22:19:22 -08:00
|
|
|
|
var options = new Options() { InternalProgram = InternalProgram.DiscImageCreator };
|
2022-04-20 13:47:55 -07:00
|
|
|
|
|
|
|
|
|
|
// TODO: This relies on creating real objects for the drive. Can we mock this out instead?
|
2020-05-06 17:00:34 -07:00
|
|
|
|
var drive = isFloppy
|
2022-04-20 13:47:55 -07:00
|
|
|
|
? Drive.Create(InternalDriveType.Floppy, letter.ToString())
|
|
|
|
|
|
: Drive.Create(InternalDriveType.Optical, letter.ToString());
|
2020-05-06 17:00:34 -07:00
|
|
|
|
|
2023-04-11 11:15:53 -04:00
|
|
|
|
var env = new DumpEnvironment(options, string.Empty, drive, RedumpSystem.IBMPCcompatible, mediaType, null, parameters);
|
2018-06-28 19:41:18 -07:00
|
|
|
|
|
More and more cleanup (#86)
* Namespace cleanups
* Make dump validation instanced
* Add note to Tasks
* Move stuff to DumpEnvironment
Most of the stuff in Tasks.cs acted on a single input parameter, namely a DumpEnvironment. Since that's the case, it was more logical to wrap those into DumpEnvironment and make them instance methods rather than keep them static. Due to this change, quite a few methods changed access, and some had to be marked internal due to wanting them to be tested separately.
* Gut Tasks
* One less thing in MainWindow
* Remove explicit cast
* Wrong check
* Create helper method
* Disable scan button on dump
* Remove unnecessary getters/setters
* Method name/description cleanup
* Address TODO
* Namespace cleanups
* Make dump validation instanced
* Add note to Tasks
* Move stuff to DumpEnvironment
Most of the stuff in Tasks.cs acted on a single input parameter, namely a DumpEnvironment. Since that's the case, it was more logical to wrap those into DumpEnvironment and make them instance methods rather than keep them static. Due to this change, quite a few methods changed access, and some had to be marked internal due to wanting them to be tested separately.
* Gut Tasks
* One less thing in MainWindow
* Remove explicit cast
* Wrong check
* Create helper method
* Disable scan button on dump
* Remove unnecessary getters/setters
* Method name/description cleanup
* Address TODO
* Clean up OnContentRendered
* Namespace cleanups
* Make dump validation instanced
* Add note to Tasks
* Move stuff to DumpEnvironment
Most of the stuff in Tasks.cs acted on a single input parameter, namely a DumpEnvironment. Since that's the case, it was more logical to wrap those into DumpEnvironment and make them instance methods rather than keep them static. Due to this change, quite a few methods changed access, and some had to be marked internal due to wanting them to be tested separately.
* Gut Tasks
* One less thing in MainWindow
* Remove explicit cast
* Wrong check
* Create helper method
* Disable scan button on dump
* Remove unnecessary getters/setters
* Method name/description cleanup
* Address TODO
* Clean up OnContentRendered
* Update event handlers
2018-07-05 21:34:04 -07:00
|
|
|
|
bool actual = env.ParametersValid();
|
2018-06-28 19:41:18 -07:00
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|