using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using Util.Domain.Entities; namespace Util.Domain.Tests.Samples; /// /// Guid聚合根测试样例 /// public class AggregateRootSample : AggregateRoot { /// /// 初始化聚合根测试样例 /// public AggregateRootSample() : this( Guid.Empty ) { } /// /// 初始化聚合根测试样例 /// /// 标识 public AggregateRootSample( Guid id ) : base( id ) { IntSamples = new List(); } /// /// 姓名 /// [Required( ErrorMessage = "姓名不能为空" )] public string Name { get; set; } /// /// 编码 /// public string Code { get; set; } /// /// 英文名 /// [Required( ErrorMessageResourceType = typeof( TestResource ), ErrorMessageResourceName = "EnglishNameIsEmpty" )] public string EnglishName { get; set; } /// /// 手机号 /// [Display(Name = "手机号" )] public string MobilePhone { get; set; } /// /// 年龄 /// public int? Age { get; set; } /// /// 电话 /// [Description( "电话" )] public int Tel { get; set; } /// /// decimal值 /// public decimal DecimalValue { get; set; } /// /// 可空decimal值 /// public decimal? NullableDecimalValue { get; set; } /// /// float值 /// public float FloatValue { get; set; } /// /// 可空float值 /// public float? NullableFloatValue { get; set; } /// /// double值 /// public double DoubleValue { get; set; } /// /// 可空double值 /// public double? NullableDoubleValue { get; set; } /// /// bool值 /// public bool BoolValue { get; set; } /// /// 可空bool值 /// public bool? NullableBoolValue { get; set; } /// /// Enum值 /// public EnumSample EnumValue { get; set; } /// /// 可空Enum值 /// public EnumSample? NullableEnumValue { get; set; } /// /// DateTime值 /// public DateTime DateValue { get; set; } /// /// 可空DateTime值 /// public DateTime? NullableDateValue { get; set; } /// /// int值 /// public int IntValue { get; set; } /// /// 可空int值 /// public int? NullableIntValue { get; set; } /// /// short值 /// public short ShortValue { get; set; } /// /// 可空short值 /// public short? NullableShortValue { get; set; } /// /// long值 /// public long LongValue { get; set; } /// /// 可空long值 /// public long? NullableLongValue { get; set; } /// /// 导航属性 /// public StringAggregateRootSample StringSample { get; set; } /// /// 导航属性集合 /// public ICollection IntSamples { get; set; } /// /// 添加变更列表 /// protected override void AddChanges( AggregateRootSample other ) { AddChange( "Name", "姓名", Name, other.Name ); AddChange( t => t.MobilePhone, other.MobilePhone ); AddChange( t => t.Tel, other.Tel ); AddChange( StringSample, other.StringSample ); AddChange( IntSamples, other.IntSamples ); } /// /// 创建测试样例 /// public static AggregateRootSample CreateSample() { return CreateSample( Guid.NewGuid() ); } /// /// 创建测试样例 /// public static AggregateRootSample CreateSample( Guid id ) { return new AggregateRootSample( id ) { Name = "TestName", EnglishName = "TestEnglishName", MobilePhone = "13012345678" }; } /// /// 创建测试样例2 /// public static AggregateRootSample CreateSample2() { return CreateSample2( Guid.NewGuid() ); } /// /// 创建测试样例2 /// public static AggregateRootSample CreateSample2( Guid id ) { return new AggregateRootSample( id ) { Name = "TestName2", EnglishName = "TestEnglishName2", MobilePhone = "12012345678" }; } } /// /// 聚合根测试样例2 /// public class AggregateRootSample2 : AggregateRoot { /// /// 初始化聚合根测试样例 /// /// 标识 public AggregateRootSample2( Guid id ) : base( id ) { } }