Created
January 22, 2018 20:05
-
-
Save hermanussen/6acab44405092ebe5a47c5a860a4d958 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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