private void Name_is_not_equal_to_null()
        {
            GedcomName name1 = new GedcomName();
            GedcomName name2 = null;

            Assert.NotEqual(name1, name2);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create an individual with a specific name.
        /// </summary>
        /// <param name="gedcomDb">The gedcom database to attach the name and individual to.</param>
        /// <param name="givenName">The given name (first name) to attach to the new individual.</param>
        /// <param name="surname">The surname (last name) to attach to the new individual.</param>
        /// <returns>The constructed individual.</returns>
        public static GedcomIndividualRecord NamedPerson(this GedcomDatabase gedcomDb, string givenName, string surname)
        {
            var person = new GedcomIndividualRecord(gedcomDb);

            person.Names.Clear();
            if (!string.IsNullOrWhiteSpace(givenName) || !string.IsNullOrWhiteSpace(surname))
            {
                var personName = new GedcomName();
                personName.Level    = 1;
                personName.Database = gedcomDb;
                if (!string.IsNullOrWhiteSpace(givenName))
                {
                    personName.Given = givenName;
                }

                personName.PreferredName = true;
                if (!string.IsNullOrWhiteSpace(surname))
                {
                    personName.Surname = surname;
                }

                person.Names.Add(personName);
            }

            return(person);
        }
        private GedcomName GenerateCompleteName()
        {
            var name = new GedcomName
            {
                Type          = "aka",
                Prefix        = "Miss",
                Given         = "Mary",
                SurnamePrefix = "Neu",
                Surname       = "Neumann",
                Suffix        = "Jr",
                Nick          = "Polly",
                PreferredName = true,
            };

            name.PhoneticVariations.Add(new GedcomVariation {
                Value = "ma-rē", VariationType = "unknown"
            });
            name.PhoneticVariations.Add(new GedcomVariation {
                Value = "mer-ē", VariationType = "unknown"
            });

            name.RomanizedVariations.Add(new GedcomVariation {
                Value = "Miriam"
            });
            name.RomanizedVariations.Add(new GedcomVariation {
                Value = "Maria"
            });

            return(name);
        }
        public void GedComComparison_GedcomName_IsEquivalentTo_ExpectAreEqual()
        {
            // Arrange
            var object1 = new GedcomName();
            var object2 = new GedcomName();

            // Act and Assert
            Assert.True(object1.IsEquivalentTo(object2));
            Assert.True(object2.IsEquivalentTo(object1));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create an individual with a specific name.
        /// </summary>
        /// <param name="gedcomDb">The gedcom database to attach the name and individual to.</param>
        /// <param name="name">The name to place directly into the name field.</param>
        /// <returns>The constructed individual.</returns>
        public static GedcomIndividualRecord NamedPerson(this GedcomDatabase gedcomDb, string name)
        {
            var personName = new GedcomName();

            personName.Level         = 1;
            personName.Database      = gedcomDb;
            personName.Name          = name;
            personName.PreferredName = true;

            var person = new GedcomIndividualRecord(gedcomDb);

            person.Names.Clear();
            person.Names.Add(personName);
            return(person);
        }
Ejemplo n.º 6
0
 private static string GetSurname(GedcomName name)
 {
     if (name.Name.Split('/').Length > 1)
     {
         return(name.Name.Split('/')[1].Trim());
     }
     else if (!string.IsNullOrWhiteSpace(name.Surname))
     {
         return(name.SurnamePrefix.Trim() + " " + name.Surname.Trim());
     }
     else
     {
         return("");
     }
 }
Ejemplo n.º 7
0
		public void SaveView()
		{
			if (_indi != null)
			{
				GedcomName name = null;
				
				if (_indi.Names.Count > 0)
				{
					name = _indi.GetName();
				}
				else
				{
					name = new GedcomName();
					name.Database = _database;
					name.Level = _indi.Level + 1;
					name.PreferedName = true;
					_indi.Names.Add(name);
				}
				
				// don't care if the name is empty, set it anyway
				name.Name = HusbandNameEntry.Text;
				
				GedcomIndividualEvent birth = _indi.Birth;
				if (!string.IsNullOrEmpty(HusbandBornInEntry.Text) ||
				    !string.IsNullOrEmpty(HusbandDateBornEntry.Text))
				{
					if (birth == null)
					{
						birth = new GedcomIndividualEvent();
						birth.Database = _database;
						birth.EventType = GedcomEvent.GedcomEventType.BIRT;
						birth.Level = _indi.Level + 1;
						birth.IndiRecord = _indi;
						_indi.Events.Add(birth);
					}
					if (birth.Place == null)
					{
						birth.Place = new GedcomPlace();
						birth.Place.Level = birth.Level + 1;
					}
					if (birth.Date == null)
					{
						birth.Date = new GedcomDate(_database);
						birth.Date.Level = birth.Level + 1;
					}
					
					birth.Place.Database = _database;
					birth.Place.Name = HusbandBornInEntry.Text;
					birth.Date.ParseDateString(HusbandDateBornEntry.Text);
				}
				else if (birth != null)
				{
					_indi.Events.Remove(birth);	
				}
				
				GedcomIndividualEvent death = _indi.Death;
				if (!string.IsNullOrEmpty(HusbandDiedInEntry.Text) ||
				    !string.IsNullOrEmpty(HusbandDateDiedEntry.Text))
				{
					if (death == null)
					{
						death = new GedcomIndividualEvent();
						death.Database = _database;
						death.EventType = GedcomEvent.GedcomEventType.DEAT;
						death.Level = _indi.Level + 1;
						death.IndiRecord = _indi;
						_indi.Events.Add(death);
					}
					if (death.Place == null)
					{
						death.Place = new GedcomPlace();
						death.Place.Level = death.Level + 1;
					}
					if (death.Date == null)
					{
						death.Date = new GedcomDate(_database);
						death.Date.Level = death.Level + 1;
					}
					
					death.Place.Database = _database;
					death.Place.Name = HusbandDiedInEntry.Text;
					death.Date.ParseDateString(HusbandDateDiedEntry.Text);
				}
				else if (death != null)
				{
					_indi.Events.Remove(death);	
				}
			}
			
		}