Try:
variables
.As<IEnumerable>()
.Setup(x => x.GetEnumerator()).Returns(TagCollection);
There are two different methods, one of which is specified in the base interface, and one of which is specified in Variables.
foreach , , . foreach public, , IEnumerable .
.OfType<Variable>() Linq, IEnumerable, . .
:
_variables.GetEnumerator();
((IEnumerable)_variables).GetEnumerator();
, Moq :
public class TheTypeMoqMakes : Variables
{
Enumerator Variables.GetEnumerator()
{
// Use return value from after
// expression tree you provided with 'Setup' without 'As'.
// If you did not provide one, just return null.
}
Enumerator IEnumerable.GetEnumerator()
{
// Use return value from after
// expression tree you provided with 'Setup' with 'As<IEnumerable>'.
// If you did not provide one, just return null.
}
// other methods and properties
}
, Moq null , Setup, , MockBehavior.Loose. MockBehavior.Strict.
, Variables interface hiding .