public void TestIt() { // Bean var beanTests = new Pair <SupportMarkerInterface, ValueWithExistsFlag>[] { new Pair <SupportMarkerInterface, ValueWithExistsFlag>(new SupportMarkerImplA("e1"), ValueWithExistsFlag.Exists("e1")), new Pair <SupportMarkerInterface, ValueWithExistsFlag>(new SupportMarkerImplB(1), ValueWithExistsFlag.Exists(1)), new Pair <SupportMarkerInterface, ValueWithExistsFlag>(new SupportMarkerImplC(), ValueWithExistsFlag.NotExists()) }; RunAssertion(BEAN_TYPE.Name, SupportEventInfra.FBEAN, null, beanTests, typeof(object)); // Map var mapTests = new Pair <IDictionary <string, object>, ValueWithExistsFlag>[] { new Pair <IDictionary <string, object>, ValueWithExistsFlag>(Collections.SingletonDataMap("somekey", "10"), ValueWithExistsFlag.NotExists()), new Pair <IDictionary <string, object>, ValueWithExistsFlag>(Collections.SingletonDataMap("id", "abc"), ValueWithExistsFlag.Exists("abc")), new Pair <IDictionary <string, object>, ValueWithExistsFlag>(Collections.SingletonDataMap("id", 10), ValueWithExistsFlag.Exists(10)), }; RunAssertion(SupportEventInfra.MAP_TYPENAME, SupportEventInfra.FMAP, null, mapTests, typeof(object)); // Object-Array var oaTests = new Pair <object[], ValueWithExistsFlag>[] { new Pair <object[], ValueWithExistsFlag>(new object[] { 1, null }, ValueWithExistsFlag.Exists(null)), new Pair <object[], ValueWithExistsFlag>(new object[] { 2, "abc" }, ValueWithExistsFlag.Exists("abc")), new Pair <object[], ValueWithExistsFlag>(new object[] { 3, 10 }, ValueWithExistsFlag.Exists(10)), }; RunAssertion(SupportEventInfra.OA_TYPENAME, SupportEventInfra.FOA, null, oaTests, typeof(object)); // XML var xmlTests = new Pair <string, ValueWithExistsFlag>[] { new Pair <string, ValueWithExistsFlag>("", ValueWithExistsFlag.NotExists()), new Pair <string, ValueWithExistsFlag>("<id>10</id>", ValueWithExistsFlag.Exists("10")), new Pair <string, ValueWithExistsFlag>("<id>abc</id>", ValueWithExistsFlag.Exists("abc")), }; RunAssertion(SupportEventInfra.XML_TYPENAME, SupportEventInfra.FXML, SupportEventInfra.XML_TO_VALUE, xmlTests, typeof(XmlNode)); // Avro var datumEmpty = new GenericRecord(SchemaBuilder.Record(SupportEventInfra.AVRO_TYPENAME)); var datumOne = new GenericRecord(GetAvroSchema()); datumOne.Put("id", 101); var datumTwo = new GenericRecord(GetAvroSchema()); datumTwo.Put("id", null); var avroTests = new Pair <GenericRecord, ValueWithExistsFlag>[] { new Pair <GenericRecord, ValueWithExistsFlag>(datumEmpty, ValueWithExistsFlag.NotExists()), new Pair <GenericRecord, ValueWithExistsFlag>(datumOne, ValueWithExistsFlag.Exists(101)), new Pair <GenericRecord, ValueWithExistsFlag>(datumTwo, ValueWithExistsFlag.Exists(null)) }; RunAssertion(SupportEventInfra.AVRO_TYPENAME, SupportEventInfra.FAVRO, null, avroTests, typeof(object)); }
private void RunAssertion(EventRepresentationChoice outputEventRep, string additionalAnnotations) { // Bean var beanTests = new Pair <SupportBeanDynRoot, ValueWithExistsFlag>[] { new Pair <SupportBeanDynRoot, ValueWithExistsFlag>(new SupportBeanDynRoot(new SupportBean_S0(101)), ValueWithExistsFlag.Exists(101)), new Pair <SupportBeanDynRoot, ValueWithExistsFlag>(new SupportBeanDynRoot("abc"), ValueWithExistsFlag.NotExists()), new Pair <SupportBeanDynRoot, ValueWithExistsFlag>(new SupportBeanDynRoot(new SupportBean_A("e1")), ValueWithExistsFlag.Exists("e1")), new Pair <SupportBeanDynRoot, ValueWithExistsFlag>(new SupportBeanDynRoot(new SupportBean_B("e2")), ValueWithExistsFlag.Exists("e2")), new Pair <SupportBeanDynRoot, ValueWithExistsFlag>(new SupportBeanDynRoot(new SupportBean_S1(102)), ValueWithExistsFlag.Exists(102)) }; RunAssertion(outputEventRep, additionalAnnotations, BEAN_TYPENAME, SupportEventInfra.FBEAN, null, beanTests, typeof(object)); // Map var mapTests = new Pair <IDictionary <string, object>, ValueWithExistsFlag>[] { new Pair <IDictionary <string, object>, ValueWithExistsFlag>(Collections.EmptyDataMap, ValueWithExistsFlag.NotExists()), new Pair <IDictionary <string, object>, ValueWithExistsFlag>(Collections.SingletonDataMap("item", Collections.SingletonDataMap("id", 101)), ValueWithExistsFlag.Exists(101)), new Pair <IDictionary <string, object>, ValueWithExistsFlag>(Collections.SingletonDataMap("item", Collections.EmptyDataMap), ValueWithExistsFlag.NotExists()), }; RunAssertion(outputEventRep, additionalAnnotations, SupportEventInfra.MAP_TYPENAME, SupportEventInfra.FMAP, null, mapTests, typeof(object)); // Object array var oaTests = new Pair <object[], ValueWithExistsFlag>[] { new Pair <object[], ValueWithExistsFlag>(new object[] { null }, ValueWithExistsFlag.NotExists()), //new Pair<>(new Object[] {new SupportBean_S0(101)}, exists(101)), //new Pair<>(new Object[] {"abc"}, notExists()), }; RunAssertion(outputEventRep, additionalAnnotations, SupportEventInfra.OA_TYPENAME, SupportEventInfra.FOA, null, oaTests, typeof(object)); // XML var xmlTests = new Pair <string, ValueWithExistsFlag>[] { new Pair <string, ValueWithExistsFlag>("<item id=\"101\"/>", ValueWithExistsFlag.Exists("101")), new Pair <string, ValueWithExistsFlag>("<item/>", ValueWithExistsFlag.NotExists()), }; if (!outputEventRep.IsAvroEvent()) { RunAssertion(outputEventRep, additionalAnnotations, SupportEventInfra.XML_TYPENAME, SupportEventInfra.FXML, SupportEventInfra.XML_TO_VALUE, xmlTests, typeof(XmlNode)); } // Avro var avroTests = new Pair <object, ValueWithExistsFlag>[] { new Pair <object, ValueWithExistsFlag>(null, ValueWithExistsFlag.Exists(null)), new Pair <object, ValueWithExistsFlag>(101, ValueWithExistsFlag.Exists(101)), new Pair <object, ValueWithExistsFlag>("abc", ValueWithExistsFlag.Exists("abc")), }; RunAssertion(outputEventRep, additionalAnnotations, SupportEventInfra.AVRO_TYPENAME, FAVRO, null, avroTests, typeof(object)); }
public void TestIt() { var NOT_EXISTS = ValueWithExistsFlag.MultipleNotExists(3); // Bean var beanTests = new Pair <SupportMarkerInterface, ValueWithExistsFlag[]>[] { new Pair <SupportMarkerInterface, ValueWithExistsFlag[]>(SupportBeanComplexProps.MakeDefaultBean(), ValueWithExistsFlag.AllExist("Simple", "NestedValue", "NestedNestedValue")), new Pair <SupportMarkerInterface, ValueWithExistsFlag[]>(new SupportMarkerImplA("x"), NOT_EXISTS), }; RunAssertion(BEAN_TYPE.Name, SupportEventInfra.FBEAN, null, beanTests, typeof(object)); // Map var mapNestedNestedOne = Collections.SingletonDataMap("nestedNestedValue", 101); IDictionary <string, object> mapNestedOne = SupportEventInfra.TwoEntryMap("nestedNested", mapNestedNestedOne, "nestedValue", "abc"); IDictionary <string, object> mapOne = SupportEventInfra.TwoEntryMap("simpleProperty", 5, "nested", mapNestedOne); var mapTests = new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>[] { new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(Collections.SingletonDataMap("simpleProperty", "a"), new ValueWithExistsFlag[] { ValueWithExistsFlag.Exists("a"), ValueWithExistsFlag.NotExists(), ValueWithExistsFlag.NotExists() }), new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(mapOne, ValueWithExistsFlag.AllExist(5, "abc", 101)), }; RunAssertion(SupportEventInfra.MAP_TYPENAME, SupportEventInfra.FMAP, null, mapTests, typeof(object)); // Object-Array var oaNestedNestedOne = new object[] { 101 }; var oaNestedOne = new object[] { "abc", oaNestedNestedOne }; var oaOne = new object[] { 5, oaNestedOne }; var oaTests = new Pair <object[], ValueWithExistsFlag[]>[] { new Pair <object[], ValueWithExistsFlag[]>(new object[] { "a", null }, new ValueWithExistsFlag[] { ValueWithExistsFlag.Exists("a"), ValueWithExistsFlag.NotExists(), ValueWithExistsFlag.NotExists() }), new Pair <object[], ValueWithExistsFlag[]>(oaOne, ValueWithExistsFlag.AllExist(5, "abc", 101)), }; RunAssertion(SupportEventInfra.OA_TYPENAME, SupportEventInfra.FOA, null, oaTests, typeof(object)); // XML var xmlTests = new Pair <string, ValueWithExistsFlag[]>[] { new Pair <string, ValueWithExistsFlag[]>( "<simpleProperty>abc</simpleProperty>" + "<nested nestedValue=\"100\">\n" + "\t<nestedNested nestedNestedValue=\"101\">\n" + "\t</nestedNested>\n" + "</nested>\n", ValueWithExistsFlag.AllExist("abc", "100", "101")), new Pair <string, ValueWithExistsFlag[]>("<nested/>", NOT_EXISTS), }; RunAssertion(SupportEventInfra.XML_TYPENAME, SupportEventInfra.FXML, SupportEventInfra.XML_TO_VALUE, xmlTests, typeof(XmlNode)); // Avro var schema = GetAvroSchema(); var datumNull = new GenericRecord(schema); var nestedSchema = AvroSchemaUtil.FindUnionRecordSchemaSingle(schema.GetField("nested").Schema).AsRecordSchema(); var nestedNestedSchema = AvroSchemaUtil.FindUnionRecordSchemaSingle(nestedSchema.GetField("nestedNested").Schema).AsRecordSchema(); var nestedNestedDatum = new GenericRecord(nestedNestedSchema); nestedNestedDatum.Put("nestedNestedValue", 101); var nestedDatum = new GenericRecord(nestedSchema); nestedDatum.Put("nestedValue", 100); nestedDatum.Put("nestedNested", nestedNestedDatum); var datumOne = new GenericRecord(schema); datumOne.Put("simpleProperty", "abc"); datumOne.Put("nested", nestedDatum); var avroTests = new Pair <GenericRecord, ValueWithExistsFlag[]>[] { new Pair <GenericRecord, ValueWithExistsFlag[]>(new GenericRecord(SchemaBuilder.Record(SupportEventInfra.AVRO_TYPENAME)), NOT_EXISTS), new Pair <GenericRecord, ValueWithExistsFlag[]>(datumNull, new ValueWithExistsFlag[] { ValueWithExistsFlag.Exists(null), ValueWithExistsFlag.NotExists(), ValueWithExistsFlag.NotExists() }), new Pair <GenericRecord, ValueWithExistsFlag[]>(datumOne, ValueWithExistsFlag.AllExist("abc", 100, 101)), }; RunAssertion(SupportEventInfra.AVRO_TYPENAME, SupportEventInfra.FAVRO, null, avroTests, typeof(object)); }
public void TestIt() { var NOT_EXISTS = ValueWithExistsFlag.MultipleNotExists(6); // Bean SupportBeanComplexProps inner = SupportBeanComplexProps.MakeDefaultBean(); var beanTests = new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>[] { new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>(new SupportBeanDynRoot("xxx"), NOT_EXISTS), new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>(new SupportBeanDynRoot(inner), ValueWithExistsFlag.AllExist( inner.GetIndexed(0), inner.GetIndexed(1), inner.ArrayProperty[1], inner.GetMapped("keyOne"), inner.GetMapped("keyTwo"), inner.MapProperty.Get("xOne"))), }; RunAssertion(BEAN_TYPE.Name, SupportEventInfra.FBEAN, null, beanTests, typeof(object)); // Map IDictionary <string, object> mapNestedOne = new Dictionary <string, object>(); mapNestedOne.Put("indexed", new int[] { 1, 2 }); mapNestedOne.Put("arrayProperty", null); mapNestedOne.Put("mapped", SupportEventInfra.TwoEntryMap("keyOne", 100, "keyTwo", 200)); mapNestedOne.Put("mapProperty", null); var mapOne = Collections.SingletonDataMap("item", mapNestedOne); var mapTests = new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>[] { new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(Collections.EmptyDataMap, NOT_EXISTS), new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(mapOne, new ValueWithExistsFlag[] { ValueWithExistsFlag.Exists(1), ValueWithExistsFlag.Exists(2), ValueWithExistsFlag.NotExists(), ValueWithExistsFlag.Exists(100), ValueWithExistsFlag.Exists(200), ValueWithExistsFlag.NotExists() }), }; RunAssertion(SupportEventInfra.MAP_TYPENAME, SupportEventInfra.FMAP, null, mapTests, typeof(object)); // Object-Array var oaNestedOne = new object[] { new int[] { 1, 2 }, SupportEventInfra.TwoEntryMap("keyOne", 100, "keyTwo", 200), new int[] { 1000, 2000 }, Collections.SingletonMap("xOne", "abc") }; var oaOne = new object[] { null, oaNestedOne }; var oaTests = new Pair <object[], ValueWithExistsFlag[]>[] { new Pair <object[], ValueWithExistsFlag[]>(new object[] { null, null }, NOT_EXISTS), new Pair <object[], ValueWithExistsFlag[]>(oaOne, ValueWithExistsFlag.AllExist(1, 2, 2000, 100, 200, "abc")), }; RunAssertion(SupportEventInfra.OA_TYPENAME, SupportEventInfra.FOA, null, oaTests, typeof(object)); // XML var xmlTests = new Pair <string, ValueWithExistsFlag[]>[] { new Pair <string, ValueWithExistsFlag[]>("", NOT_EXISTS), new Pair <string, ValueWithExistsFlag[]>( "<item>" + "<indexed>1</indexed><indexed>2</indexed><mapped id=\"keyOne\">3</mapped><mapped id=\"keyTwo\">4</mapped>" + "</item>", new ValueWithExistsFlag[] { ValueWithExistsFlag.Exists("1"), ValueWithExistsFlag.Exists("2"), ValueWithExistsFlag.NotExists(), ValueWithExistsFlag.Exists("3"), ValueWithExistsFlag.Exists("4"), ValueWithExistsFlag.NotExists() }) }; RunAssertion(SupportEventInfra.XML_TYPENAME, SupportEventInfra.FXML, SupportEventInfra.XML_TO_VALUE, xmlTests, typeof(XmlNode)); // Avro var schema = GetAvroSchema(); var itemSchema = AvroSchemaUtil.FindUnionRecordSchemaSingle(schema.GetField("item").Schema).AsRecordSchema(); var datumOne = new GenericRecord(schema); datumOne.Put("item", null); var datumItemTwo = new GenericRecord(itemSchema); datumItemTwo.Put("indexed", Collections.List(1, 2)); datumItemTwo.Put("mapped", SupportEventInfra.TwoEntryMap("keyOne", 3, "keyTwo", 4)); var datumTwo = new GenericRecord(schema); datumTwo.Put("item", datumItemTwo); var avroTests = new Pair <GenericRecord, ValueWithExistsFlag[]>[] { new Pair <GenericRecord, ValueWithExistsFlag[]>(new GenericRecord(schema), NOT_EXISTS), new Pair <GenericRecord, ValueWithExistsFlag[]>(datumOne, NOT_EXISTS), new Pair <GenericRecord, ValueWithExistsFlag[]>(datumTwo, new ValueWithExistsFlag[] { ValueWithExistsFlag.Exists(1), ValueWithExistsFlag.Exists(2), ValueWithExistsFlag.NotExists(), ValueWithExistsFlag.Exists(3), ValueWithExistsFlag.Exists(4), ValueWithExistsFlag.NotExists() }), }; RunAssertion(SupportEventInfra.AVRO_TYPENAME, SupportEventInfra.FAVRO, null, avroTests, typeof(object)); }