public void TestContextWithMultipleMalformedFields() { SnowplowEventTransformationException exception = null; var malformedContext = "{\n 'schema': 'any',\n 'data': [\n {\n 'schema': 'failing',\n 'data': {\n 'value': 1\n }\n },\n {\n 'data': {\n 'value': 2\n }\n },\n {\n 'schema': 'iglu:com.acme/unduplicated/jsonschema/1-0-0'\n }\n ]\n}"; try { JsonShredder.ParseContexts(malformedContext); } catch (SnowplowEventTransformationException sete) { exception = sete; } var expectedExceptions = new List <string>() { "Schema failing does not conform to schema pattern.", "Context JSON did not contain a stringly typed schema field.", "Could not extract inner data field from custom context." }; var exceptionList = expectedExceptions.Except(exception.ErrorMessages); Assert.Equal(0, exceptionList.Count()); }
protected void TestMultipleMalformedField() { SnowplowEventTransformationException exception = null; var malformedFieldsTsv = new string('\t', 102) + "bad_dvce_ismobile" + new string('\t', 8) + "bad_tax_base" + new string('\t', 20); try { EventTransformer.Transform(malformedFieldsTsv); } catch (SnowplowEventTransformationException sete) { exception = sete; } var expectedExceptions = new List <string>() { "Invalid value bad_dvce_ismobile for field dvce_ismobile", "Unexpected exception parsing field with key tr_tax_base and value bad_tax_base: Input string was not in a correct format." }; var exceptionList = expectedExceptions.Except(exception.ErrorMessages); Assert.Equal(0, exceptionList.Count()); }
public void TestContextWithMalformedField() { SnowplowEventTransformationException exception = null; var malformedContext = "{\n 'schema': 'any',\n 'data': [\n {\n 'schema': 'failing'\n },\n {\n 'schema': 'iglu:com.acme/unduplicated/jsonschema/1-0-0',\n 'data': {\n 'value': 2\n }\n }\n ]\n}"; try { JsonShredder.ParseContexts(malformedContext); } catch (SnowplowEventTransformationException sete) { exception = sete; } Assert.True(exception.Message.Equals("Could not extract inner data field from custom context.")); }