private void Apply(CompanyRegistered @event) { this.Id = @event.AggregateId; this.Name = new CompanyName(@event.Name); this.NationalId = new NationalId(@event.NationalId); this._employees = new List <Employee>(); }
public void EqualsObjectCastTest() { string number = "test-number"; NationalId nationalId = new NationalId(number: number); object obj = new NationalId(number: number); Assert.True(nationalId.Equals(obj)); }
public void EqualsTest() { string number = "test-number"; NationalId number1 = new NationalId(number: number); Assert.Equal(number1, number1); Assert.Equal(number1, new NationalId(number: number)); Assert.NotEqual(number1, new NationalId(number: number + "1")); Assert.False(number1.Equals(null)); }
/// <inheritdoc /> public override void RestoreSnapshot(Snapshot snapshot) { var snapshotToRestore = (CompanySnapshot)snapshot; this.Id = snapshotToRestore.AggregateId; this.Name = new CompanyName(snapshotToRestore.Name); this.NationalId = new NationalId(snapshotToRestore.NationalId); this._employees = snapshotToRestore.Employees.Select(q => new Employee(q.Id, new FullName(q.FirstName, q.LastName), new NationalCode(q.NationalCode))).ToList(); this.CurrentVersion = snapshotToRestore.Version; }
public void GetHashcodeTest() { NationalId nationalId1 = new NationalId(); nationalId1.Number = "test-number"; nationalId1.Type = "test-type"; nationalId1.DistrictOfIssue = "test-districtOfIssue"; nationalId1.CityOfIssue = "test-cityOfIssue"; nationalId1.ProvinceOfIssue = "test-provinceOfIssue"; nationalId1.CountyOfIssue = "test-countyOfIssue"; NationalId nationalId2 = new NationalId(); nationalId2.Number = "test-number"; nationalId2.Type = "test-type"; nationalId2.DistrictOfIssue = "test-districtOfIssue"; nationalId2.CityOfIssue = "test-cityOfIssue"; nationalId2.ProvinceOfIssue = "test-provinceOfIssue"; nationalId2.CountyOfIssue = "test-countyOfIssue"; Assert.Equal(nationalId1.GetHashCode(), nationalId2.GetHashCode()); }
public void IsValid_Throws_ArgumentException_When_Input_Is_Null() { Action act = () => NationalId.IsValid(null); var exception = Assert.Throws <ArgumentException>(act); }
/// <inheritdoc /> public Company(CompanyName name, NationalId nationalId) : base(Guid.NewGuid()) { ApplyChange(new CompanyRegistered(this.Id, name.Value, nationalId.Id)); }
public NationalIdTests() { nationalId = new NationalId(); }