public void CanSerializerSingleErrorFromObject() { var error = new JsonApiError { Status = "422", Source = new JsonApiErrorSource { Pointer = "/data/attributes/firstName" }, Title = "Invalid Attribute", Detail = "First name must contain at least three characters." }; var json = error.Serialize(); Assert.Equal(@" { 'errors': [ { 'status': '422', 'title': 'Invalid Attribute', 'detail': 'First name must contain at least three characters.', 'source': { 'pointer': '/data/attributes/firstName' } } ] }".Format(), json, JsonStringEqualityComparer.Default); }
public void SerializingNullErrorInArrayThrows() { var errors = new JsonApiError[] { null }; var exception = Record.Exception(() => errors.Serialize()); Assert.NotNull(exception); Assert.IsType <JsonApiFormatException>(exception); }