-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not update dimension when it already supports unit to avoid fraction/dimensionless collision #1515
Merged
msevestre
merged 5 commits into
develop
from
1499_do_not_update_dimension_when_it_already_supports_unit
Feb 24, 2022
Merged
Do not update dimension when it already supports unit to avoid fraction/dimensionless collision #1515
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
144902f
Do not update dimension when it already supports unit to avoid fracti…
abdelr 4f8b113
Fixing test
abdelr c5d36eb
Naming some constants
abdelr 2934c1a
Using existing code
abdelr 1c54c5a
Update ColumnMappingPresenter.cs
msevestre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ namespace OSPSuite.Presentation.Importer.Presenters | |
{ | ||
public abstract class concern_for_ColumnMappingPresenter : ContextSpecification<ColumnMappingPresenter> | ||
{ | ||
protected const int GEOMETRIC_ERROR = 0; | ||
protected const int ARITMETIC_ERROR = 1; | ||
protected IDataFormat _basicFormat; | ||
protected IColumnMappingView _view; | ||
protected IImporter _importer; | ||
|
@@ -168,7 +170,7 @@ protected override void Context() | |
{ | ||
base.Context(); | ||
A.CallTo(() => _mappingParameterEditorPresenter.Unit).Returns(new UnitDescription("")); | ||
A.CallTo(() => _mappingParameterEditorPresenter.SelectedErrorType).Returns(0); | ||
A.CallTo(() => _mappingParameterEditorPresenter.SelectedErrorType).Returns(GEOMETRIC_ERROR); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should return the enum that we have already defined as opposed to number. I am going to accept this PR but create an issue for this because returning the index of the combo box is not ok |
||
UpdateSettings(); | ||
} | ||
|
||
|
@@ -198,7 +200,7 @@ protected override void Context() | |
{ | ||
base.Context(); | ||
A.CallTo(() => _mappingParameterEditorPresenter.Unit).Returns(new UnitDescription("")); | ||
A.CallTo(() => _mappingParameterEditorPresenter.SelectedErrorType).Returns(1); | ||
A.CallTo(() => _mappingParameterEditorPresenter.SelectedErrorType).Returns(ARITMETIC_ERROR); | ||
UpdateSettings(); | ||
} | ||
|
||
|
@@ -335,7 +337,7 @@ protected override void Context() | |
base.Context(); | ||
_mappingSource = _parameters[2] as MappingDataFormatParameter; | ||
A.CallTo(() => _mappingParameterEditorPresenter.Unit).Returns(new UnitDescription("µmol/l")); | ||
A.CallTo(() => _mappingParameterEditorPresenter.SelectedErrorType).Returns(1); | ||
A.CallTo(() => _mappingParameterEditorPresenter.SelectedErrorType).Returns(ARITMETIC_ERROR); | ||
UpdateSettings(); | ||
} | ||
|
||
|
@@ -454,4 +456,33 @@ public void the_unit_and_dimension_are_set_properly(string oldUnitDescription, s | |
mappedColumn.Dimension.HasUnit(mappedColumn.Unit.SelectedUnit).ShouldBeTrue(); | ||
} | ||
} | ||
|
||
public class When_unit_is_manually_set_to_fraction_empty : concern_for_ColumnMappingPresenter | ||
{ | ||
protected MappingDataFormatParameter _mappingSource; | ||
|
||
protected override void Context() | ||
{ | ||
base.Context(); | ||
var supportedDimensions = _columnInfos["Error"].SupportedDimensions; | ||
supportedDimensions.Clear(); | ||
supportedDimensions.AddRange(DomainHelperForSpecs.ExtendedDimensionsForSpecs()); | ||
_mappingSource = _parameters[2] as MappingDataFormatParameter; | ||
_mappingSource.MappedColumn.Dimension = supportedDimensions.First(x => x.Name == Constants.Dimension.FRACTION); | ||
A.CallTo(() => _mappingParameterEditorPresenter.Unit).Returns(new UnitDescription("")); | ||
A.CallTo(() => _mappingParameterEditorPresenter.SelectedErrorType).Returns(ARITMETIC_ERROR); | ||
UpdateSettings(); | ||
} | ||
|
||
protected override void Because() | ||
{ | ||
sut.UpdateDescriptionForModel(_mappingSource); | ||
} | ||
|
||
[Observation] | ||
public void the_dimension_is_not_changed() | ||
{ | ||
_mappingSource.MappedColumn.Dimension.ShouldNotBeNull(); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this code over an over . FirstOrDefault(x=>x.HasUnit). It needs to be refactored at some point. I am pointing out here because I am seeing it. Please create an issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's always coming from the SupportedDimensions. If we make it a real class as opposed to a list? Or it belongs to the Columninfo itself. Not that Supporteddimension is a List and not a IReadOnlyList which breaks encapsulation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1520