using Util.Domain.Tests.Samples; using Xunit; namespace Util.Domain.Tests.Entities; /// /// int标识实体测试 /// public class IntEntityTest { /// /// 测试初始化 /// public IntEntityTest() { _sample = new IntAggregateRootSample(); _sample2 = new IntAggregateRootSample(); } /// /// 聚合根测试样例 /// private IntAggregateRootSample _sample; /// /// 聚合根测试样例2 /// private IntAggregateRootSample _sample2; /// /// 测试实体相等性 - 当两个实体的标识相同,则实体相同 /// [Fact] public void TestEquals_IdEquals() { _sample = new IntAggregateRootSample( 1 ); _sample2 = new IntAggregateRootSample( 1 ); Assert.True( _sample.Equals( _sample2 ) ); Assert.True( _sample == _sample2 ); Assert.False( _sample != _sample2 ); } /// /// 测试实体相等性 - Id为空 /// [Fact] public void TestEquals_Id_Empty() { _sample = new IntAggregateRootSample( 0 ); _sample2 = new IntAggregateRootSample( 1 ); Assert.False( _sample.Equals( _sample2 ) ); Assert.False( _sample == _sample2 ); Assert.False( _sample2 == _sample ); } }