diff --git a/src/SIL.LCModel.FixData/FwDataFixer.cs b/src/SIL.LCModel.FixData/FwDataFixer.cs index 66b5c041..90f3e3ba 100644 --- a/src/SIL.LCModel.FixData/FwDataFixer.cs +++ b/src/SIL.LCModel.FixData/FwDataFixer.cs @@ -256,6 +256,11 @@ internal override bool FixElement(XElement rt, ErrorLogger errorLogger) errorLogger(String.Format(Strings.ksRemovingObjectWithBadOwner, guidOwner, className, guid), true); return false; } + else + { + errorLogger(String.Format(Strings.ksRemovingDisownedObject, guidOwner, className, guid), true); + return false; + } } } else if (storedOwner != Guid.Empty) diff --git a/src/SIL.LCModel.FixData/Strings.Designer.cs b/src/SIL.LCModel.FixData/Strings.Designer.cs index 61d6ecb8..972d1d39 100644 --- a/src/SIL.LCModel.FixData/Strings.Designer.cs +++ b/src/SIL.LCModel.FixData/Strings.Designer.cs @@ -258,6 +258,15 @@ public static string ksRemovingObjectWithBadOwner { } } + /// + /// Looks up a localized string similar to Removing disowned object (invalid ownerguid='{0}', class='{1}', guid='{2}').. + /// + public static string ksRemovingDisownedObject { + get { + return ResourceManager.GetString("ksRemovingDisownedObject", resourceCulture); + } + } + /// /// Looks up a localized string similar to Removing owner of empty sequence (guid='{0}' class='{1}') from its owner (guid='{2}').. /// diff --git a/src/SIL.LCModel.FixData/Strings.resx b/src/SIL.LCModel.FixData/Strings.resx index 255637f9..632d5765 100644 --- a/src/SIL.LCModel.FixData/Strings.resx +++ b/src/SIL.LCModel.FixData/Strings.resx @@ -135,6 +135,9 @@ Removing object with nonexistent owner (invalid ownerguid='{0}', class='{1}', guid='{2}'). + + Removing disowned object (invalid ownerguid='{0}', class='{1}', guid='{2}'). + Adding ownerguid='{0}' (class='{1}', guid='{2}'). diff --git a/tests/SIL.LCModel.FixData.Tests/FwDataFixerTests.cs b/tests/SIL.LCModel.FixData.Tests/FwDataFixerTests.cs index 2205934d..f2ab3413 100644 --- a/tests/SIL.LCModel.FixData.Tests/FwDataFixerTests.cs +++ b/tests/SIL.LCModel.FixData.Tests/FwDataFixerTests.cs @@ -441,6 +441,8 @@ public void DanglingWordformLinks() var danglingMorphGoodSenseGuid = "9665bf3b-2aab-4f7f-88a9-4ca738b75110"; var danglingMorphNoRepairGuid = "5752ed24-40e1-4282-9ba0-d82c89592432"; var danglingMorphNoRepairAfGuid = "1f568cae-b0f8-413d-84a6-41cbd90923e9"; + var disownedOwnerGuid = "16827d7a-cf4e-45f8-aaa1-66cef5c2cc4d"; + var disownedGuid = "1f568cae-b0f8-413d-84a6-41cbd90923e9"; // Verify initial state. // We start out with morph bundles that have broken links. @@ -463,7 +465,7 @@ public void DanglingWordformLinks() "//rt[@class=\"WfiMorphBundle\" and @guid=\"" + danglingMorphNoRepairAfGuid + "\"]/Morph/objsur[@guid=\"" + danglingMsaGuid + "\"]", 1); // Check errors - Assert.AreEqual(10, _errors.Count, "Unexpected number of errors found."); + Assert.AreEqual(11, _errors.Count, "Unexpected number of errors found."); Assert.True(_errors[0].StartsWith("Removing dangling link to '" + danglingMsaGuid + "' (class='LexEntry'"), "Error message is incorrect."); // OriginalFixer--ksRemovingLinkToNonexistingObject Assert.That(_errors[1], Is.EqualTo("Fixing link to MSA based on Sense MSA (class='WfiMorphBundle', guid='" + repairableBundleGuid + "')."), @@ -480,7 +482,9 @@ public void DanglingWordformLinks() "Error message is incorrect."); // MorphBundleFixer--ksRemovingDanglingMsa Assert.That(_errors[8], Is.EqualTo("Removing dangling link to Form '" + danglingMsaGuid + "' for WfiMorphBundle '" + danglingMorphNoRepairGuid + "'."), "Error message is incorrect."); // MorphBundleFixer--ksRemovingDanglingMorph - Assert.That(_errors[9], Is.EqualTo("Removing dangling link to Form '" + danglingMsaGuid + "' for WfiMorphBundle '" + danglingMorphNoRepairAfGuid + "'."), + Assert.True(_errors[9].StartsWith("Removing disowned object (invalid ownerguid='" + disownedOwnerGuid + "', class='WfiMorphBundle', guid='" + disownedGuid), + "Error message is incorrect."); // MorphBundleFixer--ksRemovingDanglingMorph + Assert.That(_errors[10], Is.EqualTo("Removing dangling link to Form '" + danglingMsaGuid + "' for WfiMorphBundle '" + danglingMorphNoRepairAfGuid + "'."), "Error message is incorrect."); // MorphBundleFixer--ksRemovingDanglingMorph // Check file repair @@ -498,6 +502,8 @@ public void DanglingWordformLinks() "//rt[@class=\"WfiMorphBundle\" and @guid=\"" + danglingMorphNoRepairGuid + "\"]/Morph", 0); // must remove Morph, not just child objsur AssertThatXmlIn.File(Path.Combine(testPath, "BasicFixup.fwdata")).HasSpecifiedNumberOfMatchesForXpath( "//rt[@class=\"WfiMorphBundle\" and @guid=\"" + danglingMorphNoRepairAfGuid + "\"]/Morph/objsur", 0); + AssertThatXmlIn.File(Path.Combine(testPath, "BasicFixup.fwdata")).HasSpecifiedNumberOfMatchesForXpath( + "//rt[@class=\"WfiMorphBundle\" and @guid=\"" + disownedGuid + "\"]/Morph/objsur", 0); } /// diff --git a/tests/SIL.LCModel.FixData.Tests/TestData/DeletedMsaRefBySenseAndBundle/Test.fwdata b/tests/SIL.LCModel.FixData.Tests/TestData/DeletedMsaRefBySenseAndBundle/Test.fwdata index 99df4cfa..e39b0c0c 100644 --- a/tests/SIL.LCModel.FixData.Tests/TestData/DeletedMsaRefBySenseAndBundle/Test.fwdata +++ b/tests/SIL.LCModel.FixData.Tests/TestData/DeletedMsaRefBySenseAndBundle/Test.fwdata @@ -20,12 +20,12 @@ - + - + diff --git a/tests/SIL.LCModel.FixData.Tests/TestData/MorphBundleProblems/Test.fwdata b/tests/SIL.LCModel.FixData.Tests/TestData/MorphBundleProblems/Test.fwdata index b1f724ba..694ed43f 100644 --- a/tests/SIL.LCModel.FixData.Tests/TestData/MorphBundleProblems/Test.fwdata +++ b/tests/SIL.LCModel.FixData.Tests/TestData/MorphBundleProblems/Test.fwdata @@ -25,12 +25,17 @@ - + - + + + + + +