예제 #1
0
 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>();
 }
예제 #2
0
        public void EqualsObjectCastTest()
        {
            string     number     = "test-number";
            NationalId nationalId = new NationalId(number: number);
            object     obj        = new NationalId(number: number);

            Assert.True(nationalId.Equals(obj));
        }
예제 #3
0
        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));
        }
예제 #4
0
        /// <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;
        }
예제 #5
0
        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());
        }
예제 #6
0
        public void IsValid_Throws_ArgumentException_When_Input_Is_Null()
        {
            Action act = () => NationalId.IsValid(null);

            var exception = Assert.Throws <ArgumentException>(act);
        }
예제 #7
0
 /// <inheritdoc />
 public Company(CompanyName name, NationalId nationalId) : base(Guid.NewGuid())
 {
     ApplyChange(new CompanyRegistered(this.Id, name.Value, nationalId.Id));
 }
예제 #8
0
 public NationalIdTests()
 {
     nationalId = new NationalId();
 }