public void AllEntities_AllPublicPropertiesAreMarkedWithExpectedAttributes() { List <Type> jsonObjectTypes = SerializationTestsHelper.GetJsonObjectTypes(); foreach (Type type in jsonObjectTypes) { foreach (PropertyInfo propertyInfo in type.GetProperties( BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { if (propertyInfo.GetCustomAttribute <JsonPropertyAttribute>() == null && propertyInfo.GetCustomAttribute <JsonIgnoreAttribute>() == null) { Assert.Fail($"For type '{type.Name}', property '{propertyInfo.Name}' is missing " + $"{nameof(JsonPropertyAttribute)} or {nameof(JsonIgnoreAttribute)}."); } } } }
public void AllEntities_SerializeAndDeserializeCorrectly() { List <Type> jsonObjectTypes = SerializationTestsHelper.GetJsonObjectTypes(); string typeName = null; try { foreach (Type type in jsonObjectTypes) { typeName = type.Name; SerializationTestsHelper.Test(type); } } catch (Exception e) { Assert.Fail($"Type {typeName} failed to serialize/deserialize: {e}"); } }