Ejemplo n.º 1
0
        public void WhenNestedAbstractClassSyncMethod()
        {
            var types = VerthandiTest.Generate(typeof(B.JitCClassB <, ,>));

            Assert.Single(types);
            var t = types.Values.First();

            Assert.Contains(t.Attributes, i => i.AttributeType.FullName == typeof(DefaultImplementAttribute).FullName && i.ConstructorArguments.First().Value == typeof(B.JitCClassB <, ,>));
            var instance = Activator.CreateInstance(t.RealType.MakeGenericType(this.GetType(), typeof(long), typeof(int))) as B.JitCClassB <DefaultImplementNotationGeneratorTest, long, int>;
            var r        = instance.A();

            Assert.Null(r.Item1);
            Assert.Equal(0L, r.Item2);
            Assert.Equal(0, r.Item3);

            types = VerthandiTest.Generate(typeof(B.A.JitCClassA <, ,>));
            Assert.Single(types);
            t = types.Values.First();
            Assert.Contains(t.Attributes, i => i.AttributeType.FullName == typeof(DefaultImplementAttribute).FullName && i.ConstructorArguments.First().Value == typeof(B.A.JitCClassA <, ,>));
            var instance1 = Activator.CreateInstance(t.RealType.MakeGenericType(this.GetType(), typeof(long), typeof(int))) as B.A.JitCClassA <DefaultImplementNotationGeneratorTest, long, int>;

            r = instance1.A();
            Assert.Null(r.Item1);
            Assert.Equal(0L, r.Item2);
            Assert.Equal(0, r.Item3);
        }
Ejemplo n.º 2
0
        public async Task WhenAbstractClassAndSomeMethods()
        {
            var types = VerthandiTest.Generate(typeof(JitCClass));

            Assert.Single(types);
            var t = types.Values.First();

            Assert.Contains(t.Attributes, i => i.AttributeType.FullName == typeof(DefaultImplementAttribute).FullName && i.ConstructorArguments.First().Value == typeof(JitCClass));
            var instance = Activator.CreateInstance(t.RealType) as JitCClass;

            Assert.Equal(0, instance.AddOne(33));
            instance.AddVoid();
            await instance.AddTask(66);

            Assert.Equal(0, await instance.AddVTask(44));
            Assert.Equal(0, await instance.AddValueTask(11));
            Assert.Null(await instance.AddValueTask(this));
            Assert.Null(await instance.AddValueTask(new A(), instance));
            Assert.Equal(0, instance.PA);
            instance.PD = 55;
            Assert.Null(instance[3, ""]);
            var c = instance;

            Assert.Null(instance.AddValue1(new A(), ref c));
            Assert.Null(instance.AddValue2(new A(), in c));
            Assert.Null(instance.AddValue3(new A(), out c));
            Assert.Equal(3, instance.A());
            Assert.Equal(3, instance.B());
        }
Ejemplo n.º 3
0
        public void WhenOutGenericInterfaceSyncMethod()
        {
            var types = VerthandiTest.Generate(typeof(IJitD <>));

            Assert.Single(types);
            var t = types.Values.First();

            Assert.Contains(t.Attributes, i => i.AttributeType.FullName == typeof(DefaultImplementAttribute).FullName && i.ConstructorArguments.First().Value == typeof(IJitD <>));
            var instance = Activator.CreateInstance(t.RealType.MakeGenericType(this.GetType())) as IJitD <DefaultImplementNotationGeneratorTest>;

            Assert.Null(instance.A());
        }
Ejemplo n.º 4
0
        public void WhenInGenericInterfaceSyncMethod()
        {
            var types = VerthandiTest.Generate(typeof(IJitDIn <, ,>));

            Assert.Single(types);
            var t = types.Values.First();

            Assert.Contains(t.Attributes, i => i.AttributeType.FullName == typeof(DefaultImplementAttribute).FullName && i.ConstructorArguments.First().Value == typeof(IJitDIn <, ,>));
            var instance = Activator.CreateInstance(t.RealType.MakeGenericType(typeof(AopSourceGenerator), typeof(int), typeof(int))) as IJitDIn <AopSourceGenerator, int, int>;

            Assert.Null(instance.A());
        }
Ejemplo n.º 5
0
        public void WhenInheritInterface()
        {
            var types = VerthandiTest.Generate(typeof(IJitD));

            Assert.Single(types);
            var t = types.Values.First();

            Assert.Contains(t.Attributes, i => i.AttributeType.FullName == typeof(DefaultImplementAttribute).FullName && i.ConstructorArguments.First().Value == typeof(IJitD));
            var instance = Activator.CreateInstance(t.RealType) as IJitD;

            Assert.Equal(0, instance.GiveFive());
        }