Skip to content

Commit 918e4bf

Browse files
committed
Introduce base dump settings type
1 parent 1da7001 commit 918e4bf

18 files changed

Lines changed: 152 additions & 395 deletions

CHANGELIST.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
- Add placeholder CLI media info methods
3434
- Further cleanup in Options
3535
- Move dump settings next to execution contexts
36+
- Introduce base dump settings type
3637

3738
### 3.6.0 (2025-11-28)
3839

MPF.ExecutionContexts.Test/AaruTests.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections.Generic;
21
using MPF.ExecutionContexts.Aaru;
32
using SabreTools.RedumpLib.Data;
43
using Xunit;
@@ -29,13 +28,13 @@ public void ExtensionTest(MediaType? type, string expected)
2928

3029
#region Default Values
3130

32-
private static readonly Dictionary<string, string?> AllOptions = new()
31+
private static readonly BaseDumpSettings AllOptions = new DumpSettings()
3332
{
34-
[SettingConstants.EnableDebug] = "true",
35-
[SettingConstants.EnableVerbose] = "true",
36-
[SettingConstants.ForceDumping] = "true",
37-
[SettingConstants.RereadCount] = "1000",
38-
[SettingConstants.StripPersonalData] = "true",
33+
EnableDebug = true,
34+
EnableVerbose = true,
35+
ForceDumping = true,
36+
RereadCount = 1000,
37+
StripPersonalData = true,
3938
};
4039

4140
[Theory]

MPF.ExecutionContexts.Test/BaseExecutionContextTests.cs

Lines changed: 0 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -1,199 +1,11 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43
using Xunit;
54

65
namespace MPF.ExecutionContexts.Test
76
{
87
public class BaseExecutionContextTests
98
{
10-
#region GetBooleanSetting
11-
12-
[Fact]
13-
public void GetBooleanSetting_InvalidDict_Default()
14-
{
15-
Dictionary<string, string?> settings = [];
16-
string key = "key";
17-
bool defaultValue = false;
18-
19-
bool actual = BaseExecutionContext.GetBooleanSetting(settings, key, defaultValue);
20-
Assert.False(actual);
21-
}
22-
23-
[Fact]
24-
public void GetBooleanSetting_InvalidKey_Default()
25-
{
26-
Dictionary<string, string?> settings = new()
27-
{
28-
["key2"] = "true",
29-
};
30-
string key = "key";
31-
bool defaultValue = false;
32-
33-
bool actual = BaseExecutionContext.GetBooleanSetting(settings, key, defaultValue);
34-
Assert.False(actual);
35-
}
36-
37-
[Fact]
38-
public void GetBooleanSetting_NullValue_Default()
39-
{
40-
Dictionary<string, string?> settings = new()
41-
{
42-
["key"] = null,
43-
};
44-
string key = "key";
45-
bool defaultValue = false;
46-
47-
bool actual = BaseExecutionContext.GetBooleanSetting(settings, key, defaultValue);
48-
Assert.False(actual);
49-
}
50-
51-
[Fact]
52-
public void GetBooleanSetting_InvalidValue_Default()
53-
{
54-
Dictionary<string, string?> settings = new()
55-
{
56-
["key"] = "invalid",
57-
};
58-
string key = "key";
59-
bool defaultValue = false;
60-
61-
bool actual = BaseExecutionContext.GetBooleanSetting(settings, key, defaultValue);
62-
Assert.False(actual);
63-
}
64-
65-
[Fact]
66-
public void GetBooleanSetting_ValidValue_Parsed()
67-
{
68-
Dictionary<string, string?> settings = new()
69-
{
70-
["key"] = "true",
71-
};
72-
string key = "key";
73-
bool defaultValue = false;
74-
75-
bool actual = BaseExecutionContext.GetBooleanSetting(settings, key, defaultValue);
76-
Assert.True(actual);
77-
}
78-
79-
#endregion
80-
81-
#region GetInt32Setting
82-
83-
[Fact]
84-
public void GetInt32Setting_InvalidDict_Default()
85-
{
86-
Dictionary<string, string?> settings = [];
87-
string key = "key";
88-
int defaultValue = -1;
89-
90-
int actual = BaseExecutionContext.GetInt32Setting(settings, key, defaultValue);
91-
Assert.Equal(-1, actual);
92-
}
93-
94-
[Fact]
95-
public void GetInt32Setting_InvalidKey_Default()
96-
{
97-
Dictionary<string, string?> settings = new()
98-
{
99-
["key2"] = "12345",
100-
};
101-
string key = "key";
102-
int defaultValue = -1;
103-
104-
int actual = BaseExecutionContext.GetInt32Setting(settings, key, defaultValue);
105-
Assert.Equal(-1, actual);
106-
}
107-
108-
[Fact]
109-
public void GetInt32Setting_NullValue_Default()
110-
{
111-
Dictionary<string, string?> settings = new()
112-
{
113-
["key"] = null,
114-
};
115-
string key = "key";
116-
int defaultValue = -1;
117-
118-
int actual = BaseExecutionContext.GetInt32Setting(settings, key, defaultValue);
119-
Assert.Equal(-1, actual);
120-
}
121-
122-
[Fact]
123-
public void GetInt32Setting_InvalidValue_Default()
124-
{
125-
Dictionary<string, string?> settings = new()
126-
{
127-
["key"] = "invalid",
128-
};
129-
string key = "key";
130-
int defaultValue = -1;
131-
132-
int actual = BaseExecutionContext.GetInt32Setting(settings, key, defaultValue);
133-
Assert.Equal(-1, actual);
134-
}
135-
136-
[Fact]
137-
public void GetInt32Setting_ValidValue_Parsed()
138-
{
139-
int expected = 12345;
140-
Dictionary<string, string?> settings = new()
141-
{
142-
["key"] = "12345",
143-
};
144-
string key = "key";
145-
int defaultValue = -1;
146-
147-
int actual = BaseExecutionContext.GetInt32Setting(settings, key, defaultValue);
148-
Assert.Equal(expected, actual);
149-
}
150-
151-
#endregion
152-
153-
#region GetStringSetting
154-
155-
[Fact]
156-
public void GetStringSetting_InvalidDict_Default()
157-
{
158-
Dictionary<string, string?> settings = [];
159-
string key = "key";
160-
string? defaultValue = null;
161-
162-
string? actual = BaseExecutionContext.GetStringSetting(settings, key, defaultValue);
163-
Assert.Null(actual);
164-
}
165-
166-
[Fact]
167-
public void GetStringSetting_InvalidKey_Default()
168-
{
169-
Dictionary<string, string?> settings = new()
170-
{
171-
["key2"] = "12345",
172-
};
173-
string key = "key";
174-
string? defaultValue = null;
175-
176-
string? actual = BaseExecutionContext.GetStringSetting(settings, key, defaultValue);
177-
Assert.Null(actual);
178-
}
179-
180-
[Fact]
181-
public void GetStringSetting_ValidValue_Rturned()
182-
{
183-
string expected = "expected";
184-
Dictionary<string, string?> settings = new()
185-
{
186-
["key"] = "expected",
187-
};
188-
string key = "key";
189-
string? defaultValue = null;
190-
191-
string? actual = BaseExecutionContext.GetStringSetting(settings, key, defaultValue);
192-
Assert.Equal(expected, actual);
193-
}
194-
195-
#endregion
196-
1979
#region SplitParameterString
19810

19911
[Fact]

MPF.ExecutionContexts.Test/DiscImageCreatorTests.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Collections.Generic;
2-
using MPF.ExecutionContexts.DiscImageCreator;
1+
using MPF.ExecutionContexts.DiscImageCreator;
32
using SabreTools.RedumpLib.Data;
43
using Xunit;
54

@@ -42,15 +41,15 @@ public void ExtensionTest(MediaType? type, string? expected)
4241

4342
#region Default Values
4443

45-
private static readonly Dictionary<string, string?> AllOptions = new()
44+
private static readonly BaseDumpSettings AllOptions = new DumpSettings()
4645
{
47-
[SettingConstants.DVDRereadCount] = "1000",
48-
[SettingConstants.MultiSectorRead] = "true",
49-
[SettingConstants.MultiSectorReadValue] = "1000",
50-
[SettingConstants.ParanoidMode] = "true",
51-
[SettingConstants.QuietMode] = "true",
52-
[SettingConstants.RereadCount] = "1000",
53-
[SettingConstants.UseCMIFlag] = "true",
46+
DVDRereadCount = 1000,
47+
MultiSectorRead = true,
48+
MultiSectorReadValue = 1000,
49+
ParanoidMode = true,
50+
QuietMode = true,
51+
RereadCount = 1000,
52+
UseCMIFlag = true,
5453
};
5554

5655
[Theory]

MPF.ExecutionContexts.Test/DreamdumpTests.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections.Generic;
21
using MPF.ExecutionContexts.Dreamdump;
32
using SabreTools.RedumpLib.Data;
43
using Xunit;
@@ -9,22 +8,22 @@ public class DreamdumpTests
98
{
109
#region Default Values
1110

12-
private static readonly Dictionary<string, string?> AllOptions = new()
11+
private static readonly BaseDumpSettings AllOptions = new DumpSettings()
1312
{
14-
[SettingConstants.RereadCount] = "1000",
15-
[SettingConstants.SectorOrder] = "DATA_C2_SUB",
13+
RereadCount = 50,
14+
SectorOrder = SectorOrder.DATA_C2_SUB,
1615
};
1716

1817
// None of these scenarios are actually supported as all are treated like GD-ROM
1918
[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")]
19+
[InlineData(null, null, null, "filename.bin", null, "--retries=50 --image-name=\"filename\" --sector-order=DATA_C2_SUB")]
20+
[InlineData(RedumpSystem.IBMPCcompatible, MediaType.CDROM, "/dev/sr0", "path/filename.bin", 2, "--retries=50 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
21+
[InlineData(RedumpSystem.IBMPCcompatible, MediaType.DVD, "/dev/sr0", "path/filename.bin", 2, "--retries=50 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
22+
[InlineData(RedumpSystem.NintendoGameCube, MediaType.NintendoGameCubeGameDisc, "/dev/sr0", "path/filename.bin", 2, "--retries=50 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
23+
[InlineData(RedumpSystem.NintendoWii, MediaType.NintendoWiiOpticalDisc, "/dev/sr0", "path/filename.bin", 2, "--retries=50 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
24+
[InlineData(RedumpSystem.HDDVDVideo, MediaType.HDDVD, "/dev/sr0", "path/filename.bin", 2, "--retries=50 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
25+
[InlineData(RedumpSystem.BDVideo, MediaType.BluRay, "/dev/sr0", "path/filename.bin", 2, "--retries=50 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
26+
[InlineData(RedumpSystem.NintendoWiiU, MediaType.NintendoWiiUOpticalDisc, "/dev/sr0", "path/filename.bin", 2, "--retries=50 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
2827
public void DefaultValueTest(RedumpSystem? system,
2928
MediaType? type,
3029
string? drivePath,
@@ -42,10 +41,10 @@ public void DefaultValueTest(RedumpSystem? system,
4241
#region Default
4342

4443
[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")]
44+
[InlineData("--force-qtoc --train --retries=50 --image-name=image --image-path=path --read-offset=0 --read-at-once=0 --speed=8 --sector-order=so --drive=/dev/sr0")]
4645
public void DiscTest(string parameters)
4746
{
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";
47+
string? expected = "--force-qtoc --train --retries=50 --image-name=\"image\" --image-path=\"path\" --read-offset=0 --read-at-once=0 --speed=8 --sector-order=so --drive=/dev/sr0";
4948
var context = new ExecutionContext(parameters);
5049
string? actual = context.GenerateParameters();
5150
Assert.Equal(expected, actual);

MPF.ExecutionContexts.Test/RedumperTests.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections.Generic;
21
using MPF.ExecutionContexts.Redumper;
32
using SabreTools.RedumpLib.Data;
43
using Xunit;
@@ -30,14 +29,14 @@ public void ExtensionTest(MediaType? type, string? expected)
3029

3130
#region Default Values
3231

33-
private static readonly Dictionary<string, string?> AllOptions = new()
32+
private static readonly BaseDumpSettings AllOptions = new DumpSettings()
3433
{
35-
[SettingConstants.EnableVerbose] = "true",
36-
[SettingConstants.LeadinRetryCount] = "1000",
37-
[SettingConstants.ReadMethod] = "BE",
38-
[SettingConstants.RereadCount] = "1000",
39-
[SettingConstants.SectorOrder] = "DATA_C2_SUB",
40-
[SettingConstants.DriveType] = "GENERIC",
34+
EnableVerbose = true,
35+
LeadinRetryCount = 1000,
36+
ReadMethod = ReadMethod.BE,
37+
RereadCount = 1000,
38+
SectorOrder = SectorOrder.DATA_C2_SUB,
39+
DriveType = DriveType.GENERIC,
4140
};
4241

4342
[Theory]

MPF.ExecutionContexts/Aaru/DumpSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
namespace MPF.ExecutionContexts.Aaru
22
{
33
/// <summary>
4-
/// Settings related to the dumping step
4+
/// Context-specific settings that can be used by caller
55
/// </summary>
6-
public class DumpSettings
6+
public class DumpSettings : BaseDumpSettings
77
{
88
/// <summary>
99
/// Enable debug output while dumping by default

0 commit comments

Comments
 (0)