public void EnsurePassedFactoriesAreUsed(int value1, int value2, int value3) { int[] values={value1,value2,value3}; int i = 0; factoryMock.Setup(f => f.Generate()).Returns(() => { var value = values[i]; i++; return value; }); var factory = new SetFactory<int>(factoryMock.Object); var result = factory.Generate(3); i = 0; foreach (var value in values) { Assert.Contains(value,result); } }