Skip to content

Commit 4c2368c

Browse files
#2650 reload with same settings fails (#2774)
1 parent 29d6113 commit 4c2368c

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/OSPSuite.Presentation/Services/DataImporter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ string dataFileName
8888
public override ReloadDataSets CalculateReloadDataSetsFromConfiguration(IReadOnlyList<DataRepository> dataSetsToImport,
8989
IReadOnlyList<DataRepository> existingDataSets)
9090
{
91+
// If the import returned nothing (e.g. all sheets missing or a parsing exception), do not
92+
// proceed with the reload dialog. The error was already shown and there is nothing to reload.
93+
if (!dataSetsToImport.Any())
94+
return new ReloadDataSets();
95+
9196
var newDataSets = dataSetsToImport.Where(dataSet => !repositoryExistsInList(existingDataSets, dataSet)).ToList();
9297
var dataSetsToBeDeleted = existingDataSets.Where(dataSet => !repositoryExistsInList(dataSetsToImport, dataSet));
9398
var overwrittenDataSets = dataSetsToImport.Except(newDataSets);

tests/OSPSuite.UI.Tests/Services/DataImporterSpecs.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,34 @@ public void should_return_one_deleted_data_sets()
229229
_result.DataSetsToBeDeleted.Any(x => x.Name == "repo2").ShouldBeTrue();
230230
}
231231
}
232+
233+
public class When_reloading_configuration_but_no_data_sets_were_imported : concern_for_DataImporter
234+
{
235+
private ReloadDataSets _result;
236+
237+
protected override void Context()
238+
{
239+
base.Context();
240+
_dataSetsToImport = new List<DataRepository>();
241+
}
242+
243+
protected override void Because()
244+
{
245+
_result = sut.CalculateReloadDataSetsFromConfiguration(_dataSetsToImport, _existingDataSets);
246+
}
247+
248+
[Test]
249+
public void should_return_empty_reload_result()
250+
{
251+
_result.DataSetsToBeDeleted.Count().ShouldBeEqualTo(0);
252+
_result.NewDataSets.Count().ShouldBeEqualTo(0);
253+
_result.OverwrittenDataSets.Count().ShouldBeEqualTo(0);
254+
}
255+
256+
[Test]
257+
public void should_not_show_the_reload_dialog()
258+
{
259+
A.CallTo(() => _applicationController.Start<IImporterReloadPresenter>()).MustNotHaveHappened();
260+
}
261+
}
232262
}

0 commit comments

Comments
 (0)