Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hermanussen/6acab44405092ebe5a47c5a860a4d958 to your computer and use it in GitHub Desktop.
Save hermanussen/6acab44405092ebe5a47c5a860a4d958 to your computer and use it in GitHub Desktop.
[Test(Description = "Checks if Sitecore IDs in a class with constants can be found in the serialized data")]
public void ShouldIdsBeFoundInSerializedData(
[Values(typeof(Constants))]
Type typeWithIdConstants)
{
foreach (FieldInfo field in typeWithIdConstants
.GetFields(BindingFlags.Public | BindingFlags.Static)
.Where(f => f.FieldType == typeof (ID)))
{
ID constantValue = field.GetValue(null) as ID;
if (((object) constantValue) != null)
{
constantValue
.FindFilePath("master")
.Should()
.NotBeNullOrWhiteSpace(
"Item with ID {0} (as defined by {1}.{2}) should be in the serialized data",
constantValue,
field.DeclaringType.Name,
field.Name);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment