Avoid potential concurrency issues in behavior pipeline
Avoid potential concurrency issues in behavior pipeline

If one of the behaviors causes the collection to be modified
(i.e. a callback injects another mock setup), the iteration
performed in the behavior pipeline may be invalidated and cause
an index out of range exception.

Prevent such mid-call changes by caching the list of behaviors
as an array.

Moq/moq