-
Notifications
You must be signed in to change notification settings - Fork 36
Description
We have logic that answers the following question:
- Given a property of arbitrary Type with current value
oldValue - What UI should I show to illicit a new value from the user
- Run that UI
- Did the UI cancel or complete?
- If complete return true and
outthe new value
This is that method:
internal static bool GetNewValue(Design design, Property property, object? oldValue, out object? newValue)There are really 2 possibilities that this method decides:
- Show a modal (e.g. enter a string)
- Show an 'editor' (e.g. PosEditor)
This is hard to test and getting too big.
Possible Solutions
Add a shared interface for all editors INewValueGetter (PosEditor, SizeEditor etc)
Create a new class PropertyValueFactory with function Create that takes a Design, Property and oldValue then returns an INewValueGetter.
This will allow for unit testing that the correct decisions about what editor should be shown to be written and move the logic of this tree into its own class.
Advantages
In #271 I have started down the route of a more complex ArrayEditor. Having this logic in its own class would make it possible to centralize 'new value' logic.
Testability
Automation style of tests e.g. mocking INewValueGetter with test implementations that simulate the user driving editor to create a given value.