diff --git a/src/DiffEngineTray.Tests/OptionsFormMaxInstancesTests.cs b/src/DiffEngineTray.Tests/OptionsFormMaxInstancesTests.cs new file mode 100644 index 00000000..2e257467 --- /dev/null +++ b/src/DiffEngineTray.Tests/OptionsFormMaxInstancesTests.cs @@ -0,0 +1,27 @@ +using NumericUpDown = System.Windows.Forms.NumericUpDown; + +/// +/// The form's range has to be the setting's range. DiffEngine_MaxInstances takes any ushort, and +/// the spinner was left at NumericUpDown's default maximum of 100, so anything above that threw +/// out of the constructor and Options could never be opened to lower it again. +/// +[TUnit.Core.Executors.STAThreadExecutor] +public class OptionsFormMaxInstancesTests +{ + [Test] + public async Task Opens_at_the_highest_max_instances_that_can_be_set() + { + using var form = new OptionsForm( + new() + { + MaxInstancesToLaunch = ushort.MaxValue + }, + _ => Task.FromResult>([])); + + var spinner = form.Controls + .Find("maxInstancesNumericUpDown", true) + .OfType() + .Single(); + await Assert.That(spinner.Value).IsEqualTo(ushort.MaxValue); + } +} diff --git a/src/DiffEngineTray/Settings/OptionsForm.Designer.cs b/src/DiffEngineTray/Settings/OptionsForm.Designer.cs index f4e13760..7bee9b0f 100644 --- a/src/DiffEngineTray/Settings/OptionsForm.Designer.cs +++ b/src/DiffEngineTray/Settings/OptionsForm.Designer.cs @@ -256,6 +256,16 @@ void InitializeComponent() this.maxInstancesNumericUpDown.Dock = System.Windows.Forms.DockStyle.Left; this.maxInstancesNumericUpDown.Location = new System.Drawing.Point(5, 44); this.maxInstancesNumericUpDown.Margin = new System.Windows.Forms.Padding(5); + // ushort.MaxValue, which is what MaxInstance accepts. Left at the default 100, a + // DiffEngine_MaxInstances above that threw out of this form's constructor, so Options + // could never be opened to lower it again. + this.maxInstancesNumericUpDown.Maximum = new decimal(new int[] + { + 65535, + 0, + 0, + 0 + }); this.maxInstancesNumericUpDown.Minimum = new decimal(new int[] { 0,