示例#1
0
        public void RelativeInfoTest()
        {
            var motherRelativeStatus = RelativeStatus.Mother;

            var motherSurname    = "Евдокимова";
            var motherName       = "Евгения";
            var motherPatronymic = "Вадимовна";
            var motherFullName   = new FullName(motherSurname, motherName, motherPatronymic);

            var motherBirthDate  = new DateTime(1980, 1, 1);
            var motherBirthPlace = "г. Барнаул";
            var motherBirthInfo  = new BirthInfo(motherBirthDate, motherBirthPlace);

            var motherPersonInfo = new PersonInfo(motherFullName, motherBirthInfo);

            var motherWorkPlace = "Магазин игрушек";

            var motherInfo = new RelativeInfo(motherRelativeStatus, motherPersonInfo, motherWorkPlace);

            Assert.AreEqual(motherRelativeStatus, motherInfo.RelativeStatus);

            Assert.AreEqual(motherSurname, motherInfo.PersonInfo.FullName.Surname);
            Assert.AreEqual(motherName, motherInfo.PersonInfo.FullName.Name);
            Assert.AreEqual(motherPatronymic, motherInfo.PersonInfo.FullName.Patronymic);

            Assert.AreEqual(motherBirthDate, motherInfo.PersonInfo.BirthInfo.Date);
            Assert.AreEqual(motherBirthPlace, motherInfo.PersonInfo.BirthInfo.Place);

            Assert.AreEqual(motherWorkPlace, motherInfo.WorkPlace);
        }
示例#2
0
        private static int Compare(RelativeInfo infoA, RelativeInfo infoB)
        {
            var relativePathA = infoA.TocPathRelativeToArticle;
            var relativePathB = infoB.TocPathRelativeToArticle;

            int subDirCompareResult = relativePathA.SubdirectoryCount - relativePathB.SubdirectoryCount;

            if (subDirCompareResult != 0)
            {
                return(subDirCompareResult);
            }

            int parentDirCompareResult = relativePathA.ParentDirectoryCount - relativePathB.ParentDirectoryCount;

            if (parentDirCompareResult != 0)
            {
                return(parentDirCompareResult);
            }

            var tocA = infoA.TocInfo;
            var tocB = infoB.TocInfo;

            var outputPathCompareResult = StringComparer.OrdinalIgnoreCase.Compare(tocA.OutputPath, tocB.OutputPath);

            if (outputPathCompareResult != 0)
            {
                return(outputPathCompareResult);
            }

            return(StringComparer.OrdinalIgnoreCase.Compare(tocA.FilePath, tocB.FilePath));
        }
示例#3
0
        public void FamilyInfoTest()
        {
            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 motherInfo = new RelativeInfo(motherRelativeStatus, motherPersonInfo, motherWorkPlace);

            var fatherRelativeStatus = RelativeStatus.Father;
            var fatherFullName       = new FullName("Евдокимов", "Евгений", "Сергеевич");
            var fatherBirthInfo      = new BirthInfo(new DateTime(1981, 1, 1), "г. Барнаул");
            var fatherPersonInfo     = new PersonInfo(fatherFullName, fatherBirthInfo);
            var fatherWorkPlace      = "Завод";

            var fatherInfo = new RelativeInfo(fatherRelativeStatus, fatherPersonInfo, fatherWorkPlace);

            var relatives = new List <RelativeInfo>()
            {
                motherInfo, fatherInfo
            };
            var familyInfo = new FamilyInfo(parentFamilyStatus, relatives);

            Assert.AreEqual(parentFamilyStatus, familyInfo.ParentFamilyStatus);
            Assert.AreEqual(motherInfo, familyInfo.GetRelative(0));
            Assert.AreEqual(fatherInfo, familyInfo.GetRelative(1));
        }
示例#4
0
        private FamilyInfo BuildFamilyInfo()
        {
            var parentFamilyStatus = _thirdCardGroup.FamilyCard.ParentFamilyStatus.ToParentFamilyStatusEnum();

            var relatives = new List <RelativeInfo>();

            foreach (var relativeUIModel in _thirdCardGroup.FamilyCard.RelativeInfoUIModels)
            {
                var relativeStatus = relativeUIModel.RelativeStatus.ToRelativeStatusEnum();
                var fullName       = new FullName(relativeUIModel.FullName);

                if (!relativeUIModel.BirthDate.HasValue)
                {
                    throw new NullReferenceException(nameof(relativeUIModel.BirthDate));
                }

                var birthInfo = new BirthInfo(relativeUIModel.BirthDate.Value, relativeUIModel.BirthPlace);

                var personInfo = new PersonInfo(fullName, birthInfo);

                var workPlace = relativeUIModel.WorkPlace;

                var relativeInfo = new RelativeInfo(relativeStatus, personInfo, workPlace);
                relatives.Add(relativeInfo);
            }

            return(new FamilyInfo(parentFamilyStatus, relatives));
        }
示例#5
0
        private static FamilyInfo BuildFamilyInfo()
        {
            var parentFamilyStatus = ParentFamilyStatus.Full;

            var fatherRelativeStatus = RelativeStatus.Father;
            var fatherFullName       = new FullName("Грибко", "Иван", "Викторович");
            var fatherBirthInfo      = new BirthInfo(new DateTime(1960, 1, 1), "Новосибирская обл., г. Новосибирск");
            var fatherPersonInfo     = new PersonInfo(fatherFullName, fatherBirthInfo);
            var fatherWorkPlace      = "Пекарь";

            var fatherInfo = new RelativeInfo(fatherRelativeStatus, fatherPersonInfo, fatherWorkPlace);

            var motherRelativeStatus = RelativeStatus.Mother;
            var motherFullName       = new FullName("Грибко", "Юлия", "Вадимовна");
            var motherBirthInfo      = new BirthInfo(new DateTime(1965, 1, 1), "Новосибирская обл., г. Новосибирск");
            var motherPersonInfo     = new PersonInfo(motherFullName, motherBirthInfo);
            var motherWorkPlace      = "Повар";

            var motherInfo = new RelativeInfo(motherRelativeStatus, motherPersonInfo, motherWorkPlace);

            var sisterRelativeStatus = RelativeStatus.Sister;
            var sisterFullName       = new FullName("Грибко", "Валерия", "Ивановна");
            var sisterBirthInfo      = new BirthInfo(new DateTime(1990, 1, 1), "Новосибирская обл., г. Новосибирск");
            var sisterPersonInfo     = new PersonInfo(sisterFullName, sisterBirthInfo);
            var sisterWorkPlace      = "Художник";

            var sisterInfo = new RelativeInfo(sisterRelativeStatus, sisterPersonInfo, sisterWorkPlace);

            var relatives = new List <RelativeInfo>()
            {
                fatherInfo, motherInfo, sisterInfo
            };

            return(new FamilyInfo(parentFamilyStatus, relatives));
        }
        private FamilyInfo BuildFamilyInfo()
        {
            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 motherInfo = new RelativeInfo(motherRelativeStatus, motherPersonInfo, motherWorkPlace);

            var fatherRelativeStatus = RelativeStatus.Father;
            var fatherFullName       = new FullName("Евдокимов", "Евгений", "Сергеевич");
            var fatherBirthInfo      = new BirthInfo(new DateTime(1981, 1, 1), "г. Барнаул");
            var fatherPersonInfo     = new PersonInfo(fatherFullName, fatherBirthInfo);
            var fatherWorkPlace      = "Завод";

            var fatherInfo = new RelativeInfo(fatherRelativeStatus, fatherPersonInfo, fatherWorkPlace);

            var relatives = new List <RelativeInfo>()
            {
                motherInfo, fatherInfo
            };

            return(new FamilyInfo(parentFamilyStatus, relatives));
        }
示例#7
0
        private void UpdateNearestTocCore(IHostService host, string item, FileModel toc, ConcurrentDictionary <string, RelativeInfo> nearest)
        {
            if (!host.SourceFiles.TryGetValue(item, out var itemSource))
            {
                return;
            }

            var tocInfo = new RelativeInfo(toc, itemSource);

            nearest.AddOrUpdate(
                item,
                k => tocInfo,
                (k, v) => Compare(tocInfo, v) < 0 ? tocInfo : v);
        }
示例#8
0
        public void FamilyInfoGettingExceptionTest()
        {
            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 motherInfo = new RelativeInfo(motherRelativeStatus, motherPersonInfo, motherWorkPlace);

            var familyInfo = new FamilyInfo(parentFamilyStatus);

            familyInfo.AddRelative(motherInfo);

            Assert.IsNull(familyInfo.GetRelative(1));
        }
示例#9
0
        public void AddRelative(RelativeInfo relative)
        {
            if (relative == null)
            {
                throw new ArgumentNullException(nameof(relative));
            }

            if (_relativesCount >= MaxRelativesCount)
            {
                throw new InvalidOperationException($"Relatives count can't be more than '{MaxRelativesCount}'");
            }

            var idx = _relativesCount;

            _relatives[idx] = relative;
            _relativesCount++;
        }
        private static void FillFamilyInfo(priz priz, FamilyInfo familyInfo)
        {
            priz.parents = familyInfo.ParentFamilyStatus.ToParentFamilyStatusString();

            // I didn't want write this code, but db structure force me do it

            int          curRelativeIdx  = 0;
            RelativeInfo currentRelative = null;

            currentRelative = familyInfo.GetRelative(curRelativeIdx++);
            if (currentRelative != null)
            {
                priz.relation             = currentRelative.RelativeStatus.ToRelativeStatusString();
                priz.relative_name        = currentRelative.PersonInfo.FullName.Value;
                priz.relative_birth_date  = currentRelative.PersonInfo.BirthInfo.Date.ToString(DateConstants.RecruitDateFormat);
                priz.relative_birth_place = currentRelative.PersonInfo.BirthInfo.Place;
                priz.relative_work_place  = currentRelative.WorkPlace;
            }

            currentRelative = familyInfo.GetRelative(curRelativeIdx++);
            if (currentRelative != null)
            {
                priz.relation2             = currentRelative.RelativeStatus.ToRelativeStatusString();
                priz.relative_name2        = currentRelative.PersonInfo.FullName.Value;
                priz.relative_birth_date2  = currentRelative.PersonInfo.BirthInfo.Date.ToString(DateConstants.RecruitDateFormat);
                priz.relative_birth_place2 = currentRelative.PersonInfo.BirthInfo.Place;
                priz.relative_work_place2  = currentRelative.WorkPlace;
            }

            currentRelative = familyInfo.GetRelative(curRelativeIdx++);
            if (currentRelative != null)
            {
                priz.relation3             = currentRelative.RelativeStatus.ToRelativeStatusString();
                priz.relative_name3        = currentRelative.PersonInfo.FullName.Value;
                priz.relative_birth_date3  = currentRelative.PersonInfo.BirthInfo.Date.ToString(DateConstants.RecruitDateFormat);
                priz.relative_birth_place3 = currentRelative.PersonInfo.BirthInfo.Place;
                priz.relative_work_place3  = currentRelative.WorkPlace;
            }
        }
        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);
        }