diff --git a/src/LibFLExBridge-ChorusPlugin/Handling/ConfigLayout/FieldWorksConfigurationLayoutValidator.cs b/src/LibFLExBridge-ChorusPlugin/Handling/ConfigLayout/FieldWorksConfigurationLayoutValidator.cs
index 288da3ec0..e87c37d20 100644
--- a/src/LibFLExBridge-ChorusPlugin/Handling/ConfigLayout/FieldWorksConfigurationLayoutValidator.cs
+++ b/src/LibFLExBridge-ChorusPlugin/Handling/ConfigLayout/FieldWorksConfigurationLayoutValidator.cs
@@ -29,8 +29,10 @@ internal static string Validate(string pathToFile)
return ValidateLayoutTypeElement(childElement);
case "layout":
return ValidateLayoutElement(childElement);
+ case "part":
+ return ValidatePartElement(childElement);
default:
- return "Layout file contains unrecognized child element.";
+ return "Layout file contains unrecognized child element: " + childElement.Name.LocalName + ".";
}
}
}
@@ -108,7 +110,7 @@ private static string ValidateLayoutElement(XElement layout)
case "generate":
return ValidateGenerateElement(childElement);
default:
- return "Layout element contains unrecognized child element.";
+ return "Layout element contains unrecognized child element" + childElement.Name.LocalName + ".";
}
}
return null;
@@ -118,6 +120,16 @@ private static string ValidatePartElement(XElement part)
{
if (part.Attribute("ref") == null)
return "Required 'ref' attribute is missing.";
+ foreach (var childElement in part.Elements())
+ {
+ if (childElement.Name.LocalName == "indent")
+ {
+ foreach (var grandChildElement in childElement.Elements())
+ {
+ ValidatePartElement(grandChildElement);
+ }
+ }
+ }
return null;
}
diff --git a/src/LibFLExBridge-ChorusPluginTests/Handling/ConfigLayout/FieldWorksCustomLayoutTypeHandlerTests.cs b/src/LibFLExBridge-ChorusPluginTests/Handling/ConfigLayout/FieldWorksCustomLayoutTypeHandlerTests.cs
index 532c25a66..6051c1134 100644
--- a/src/LibFLExBridge-ChorusPluginTests/Handling/ConfigLayout/FieldWorksCustomLayoutTypeHandlerTests.cs
+++ b/src/LibFLExBridge-ChorusPluginTests/Handling/ConfigLayout/FieldWorksCustomLayoutTypeHandlerTests.cs
@@ -13,6 +13,7 @@
using NUnit.Framework;
using SIL.IO;
using SIL.Progress;
+using System.Text.RegularExpressions;
namespace LibFLExBridgeChorusPluginTests.Handling.ConfigLayout
{
@@ -109,6 +110,24 @@ public void ShouldNotBeAbleToValidateFile()
Assert.IsNotNull(FileHandler.ValidateFile(_ourFile.Path, new NullProgress()));
}
+ [Test]
+ public void ShouldBeAbleToValidateFileWithPartAndIndent()
+ {
+ const string data =
+@"
+
+
+
+
+
+
+
+";
+
+ File.WriteAllText(_ourFile.Path, data);
+ Assert.IsNull(FileHandler.ValidateFile(_ourFile.Path, new NullProgress()));
+ }
+
[Test]
public void ShouldBeAbleToValidateFile()
{
@@ -357,5 +376,45 @@ public void SampleMergeWithEmptyAncestor()
Assert.IsFalse(results.Contains("combinedkey"));
}
+
+ [Test]
+ public void SampleMergeWithPartAndIndent()
+ {
+ const string commonAncestor =
+@"
+
+
+
+
+
+
+
+";
+ const string ourContent =
+@"
+
+
+
+
+
+
+
+";
+
+ const string theirContent = commonAncestor;
+
+ var results = FieldWorksTestServices.DoMerge(
+ FileHandler,
+ _ourFile, ourContent,
+ _commonFile, commonAncestor,
+ _theirFile, theirContent,
+ null, null,
+ 0, new List(),
+ 1, new List { typeof(XmlChangedRecordReport) });
+ string normalizedResults = Regex.Replace(results, @"\s", "");
+ string normalizedOurContent = Regex.Replace(ourContent, @"\s", "");
+ Assert.AreEqual(normalizedResults, normalizedOurContent);
+ }
+
}
}
\ No newline at end of file