Beispiel #1
0
        public void WriteCtor()
        {
            var @class = new TestClass("java.lang.Object", "com.mypackage.foo");
            var ctor   = new TestCtor(@class, "Object");

            generator.Context.ContextTypes.Push(@class);
            generator.WriteConstructor(ctor, string.Empty, true, @class);
            generator.Context.ContextTypes.Pop();

            Assert.AreEqual(GetTargetedExpected(nameof(WriteCtor)), writer.ToString().NormalizeLineEndings());
        }
Beispiel #2
0
        public static TestCtor CreateConstructor(GenBase parent, string methodName, CodeGenerationOptions options, params Parameter [] parameters)
        {
            var ctor = new TestCtor(parent, methodName);

            foreach (var p in parameters)
            {
                ctor.Parameters.Add(p);
            }

            ctor.Validate(options, null, new CodeGeneratorContext());

            return(ctor);
        }
Beispiel #3
0
        public void WriteCtorWithStringOverload()
        {
            var @class = new TestClass("java.lang.Object", "com.mypackage.foo");
            var ctor   = new TestCtor(@class, "Object");

            ctor.Parameters.Add(new Parameter("mystring", "java.lang.CharSequence", "Java.Lang.ICharSequence", false));
            ctor.Validate(options, null, new CodeGeneratorContext());

            generator.Context.ContextTypes.Push(@class);
            generator.WriteConstructor(ctor, string.Empty, true, @class);
            generator.Context.ContextTypes.Pop();

            Assert.AreEqual(GetTargetedExpected(nameof(WriteCtorWithStringOverload)), writer.ToString().NormalizeLineEndings());
        }
Beispiel #4
0
        public void WriteCtorDeprecated()
        {
            var @class = new TestClass("java.lang.Object", "com.mypackage.foo");
            var ctor   = new TestCtor(@class, "Object")
                         .SetDeprecated("This constructor is obsolete")
                         .SetCustomAttributes("[MyAttribute]")
                         .SetAnnotation("[global::Android.Runtime.IntDefinition (null, JniField = \"xamarin/test/SomeObject.SOME_VALUE\")]");

            generator.Context.ContextTypes.Push(@class);
            generator.WriteConstructor(ctor, string.Empty, true, @class);
            generator.Context.ContextTypes.Pop();

            Assert.AreEqual(GetTargetedExpected(nameof(WriteCtorDeprecated)), writer.ToString().NormalizeLineEndings());
        }