2016-11-25 4 views
2

AutoFixture로 이것을 쉽게 할 수 있습니까? 번호 범위를위한 자동 조정

하십시오

var myInt = fixture.Create<int>(min, max);

이 내가 필요한 모든 것입니다. 아무것도, 아무것도 더, 나는 그것을 한 번만 필요합니다. 이 간단한 문장에 대해 완전히 새로운 클래스 계층 구조가 필요하지 않습니다. AutoFixture에서 가능한지 또는 임의의 객체를 인스턴스화하고 직접 작업해야하는지 알고 싶습니다.

이 기능을 사용할 수없는 경우 여기에 누락 된 기능이없는 이유가 있습니까?

답변

1

예, 있습니다 :

// Install-Package AutoFixture.Xunit - or - 
// Install-Package AutoFixture.Xunit2 

using System; 
using System.ComponentModel.DataAnnotations; 
using Xunit; 

[Theory, AutoData] 
public void ActualIsInTestRange([Range(99, 111)]int actual) 
{ 
    Assert.InRange(actual, 99, 111); 
} 
+0

안녕하세요,이 새로운 질문에 대답 할 수 HTTP하십시오 //stackoverflow.com/questions/40824701/autofixture-constrained-string-parameter –

+0

@ AdanayMartín 내가 왼쪽 [의견] (http://stackoverflow.com/questions/40824701/autofixture-constrained-string-parameter#comment68878952_40824701). –