public void FamilyInfoAddingExceptionTest() { var parentFamilyStatus = ParentFamilyStatus.Full; var motherRelativeStatus = RelativeStatus.Mother; var motherFullName = new FullName("Евдокимова", "Евгения", "Вадимовна"); var motherBirthInfo = new BirthInfo(new DateTime(1980, 1, 1), "г. Барнаул"); var motherPersonInfo = new PersonInfo(motherFullName, motherBirthInfo); var motherWorkPlace = "Магазин игрушек"; var motherInfo1 = new RelativeInfo(motherRelativeStatus, motherPersonInfo, motherWorkPlace); var motherInfo2 = new RelativeInfo(motherRelativeStatus, motherPersonInfo, motherWorkPlace); var motherInfo3 = new RelativeInfo(motherRelativeStatus, motherPersonInfo, motherWorkPlace); var motherInfo4 = new RelativeInfo(motherRelativeStatus, motherPersonInfo, motherWorkPlace); var familyInfo = new FamilyInfo(parentFamilyStatus); familyInfo.AddRelative(motherInfo1); familyInfo.AddRelative(motherInfo2); familyInfo.AddRelative(motherInfo3); familyInfo.AddRelative(motherInfo4); }
private static FamilyInfo BuildFamilyInfo(priz priz) { var parentFamilyStatus = priz.parents.ToParentFamilyStatusEnum(); var familyInfo = new FamilyInfo(parentFamilyStatus); if (!string.IsNullOrWhiteSpace(priz.relation)) { DateTime?birthdate = priz.relative_birth_date.GetDateTime(); if (!birthdate.HasValue) { throw new ArgumentException(nameof(priz)); } var fullName = new FullName(priz.relative_name); var birthInfo = new BirthInfo(date: birthdate.Value, place: priz.relative_birth_place); var personInfo = new PersonInfo(fullName, birthInfo); var relative = new RelativeInfo(relativeStatus: priz.relation.ToRelativeStatusEnum(), personInfo: personInfo, workPlace: priz.relative_work_place); familyInfo.AddRelative(relative); } if (!string.IsNullOrWhiteSpace(priz.relation2)) { DateTime?birthdate = priz.relative_birth_date2.GetDateTime(); if (!birthdate.HasValue) { throw new ArgumentException(nameof(priz)); } var fullName = new FullName(priz.relative_name2); var birthInfo = new BirthInfo(date: birthdate.Value, place: priz.relative_birth_place2); var personInfo = new PersonInfo(fullName, birthInfo); var relative = new RelativeInfo(relativeStatus: priz.relation2.ToRelativeStatusEnum(), personInfo: personInfo, workPlace: priz.relative_work_place2); familyInfo.AddRelative(relative); } if (!string.IsNullOrWhiteSpace(priz.relation3)) { DateTime?birthdate = priz.relative_birth_date3.GetDateTime(); if (!birthdate.HasValue) { throw new ArgumentException(nameof(priz)); } var fullName = new FullName(priz.relative_name3); var birthInfo = new BirthInfo(date: birthdate.Value, place: priz.relative_birth_place3); var personInfo = new PersonInfo(fullName, birthInfo); var relative = new RelativeInfo(relativeStatus: priz.relation3.ToRelativeStatusEnum(), personInfo: personInfo, workPlace: priz.relative_work_place3); familyInfo.AddRelative(relative); } return(familyInfo); }