Exemple #1
0
        public void WriteManagedToJavaWithNoTypes()
        {
            var v = new TypeNameMapGenerator(new string[0], logger: Diagnostic.CreateConsoleLogger());
            var o = new MemoryStream();

            v.WriteManagedToJava(o);
            var a = ToArray(o);

            Assert.AreEqual(52, a.Length);
        }
Exemple #2
0
        public void WriteManagedToJava()
        {
            var types = SupportDeclarations.GetTestTypeDefinitions();
            var v     = new TypeNameMapGenerator(types, logger: Diagnostic.CreateConsoleLogger());
            var o     = new MemoryStream();

            v.WriteManagedToJava(o);
            var a = ToArray(o);

            Save(a, "__m2j");
            var length = 190;
            var offset = 114;
            var e      =
                "version=1\u0000" +
                $"entry-count={types.Count}\u0000" +
                "entry-len=" + length + "\u0000" +
                "value-offset=" + offset + "\u0000" +
                GetM2JEntryLine(typeof(AbstractClass), "my/AbstractClass", offset, length) +
                GetM2JEntryLine(typeof(AbstractClassInvoker), "my/AbstractClass", offset, length) +
                GetM2JEntryLine(typeof(ActivityName), "activity/Name", offset, length) +
                GetM2JEntryLine(typeof(ApplicationName), "application/Name", offset, length) +
                GetM2JEntryLine(typeof(DefaultName.A.B), "crc64197ae30a36756915/DefaultName_A_B", offset, length) +
                GetM2JEntryLine(typeof(DefaultName.A), "crc64197ae30a36756915/DefaultName_A", offset, length) +
                GetM2JEntryLine(typeof(DefaultName.C.D), "crc64197ae30a36756915/DefaultName_C_D", offset, length) +
                GetM2JEntryLine(typeof(DefaultName), "crc64197ae30a36756915/DefaultName", offset, length) +
                GetM2JEntryLine(typeof(ExampleActivity), "my/ExampleActivity", offset, length) +
                GetM2JEntryLine(typeof(ExampleInstrumentation), "my/ExampleInstrumentation", offset, length) +
                GetM2JEntryLine(typeof(ExampleOuterClass.ExampleInnerClass), "crc64197ae30a36756915/ExampleOuterClass$ExampleOuterClass_ExampleInnerClass", offset, length) +
                GetM2JEntryLine(typeof(ExampleOuterClass), "crc64197ae30a36756915/ExampleOuterClass", offset, length) +
                GetM2JEntryLine(typeof(InstrumentationName), "instrumentation/Name", offset, length) +
                GetM2JEntryLine(typeof(NonStaticOuterClass.NonStaticInnerClass), "register/NonStaticOuterClass$NonStaticInnerClass", offset, length) +
                GetM2JEntryLine(typeof(NonStaticOuterClass), "register/NonStaticOuterClass", offset, length) +
                GetM2JEntryLine(typeof(ProviderName), "provider/Name", offset, length) +
                GetM2JEntryLine(typeof(ReceiverName), "receiver/Name", offset, length) +
                GetM2JEntryLine(typeof(RegisterName.DefaultNestedName), "register/Name_DefaultNestedName", offset, length) +
                GetM2JEntryLine(typeof(RegisterName.OverrideNestedName), "register/Name$Override", offset, length) +
                GetM2JEntryLine(typeof(RegisterName), "register/Name", offset, length) +
                GetM2JEntryLine(typeof(ServiceName), "service/Name", offset, length) +
                "\u0000";
            var ex = Encoding.UTF8.GetBytes(e);

            Save(ex, "__m2j.ex");
            CollectionAssert.AreEqual(ex, a);
        }
Exemple #3
0
        public void WriteManagedToJava()
        {
            var v = new TypeNameMapGenerator(SupportDeclarations.GetTestTypeDefinitions(), logMessage: Console.WriteLine);
            var o = new MemoryStream();

            v.WriteManagedToJava(o);
            var a = ToArray(o);

            Save(a, "__m2j");
            var length = 259;
            var offset = 169;
            var e      =
                "version=1\u0000" +
                "entry-count=19\u0000" +
                "entry-len=" + length + "\u0000" +
                "value-offset=" + offset + "\u0000" +
                GetM2JEntryLine(typeof(AbstractClass), "my/AbstractClass", offset, length) +
                GetM2JEntryLine(typeof(AbstractClassInvoker), "my/AbstractClass", offset, length) +
                GetM2JEntryLine(typeof(ActivityName), "activity/Name", offset, length) +
                GetM2JEntryLine(typeof(ApplicationName), "application/Name", offset, length) +
                GetM2JEntryLine(typeof(DefaultName.A.B), "md5fef72cac46d04ae5bdc90af5bb6221ad/DefaultName_A_B", offset, length) +
                GetM2JEntryLine(typeof(DefaultName.A), "md5fef72cac46d04ae5bdc90af5bb6221ad/DefaultName_A", offset, length) +
                GetM2JEntryLine(typeof(DefaultName.C.D), "md5fef72cac46d04ae5bdc90af5bb6221ad/DefaultName_C_D", offset, length) +
                GetM2JEntryLine(typeof(DefaultName), "md5fef72cac46d04ae5bdc90af5bb6221ad/DefaultName", offset, length) +
                GetM2JEntryLine(typeof(ExampleOuterClass.ExampleInnerClass), "md5fef72cac46d04ae5bdc90af5bb6221ad/ExampleOuterClass$ExampleOuterClass_ExampleInnerClass", offset, length) +
                GetM2JEntryLine(typeof(ExampleOuterClass), "md5fef72cac46d04ae5bdc90af5bb6221ad/ExampleOuterClass", offset, length) +
                GetM2JEntryLine(typeof(InstrumentationName), "instrumentation/Name", offset, length) +
                GetM2JEntryLine(typeof(NonStaticOuterClass.NonStaticInnerClass), "register/NonStaticOuterClass$NonStaticInnerClass", offset, length) +
                GetM2JEntryLine(typeof(NonStaticOuterClass), "register/NonStaticOuterClass", offset, length) +
                GetM2JEntryLine(typeof(ProviderName), "provider/Name", offset, length) +
                GetM2JEntryLine(typeof(ReceiverName), "receiver/Name", offset, length) +
                GetM2JEntryLine(typeof(RegisterName.DefaultNestedName), "register/Name_DefaultNestedName", offset, length) +
                GetM2JEntryLine(typeof(RegisterName.OverrideNestedName), "register/Name$Override", offset, length) +
                GetM2JEntryLine(typeof(RegisterName), "register/Name", offset, length) +
                GetM2JEntryLine(typeof(ServiceName), "service/Name", offset, length) +
                "\u0000";
            var ex = Encoding.UTF8.GetBytes(e);

            Save(ex, "__m2j.ex");
            CollectionAssert.AreEqual(ex, a);
        }
Exemple #4
0
        public void WriteJavaToManaged()
        {
            var v = new TypeNameMapGenerator(SupportDeclarations.GetTestTypeDefinitions(), logger: Diagnostic.CreateConsoleLogger());
            var o = new MemoryStream();

            v.WriteJavaToManaged(o);
            var a = ToArray(o);

            Save(a, "__j2m");
            var length = 204;
            var offset = 90;
            var e      =
                "version=1\u0000" +
                "entry-count=18\u0000" +
                "entry-len=" + length + "\u0000" +
                "value-offset=" + offset + "\u0000" +
                GetJ2MEntryLine(typeof(ActivityName), "activity/Name", offset, length) +
                GetJ2MEntryLine(typeof(ApplicationName), "application/Name", offset, length) +
                GetJ2MEntryLine(typeof(InstrumentationName), "instrumentation/Name", offset, length) +
                GetJ2MEntryLine(typeof(DefaultName), "md5f43cdfade412ae71b21bb70a5c2841ab/DefaultName", offset, length) +
                GetJ2MEntryLine(typeof(DefaultName.A), "md5f43cdfade412ae71b21bb70a5c2841ab/DefaultName_A", offset, length) +
                GetJ2MEntryLine(typeof(DefaultName.A.B), "md5f43cdfade412ae71b21bb70a5c2841ab/DefaultName_A_B", offset, length) +
                GetJ2MEntryLine(typeof(DefaultName.C.D), "md5f43cdfade412ae71b21bb70a5c2841ab/DefaultName_C_D", offset, length) +
                GetJ2MEntryLine(typeof(ExampleOuterClass), "md5f43cdfade412ae71b21bb70a5c2841ab/ExampleOuterClass", offset, length) +
                GetJ2MEntryLine(typeof(ExampleOuterClass.ExampleInnerClass), "md5f43cdfade412ae71b21bb70a5c2841ab/ExampleOuterClass$ExampleOuterClass_ExampleInnerClass", offset, length) +
                GetJ2MEntryLine(typeof(AbstractClass), "my/AbstractClass", offset, length) +
                GetJ2MEntryLine(typeof(ProviderName), "provider/Name", offset, length) +
                GetJ2MEntryLine(typeof(ReceiverName), "receiver/Name", offset, length) +
                GetJ2MEntryLine(typeof(RegisterName), "register/Name", offset, length) +
                GetJ2MEntryLine(typeof(RegisterName.OverrideNestedName), "register/Name$Override", offset, length) +
                GetJ2MEntryLine(typeof(RegisterName.DefaultNestedName), "register/Name_DefaultNestedName", offset, length) +
                GetJ2MEntryLine(typeof(NonStaticOuterClass), "register/NonStaticOuterClass", offset, length) +
                GetJ2MEntryLine(typeof(NonStaticOuterClass.NonStaticInnerClass), "register/NonStaticOuterClass$NonStaticInnerClass", offset, length) +
                GetJ2MEntryLine(typeof(ServiceName), "service/Name", offset, length) +
                "\u0000";
            var ex = Encoding.UTF8.GetBytes(e);

            Save(ex, "__j2m.ex");
            CollectionAssert.AreEqual(ex, a);
        }