DTO에 대해 임의/의사 난수 값을 생성하는 beautiful library이 있습니다. int 형에 대한 규칙을 만들려면가짜 값으로 null 값을 나타내는 법?
var fruit = new[] { "apple", "banana", "orange", "strawberry", "kiwi" };
var orderIds = 0;
var testOrders = new Faker<Order>()
//Ensure all properties have rules. By default, StrictMode is false
//Set a global policy by using Faker.DefaultStrictMode
.StrictMode(true)
//OrderId is deterministic
.RuleFor(o => o.OrderId, f => orderIds++)
//Pick some fruit from a basket
.RuleFor(o => o.Item, f => f.PickRandom(fruit))
//A random quantity from 1 to 10
.RuleFor(o => o.Quantity, f => f.Random.Number(1, 10));
은 간단하다 :
.RuleForType(typeof(int), f => f.Random.Number(10, 1000))
우리는 어떻게 널 (NULL) 기본 유형에 대한 규칙을 만들려면 어떻게해야합니까?
public class ObjectWithNullables
{
public int? mynumber{get;set;}
public decimal? mydec {get;set;}
}
우리는과 같이 구성 할 수 없습니다 :
.RuleForType(typeof(int?), f => f.Random.Number(10, 1000))
우리는 어떻게 표현합니까 nullables를 예를 들어
우리의 모델은 널 (NULL)의 int null이 deimcals이 있다면?
당신이 당신의 예'RuleForType' 무엇을하려고 발생하면? 설명서를 읽었습니까? – NetMage