起订量 - It.IsInRange(TValue from, TValue to, Range rangeKind) 中的范围是什么?

Joh*_*tål 6 moq

我在谷歌上搜索了 Range 参数的作用的解释,但什么也没找到,所以我相信你会解释使用It.IsInRange(TValue from, TValue to, Range rangeKind)?时设置 Range.Inclusive 或 Range.Exclusive 有什么区别。

Ste*_*gli 5

我不确定,但我认为包含意味着您为该范围提供的值是该范围的一部分,而排除意味着它们不属于该范围:

包含:下界 <= x <= 上限

互斥:下界 < x < 上界


pax*_*nto 5

文档中指定的范围(枚举)参数-

Exclusive :     The range does not include the to and from values.
Inclusive :     The range includes the to and from values.
Run Code Online (Sandbox Code Playgroud)

用法如答案所示

It.IsInRange(0, 100, Range.Exclusive); // will not match for int values 0 and 100, but matches 1 to 99
Run Code Online (Sandbox Code Playgroud)

It.IsInRange(0, 100, Range.Inclusive); // will match for int values 0 and 100, and in-between
Run Code Online (Sandbox Code Playgroud)