Repository navigation
Combine StubbedProperty{G|S}etterSetup - #1204
Conversation
f2c59bf to
84bf35a
Compare
| if (ProxyFactory.Instance.IsMethodVisible(getter, out _)) | ||
| { | ||
| propertyValue = CreateInitialPropertyValue(mock, getter); | ||
| getterSetup = new StubbedPropertyGetterSetup(mock, expression, getter, () => propertyValue); | ||
| mock.MutableSetups.Add(getterSetup); | ||
| } |
There was a problem hiding this comment.
Those visibility checks are no longer required because we already know that either the getter or the setter can be intercepted by the proxy factory; otherwise we wouldn't end up here in the first place.
If the other accessor isn't interceptable, that amounts to the same thing as if it were completely absent: we'll still create a setup just for the present accessor (even if it won't be of much actual use beyond preventing this code from executing repeatedly for the same property).
| if (!pi.CanRead(out var getter)) | ||
| { | ||
| Guard.CanRead(pi); | ||
| } | ||
|
|
||
| if (!pi.CanWrite(out var setter)) | ||
| { | ||
| Guard.CanWrite(pi); | ||
| } |
There was a problem hiding this comment.
This isn't pretty. Seems like we're missing a method that acts as both guard and for accessor(s) retrieval (or perhaps even better, an exception factory method).
| lock (this.setups) | ||
| { | ||
| this.setups.RemoveAll(s => s is MethodSetup ms && ms.Method.IsPropertyAccessor()); | ||
| this.setups.RemoveAll(s => s is StubbedPropertySetup || (s is MethodSetup ms && ms.Method.IsPropertyAccessor())); |
There was a problem hiding this comment.
This line of code is getting really bad. It's even more important now to get rid of the whole method, if possible; see #1203 (comment).
84bf35a to
c0e1256
Compare
This is a follow-up to #1203.