Skip to content

Commit

Permalink
#2115 test update
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaperez1983 committed Jan 8, 2025
1 parent b8995c4 commit eac9da9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private ParseErrors validateDataSource(IDataSource dataSource)
}

private void loadSheets(IDataSourceFile dataSourceFile, IReadOnlyList<string> sheetNames, string filter, string selectedNamingConvention = null)
{
{
if (!sheetNames.Any())
{
View.DisableConfirmationView();
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 @@ -210,7 +212,6 @@ public void sets_column_mapping_presenter_settings()

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

protected override void Context()
Expand All @@ -219,9 +220,9 @@ protected override void Context()
_sheets = new Cache<string, DataSheet>();
_sheets.Add("Sheet1", A.Fake<DataSheet>());

_dataSourceFile = new RandomDataSourceFile(A.Fake<IImportLogger>());
_dataSourceFile = new ExcelDataSourceFile(A.Fake<IImportLogger>());
_dataSourceFile.Format = A.Fake<IDataFormat>();
_dataSourceFile.Path = "FakePath";
_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() });
Expand All @@ -232,55 +233,6 @@ public void should_not_throw_an_ImporterParsingException()
{
sut.LoadConfiguration(_importerConfiguration, "");
}

//This class needs to be added to create a random data source file
//With the empty rows that we need to test
public class RandomDataSourceFile : DataSourceFile
{
public RandomDataSourceFile(IImportLogger logger) : base(logger)
{
}

protected override void LoadFromFile(string path)
{
Console.WriteLine($"Loading data from file: {path} (simulated random data)");

var random = new Random();
int numberOfSheets = 1;

for (int i = 0; i < numberOfSheets; i++)
{
var dataSheet = new DataSheet
{
SheetName = $"Sheet{i + 1}"
};

int numberOfRows = 5;
int numberOfColumns = 3;

for (int c = 0; c < numberOfColumns; c++)
{
dataSheet.AddColumn($"Column{c + 1}", c);
}

var emptyRow = new List<string>(Enumerable.Repeat(string.Empty, numberOfColumns));
dataSheet.AddRow(emptyRow);

for (int r = 0; r < numberOfRows; r++)
{
var row = new List<string>();
for (int c = 0; c < numberOfColumns; c++)
{
row.Add($"Data_{i + 1}_{r + 1}_{c + 1}");
}

dataSheet.AddRow(row);
}

DataSheets.AddSheet(dataSheet);
}
}
}
}

public class When_import_data : concern_for_ImporterPresenter
Expand Down

0 comments on commit eac9da9

Please sign in to comment.