using System.Collections.Generic; using System.Linq; using AutoBogus; using Util.Tests.Dtos; using Util.Tests.Models; namespace Util.Tests.Fakes; /// /// 客户模拟数据服务 /// public static class CustomerFakeService { /// /// 获取客户 /// public static Customer GetCustomer() { return GetCustomers( 1 ).First(); } /// /// 获取客户列表 /// /// 行数 public static List GetCustomers( int count ) { return new AutoFaker() .RuleFor( t => t.Code, t => t.Random.String2( 1, 100 ) ) .RuleFor( t => t.Name, t => t.Random.String2( 1, 200 ) ) .RuleFor( t => t.Nickname, t => t.Random.String2( 1, 50 ) ) .RuleFor( t => t.Phone, t => t.Random.String2( 1, 50 ) ) .RuleFor( t => t.Email, t => t.Random.String2( 1, 500 ) ) .RuleFor( t => t.IsDeleted, false ) .Generate( count ); } /// /// 获取客户 /// public static CustomerDto GetCustomerDto() { return GetCustomerDtos( 1 ).First(); } /// /// 获取客户列表 /// /// 行数 public static List GetCustomerDtos( int count ) { return new AutoFaker() .Configure( builder => builder .WithSkip( t => t.Id ) ) .RuleFor( t => t.Code, t => t.Random.String2( 1, 100 ) ) .RuleFor( t => t.Name, t => t.Random.String2( 1, 200 ) ) .RuleFor( t => t.Nickname, t => t.Random.String2( 1, 50 ) ) .RuleFor( t => t.Phone, t => t.Random.String2( 1, 50 ) ) .RuleFor( t => t.Email, t => t.Random.String2( 1, 500 ) ) .RuleFor( t => t.IsDeleted, false ) .Generate( count ); } }