260511_01_ENH: 테스트 파일 실제로 돌려가며 오류 내용 수정

This commit is contained in:
2026-05-11 16:24:45 +09:00
parent b501332f06
commit c652d4ad43
7 changed files with 104 additions and 57 deletions

View File

@@ -82,7 +82,8 @@ namespace Keps.WinForms.Forms
_numTotalSamples.Minimum = 1;
_numTotalSamples.Maximum = 5000;
_numTotalSamples.Value = 123;
_numTotalSamples.Value = 1;
_numTotalSamples.Text = string.Empty;
_numOffsetValue.Minimum = 0;
_numOffsetValue.Maximum = 100;
_preparedContext = null;
@@ -181,10 +182,11 @@ namespace Keps.WinForms.Forms
string election = _cmbElection.SelectedItem.ToString();
string area = _cmbArea.SelectedItem.ToString();
int clusterMax = Convert.ToInt32(_cmbClusterMax.SelectedItem);
int totalSamples = GetTotalSamples();
RealScenarioContext context = _samplingService.LoadRealScenario(election, area, clusterMax);
_preparedContext = context;
_autoRows = new BindingList<ClusterSummaryRow>(_samplingService.AllocateAutoSampleCounts(context.AutoRows, Convert.ToInt32(_numTotalSamples.Value)));
_autoRows = new BindingList<ClusterSummaryRow>(_samplingService.AllocateAutoSampleCounts(context.AutoRows, totalSamples));
_manualRows = new BindingList<ClusterSummaryRow>(context.ManualRows.Select(CloneRow).ToList());
for (int i = 0; i < _manualRows.Count && i < _autoRows.Count; i++)
{
@@ -265,7 +267,13 @@ namespace Keps.WinForms.Forms
if (_rdoAuto.Checked)
{
_autoRows = new BindingList<ClusterSummaryRow>(_samplingService.AllocateAutoSampleCounts(_preparedContext.AutoRows, Convert.ToInt32(_numTotalSamples.Value)));
int totalSamples;
if (!TryGetTotalSamples(out totalSamples))
{
return;
}
_autoRows = new BindingList<ClusterSummaryRow>(_samplingService.AllocateAutoSampleCounts(_preparedContext.AutoRows, totalSamples));
if (_manualRows == null || _manualRows.Count != _autoRows.Count)
{
@@ -391,9 +399,37 @@ namespace Keps.WinForms.Forms
MessageBox.Show(this, "군집수를 선택하세요.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
if (!TryGetTotalSamples(out _))
{
MessageBox.Show(this, "총 표본 수를 입력하세요.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
_numTotalSamples.Focus();
return false;
}
return true;
}
private int GetTotalSamples()
{
int totalSamples;
if (!TryGetTotalSamples(out totalSamples))
{
throw new InvalidOperationException("총 표본 수를 입력하세요.");
}
return totalSamples;
}
private bool TryGetTotalSamples(out int totalSamples)
{
totalSamples = 0;
if (string.IsNullOrWhiteSpace(_numTotalSamples.Text))
{
return false;
}
totalSamples = Convert.ToInt32(_numTotalSamples.Value);
return totalSamples >= _numTotalSamples.Minimum && totalSamples <= _numTotalSamples.Maximum;
}
private List<ClusterSummaryRow> GetWorkingRows()
{
return (_rdoAuto.Checked ? _autoRows : _manualRows).Select(CloneRow).ToList();