From 5c9987e8354888ce588c65a88dc6863830679a7b Mon Sep 17 00:00:00 2001 From: Michael Sevestre Date: Tue, 27 Nov 2018 09:09:25 -0500 Subject: [PATCH] Fixes #470 issue with obs data (#471) --- .../DataRepositoryDataPresenter.cs | 3 +++ .../DataRepositoryDataPresenterSpecs.cs | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/OSPSuite.Presentation/Presenters/ObservedData/DataRepositoryDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/ObservedData/DataRepositoryDataPresenter.cs index 0bbc04be4..be3d06339 100644 --- a/src/OSPSuite.Presentation/Presenters/ObservedData/DataRepositoryDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/ObservedData/DataRepositoryDataPresenter.cs @@ -90,6 +90,9 @@ public void AddData(int rowIndex) /// public IEnumerable GetCellValidationErrorMessages(int rowIndex, int columnIndex, string newValue) { + if (string.IsNullOrWhiteSpace(newValue)) + return new[] {Error.ValueIsRequired}; + var proposedValue = newValue.ConvertedTo(); var editedColumnId = GetColumnIdFromColumnIndex(columnIndex); diff --git a/tests/OSPSuite.Core.Tests/Presentation/DataRepositoryDataPresenterSpecs.cs b/tests/OSPSuite.Core.Tests/Presentation/DataRepositoryDataPresenterSpecs.cs index 1396bb33d..c0ecf6ee4 100644 --- a/tests/OSPSuite.Core.Tests/Presentation/DataRepositoryDataPresenterSpecs.cs +++ b/tests/OSPSuite.Core.Tests/Presentation/DataRepositoryDataPresenterSpecs.cs @@ -145,6 +145,24 @@ public void should_not_return_validation_messages() } } + public class When_getting_validation_messages_for_an_empty_value : concern_for_DataRepositoryDataPresenter + { + private List _result; + + protected override void Because() + { + sut.EditObservedData(_dataRepository); + _result = sut.GetCellValidationErrorMessages(0, 1, " ").ToList(); + } + + [Observation] + public void should_return_validation_messages() + { + _result.Count.ShouldBeEqualTo(1); + _result[0].ShouldBeEqualTo(Error.ValueIsRequired); + } + } + public class When_getting_validation_messages_for_repeated_basegrid_values : concern_for_DataRepositoryDataPresenter { private List _result;