private GEDCOMFamilyRecord GetFamilyRecord(Individual individual) { string fatherId = individual.FatherId; string motherId = individual.MotherId; var familyRecord = !string.IsNullOrEmpty(fatherId) ? (!string.IsNullOrEmpty(motherId) ? _document.SelectFamilyRecord(GEDCOMUtil.CreateId("I", fatherId), GEDCOMUtil.CreateId("I", motherId)) : _document.SelectHusbandsFamilyRecords(GEDCOMUtil.CreateId("I", fatherId)).FirstOrDefault()) : _document.SelectWifesFamilyRecords(GEDCOMUtil.CreateId("I", motherId)).FirstOrDefault(); return(familyRecord); }
public void GEDCOMDocument_SelectFamilyRecord_Throws_On_Null_WifeId(string fileName, string husbandId, string wifeId) { //Arrange var document = new GEDCOMDocument(); document.LoadGEDCOM(GetEmbeddedFileString(fileName)); //Act, Assert Assert.Throws <ArgumentNullException>(() => document.SelectFamilyRecord(husbandId, wifeId)); }
public void GEDCOMDocument_SelectFamilyRecord_Returns_Null_When_Given_InValid_HusbandId_Or_WifeId(string fileName, string husbandId, string wifeId) { //Arrange var document = new GEDCOMDocument(); document.LoadGEDCOM(GetEmbeddedFileString(fileName)); //Act var record = document.SelectFamilyRecord(husbandId, wifeId); //Assert Assert.IsNull(record); }
public void GEDCOMDocument_SelectFamilyRecord_Returns_Family_When_Given_Valid_Id(string fileName, string familyId) { //Arrange var document = new GEDCOMDocument(); document.LoadGEDCOM(GetEmbeddedFileString(fileName)); //Act var record = document.SelectFamilyRecord(familyId); //Assert Assert.IsNotNull(record); Assert.AreEqual(record.Id, familyId); }