public void DeleteFamily(Family family) { Requires.NotNull("family", family); GEDCOMFamilyRecord record = _document.SelectFamilyRecord(GEDCOMUtil.CreateId("F", family.Id)); if (record == null) { //record not in repository throw new ArgumentOutOfRangeException(); } _document.RemoveRecord(record); }
public void GEDCOMDocument_RemoveRecord_Throws_If_Record_IsNull() { var document = new GEDCOMDocument(); //Assert Assert.Throws <ArgumentNullException>(() => document.RemoveRecord(null)); }
public void GEDCOMDocument_RemoveRecord_Throws_If_Record_Not_Present() { //Arrange var document = new GEDCOMDocument(); document.AddRecord(Util.CreateHeaderRecord("Header")); for (int i = 1; i <= 2; i++) { document.AddRecord(Util.CreateIndividualRecord(i)); } var record = Util.CreateIndividualRecord(3); //Assert Assert.Throws <ArgumentOutOfRangeException>(() => document.RemoveRecord(record)); }
public void GEDCOMDocument_RemoveRecord_Removes_Record_From_Individuals_Collection() { //Arrange var document = new GEDCOMDocument(); document.AddRecord(Util.CreateHeaderRecord("Header")); for (int i = 1; i <= 2; i++) { document.AddRecord(Util.CreateIndividualRecord(i)); } var record = document.IndividualRecords[1] as GEDCOMIndividualRecord; //Act document.RemoveRecord(record); //Assert Assert.AreEqual(1, document.IndividualRecords.Count); }