Skip to content

Commit

Permalink
#2115 error when importing empty row (#2384)
Browse files Browse the repository at this point in the history
* #2115 error when importing empty row

* #2115 test update

* #2115 remove empty rows

* #2115 remove extra instructions

* #2115 code cleanup
  • Loading branch information
benjaperez1983 authored Jan 10, 2025
1 parent df38c11 commit 0c46b07
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/OSPSuite.Infrastructure.Import/Core/DataSheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ public void RemoveEmptyRows()
{
if (_rawDataTable[i].All(x => x.IsNullOrEmpty()))
_rawDataTable.RemoveAt(i);
else
break;
}
}

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FakeItEasy;
using OSPSuite.BDDHelper;
Expand All @@ -12,6 +13,7 @@
using OSPSuite.Core.Services;
using OSPSuite.Helpers;
using OSPSuite.Infrastructure.Import.Core;
using OSPSuite.Infrastructure.Import.Core.DataSourceFileReaders;
using OSPSuite.Infrastructure.Import.Core.Exceptions;
using OSPSuite.Infrastructure.Import.Core.Mappers;
using OSPSuite.Infrastructure.Import.Services;
Expand Down Expand Up @@ -208,6 +210,31 @@ public void sets_column_mapping_presenter_settings()
}
}

public class When_setting_data_source_with_empty_rows : concern_for_ImporterPresenter
{
protected Cache<string, DataSheet> _sheets;

protected override void Context()
{
base.Context();
_sheets = new Cache<string, DataSheet>();
_sheets.Add("Sheet1", A.Fake<DataSheet>());

_dataSourceFile = new ExcelDataSourceFile(A.Fake<IImportLogger>());
_dataSourceFile.Format = A.Fake<IDataFormat>();
_dataSourceFile.Path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "IntegrationSampleUnitFromColumn.xlsx");
A.CallTo(() => _importerDataPresenter.SetDataSource(A<string>.Ignored)).Returns(_dataSourceFile);
_importerDataPresenter.OnImportSheets += Raise.With(new ImportSheetsEventArgs()
{ Filter = "", DataSourceFile = _dataSourceFile, SheetNames = _sheets.Keys.ToList() });
}

[Observation]
public void should_not_throw_an_ImporterParsingException()
{
sut.LoadConfiguration(_importerConfiguration, "");
}
}

public class When_import_data : concern_for_ImporterPresenter
{
protected bool triggered = false;
Expand Down

0 comments on commit 0c46b07

Please sign in to comment.