Beispiel #1
0
        public void ExternalFlagsEnumerationTest()
        {
            // This should create a new enum with [Flags] because of the "enumFlags" parameter
            var csv      = "10,Org.XmlPull.V1.XmlPullParserNode,Cdsect,I:org/xmlpull/v1/XmlPullParser.CDSECT,5";
            var mappings = new EnumMappings(string.Empty, string.Empty, "30", false);
            var sr       = new StringReader(csv);

            var removes = new List <KeyValuePair <string, string> > ();
            var enums   = mappings.ParseFieldMappings(sr, new [] { "Org.XmlPull.V1.XmlPullParserNode" }, 30, removes);

            Assert.AreEqual(true, enums.Single().Value.BitField);
        }
Beispiel #2
0
        public void ApiVersionExcludedV2Test()
        {
            // This should be completely ignored because it's API=10 and we're looking for API=5
            var csv      = "E,10,I:org/xmlpull/v1/XmlPullParser.CDSECT,5,Org.XmlPull.V1.XmlPullParserNode,Cdsect";
            var mappings = new EnumMappings(string.Empty, string.Empty, "5", false);
            var sr       = new StringReader(csv);

            var removes = new List <KeyValuePair <string, string> > ();
            var enums   = mappings.ParseFieldMappings(sr, new string [0], 5, removes);

            Assert.AreEqual(0, removes.Count);
            Assert.AreEqual(0, enums.Count);
        }
Beispiel #3
0
        public void RemoveFieldOnlyTest()
        {
            // This should only remove the field
            var csv      = "10,,,I:org/xmlpull/v1/XmlPullParser.CDSECT,5";
            var mappings = new EnumMappings(string.Empty, string.Empty, "30", false);
            var sr       = new StringReader(csv);

            var removes = new List <KeyValuePair <string, string> > ();
            var enums   = mappings.ParseFieldMappings(sr, new string [0], 30, removes);

            Assert.AreEqual("[I:org/xmlpull/v1/XmlPullParser.CDSECT, ]", removes.Single().ToString());

            Assert.AreEqual(0, enums.Count);
        }
Beispiel #4
0
        public void TransientRemoveFieldOnlyTest()
        {
            // Transient has no effect here
            var csv      = $"- ENTER TRANSIENT MODE -{Environment.NewLine}10,,,I:org/xmlpull/v1/XmlPullParser.CDSECT,5";
            var mappings = new EnumMappings(string.Empty, string.Empty, "30", false);
            var sr       = new StringReader(csv);

            var removes = new List <KeyValuePair <string, string> > ();
            var enums   = mappings.ParseFieldMappings(sr, new string [0], 30, removes);

            Assert.AreEqual("[I:org/xmlpull/v1/XmlPullParser.CDSECT, ]", removes.Single().ToString());

            Assert.AreEqual(0, enums.Count);
        }
Beispiel #5
0
        public void AddConstantOnlyTest()
        {
            // This should only add an enum
            var csv      = "10,Org.XmlPull.V1.XmlPullParserNode,Cdsect,,5";
            var mappings = new EnumMappings(string.Empty, string.Empty, "30", false);
            var sr       = new StringReader(csv);

            var removes = new List <KeyValuePair <string, string> > ();
            var enums   = mappings.ParseFieldMappings(sr, new string [0], 30, removes);

            Assert.AreEqual(0, removes.Count);

            Assert.AreEqual("Org.XmlPull.V1.XmlPullParserNode", enums.Single().Key);
            Assert.AreEqual(false, enums.Single().Value.BitField);
            Assert.AreEqual(true, enums.Single().Value.FieldsRemoved);
            Assert.AreEqual("[Cdsect, ]", enums.First().Value.JniNames.Single().ToString());
            Assert.AreEqual("[Cdsect, 5]", enums.First().Value.Members.Single().ToString());
        }
Beispiel #6
0
        public void TransientEnumificationV2Test()
        {
            // This should create a new enum and remove the field
            var csv      = "E,10,I:org/xmlpull/v1/XmlPullParser.CDSECT,5,Org.XmlPull.V1.XmlPullParserNode,Cdsect,remove";
            var mappings = new EnumMappings(string.Empty, string.Empty, "30", false);
            var sr       = new StringReader(csv);

            var removes = new List <KeyValuePair <string, string> > ();
            var enums   = mappings.ParseFieldMappings(sr, new string [0], 30, removes);

            Assert.AreEqual("[I:org/xmlpull/v1/XmlPullParser.CDSECT, Org.XmlPull.V1.XmlPullParserNode]", removes.Single().ToString());

            Assert.AreEqual("Org.XmlPull.V1.XmlPullParserNode", enums.Single().Key);
            Assert.AreEqual(false, enums.Single().Value.BitField);
            Assert.AreEqual(false, enums.Single().Value.FieldsRemoved);
            Assert.AreEqual("[Cdsect, I:org/xmlpull/v1/XmlPullParser.CDSECT]", enums.First().Value.JniNames.Single().ToString());
            Assert.AreEqual("[Cdsect, 5]", enums.First().Value.Members.Single().ToString());
        }