|
| 1 | +using System.Collections.Generic; |
| 2 | +using MPF.ExecutionContexts.Dreamdump; |
| 3 | +using SabreTools.RedumpLib.Data; |
| 4 | +using Xunit; |
| 5 | + |
| 6 | +namespace MPF.ExecutionContexts.Test |
| 7 | +{ |
| 8 | + public class DreamdumpTests |
| 9 | + { |
| 10 | + #region Default Values |
| 11 | + |
| 12 | + private static readonly Dictionary<string, string?> AllOptions = new() |
| 13 | + { |
| 14 | + [SettingConstants.RereadCount] = "1000", |
| 15 | + [SettingConstants.SectorOrder] = "DATA_C2_SUB", |
| 16 | + }; |
| 17 | + |
| 18 | + // None of these scenarios are actually supported as all are treated like GD-ROM |
| 19 | + [Theory] |
| 20 | + [InlineData(null, null, null, "filename.bin", null, "--retries=20 --image-name=\"filename\" --sector-order=DATA_C2_SUB")] |
| 21 | + [InlineData(RedumpSystem.IBMPCcompatible, MediaType.CDROM, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")] |
| 22 | + [InlineData(RedumpSystem.IBMPCcompatible, MediaType.DVD, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")] |
| 23 | + [InlineData(RedumpSystem.NintendoGameCube, MediaType.NintendoGameCubeGameDisc, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")] |
| 24 | + [InlineData(RedumpSystem.NintendoWii, MediaType.NintendoWiiOpticalDisc, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")] |
| 25 | + [InlineData(RedumpSystem.HDDVDVideo, MediaType.HDDVD, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")] |
| 26 | + [InlineData(RedumpSystem.BDVideo, MediaType.BluRay, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")] |
| 27 | + [InlineData(RedumpSystem.NintendoWiiU, MediaType.NintendoWiiUOpticalDisc, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")] |
| 28 | + public void DefaultValueTest(RedumpSystem? system, |
| 29 | + MediaType? type, |
| 30 | + string? drivePath, |
| 31 | + string filename, |
| 32 | + int? driveSpeed, |
| 33 | + string? expected) |
| 34 | + { |
| 35 | + var context = new ExecutionContext(system, type, drivePath, filename, driveSpeed, AllOptions); |
| 36 | + string? actual = context.GenerateParameters(); |
| 37 | + Assert.Equal(expected, actual); |
| 38 | + } |
| 39 | + |
| 40 | + #endregion |
| 41 | + |
| 42 | + #region Default |
| 43 | + |
| 44 | + [Theory] |
| 45 | + [InlineData("--force-qtoc --train --retries=20 --image-name=image --image-path=path --read-offset=0 --read-at-once=0 --speed=8 --sector-order=so --drive=/dev/sr0")] |
| 46 | + public void DiscTest(string parameters) |
| 47 | + { |
| 48 | + string? expected = "--force-qtoc --train --retries=20 --image-name=\"image\" --image-path=\"path\" --read-offset=0 --read-at-once=0 --speed=8 --sector-order=so --drive=/dev/sr0"; |
| 49 | + var context = new ExecutionContext(parameters); |
| 50 | + string? actual = context.GenerateParameters(); |
| 51 | + Assert.Equal(expected, actual); |
| 52 | + Assert.True(context.IsDumpingCommand()); |
| 53 | + } |
| 54 | + |
| 55 | + [Theory] |
| 56 | + [InlineData("--image-name=\"image name.bin\" --image-path=\"directory name\"")] |
| 57 | + public void SpacesTest(string parameters) |
| 58 | + { |
| 59 | + string? expected = "--image-name=\"image name.bin\" --image-path=\"directory name\""; |
| 60 | + var context = new ExecutionContext(parameters); |
| 61 | + string? actual = context.GenerateParameters(); |
| 62 | + Assert.Equal(expected, actual); |
| 63 | + Assert.True(context.IsDumpingCommand()); |
| 64 | + } |
| 65 | + |
| 66 | + #endregion |
| 67 | + } |
| 68 | +} |
0 commit comments