生成的整數是否與IFixture.Create<int>()
是唯一的?使用AutoFixture 3生成的整數是否是唯一的?
The Wiki says該數字是隨機的,但它也告訴我們這個
第一號碼[1,255]的範圍內產生,因爲這 是適用於所有的一組值數字數據類型。 .NET中最小的數字數據類型是System.Byte,它適用於此範圍內的 範圍。
當使用前255個整數時,編號從範圍[256,32767]中選取,然後是 ,對應於可用於System.Int16的其餘 正數。在GitHub上
兩個相關的東西:
https://github.com/AutoFixture/AutoFixture/issues/2
https://github.com/AutoFixture/AutoFixture/pull/7
什麼那些單元測試?
https://github.com/AutoFixture/AutoFixture/blob/master/Src/AutoFixtureUnitTest/GeneratorTest.cs#L33
[Theory, ClassData(typeof(CountTestCases))]
public void StronglyTypedEnumerationYieldsUniqueValues(int count)
{
// Fixture setup
var sut = new Generator<T>(new Fixture());
// Exercise system
var actual = sut.Take(count);
// Verify outcome
Assert.Equal(count, actual.Distinct().Count());
// Teardown
}
https://github.com/AutoFixture/AutoFixture/blob/master/Src/AutoFixtureUnitTest/GeneratorTest.cs#L57
[Theory, ClassData(typeof(CountTestCases))]
public void WeaklyTypedEnumerationYieldsUniqueValues(int count)
{
// Fixture setup
IEnumerable sut = new Generator<T>(new Fixture());
// Exercise system
var actual = sut.OfType<T>().Take(count);
// Verify outcome
Assert.Equal(count, actual.Distinct().Count());
// Teardown
}
我還沒有發現說,產生的編號是唯一的,僅是建議它的信息的位的說法,但我可能是錯的。