相关疑难解决方法(0)

NSubstitute模拟扩展方法

我想做模拟扩展方法,但它不起作用.如何才能做到这一点?

public static class RandomExtensions
{
    public static IEnumerable<int> NextInt32s(this System.Random random, int neededValuesNumber, int minInclusive, int maxExclusive)
    {
        // ...
    }
}
Run Code Online (Sandbox Code Playgroud)
[Fact]
public void Select()
{
    var randomizer = Substitute.For<DefaultRandom>();
    randomizer.NextInt32s(3, 1, 10).Returns(new int[] { 1, 2, 3 });
}
Run Code Online (Sandbox Code Playgroud)

c# random mocking nsubstitute

9
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

mocking ×1

nsubstitute ×1

random ×1