Exemplo n.º 1
0
        public void ClassInterfaceArrayElementExplicitConversions()
        {
            AssertExplicitConvert(new SealedClass[0], default(IInterface[]), ExpectedConversionResult.CompileError);
            var ic = new ImplementingClass[0];

            AssertExplicitConvert(ic, (IInterface[])ic, ExpectedConversionResult.Succeed);
            var isc = new ImplementingSealedClass[0];

            AssertExplicitConvert(isc, (IInterface[])isc, ExpectedConversionResult.Succeed);
            AssertExplicitConvert(new Struct[0], default(IInterface[]), ExpectedConversionResult.CompileError);
            AssertExplicitConvert(new SealedClass[0], default(UnrelatedNonInterface[]), ExpectedConversionResult.CompileError);
            AssertExplicitConvert(new UnsealedClass[0], default(UnrelatedNonInterface[]), ExpectedConversionResult.CompileError);
            AssertExplicitConvert(new Struct[0], default(UnrelatedNonInterface[]), ExpectedConversionResult.CompileError);
        }
Exemplo n.º 2
0
        public void InterfaceClassExplicitConversion()
        {
            IInterface iif = new ImplementingClass();

            AssertExplicitConvert(iif, default(SealedClass), ExpectedConversionResult.CompileError);
            AssertExplicitConvert(iif, default(UnsealedClass), ExpectedConversionResult.CompileError);
            ImplementingClass ic = new ImplementingClass();

            AssertExplicitConvert((IInterface)ic, ic, ExpectedConversionResult.Succeed);
            ImplementingSealedClass isc = new ImplementingSealedClass();

            AssertExplicitConvert((IInterface)isc, isc, ExpectedConversionResult.Succeed);
            AssertExplicitConvert(iif, default(Struct), ExpectedConversionResult.CompileError);
            AssertExplicitConvert((IInterface) new ImplementingStruct(), new ImplementingStruct(), ExpectedConversionResult.Succeed);
        }
Exemplo n.º 3
0
        public void ClassInterfaceExplicitConversion()
        {
            AssertExplicitConvert(new SealedClass(), default(IInterface), ExpectedConversionResult.CompileError);
            AssertExplicitConvert(new UnsealedClass(), default(IInterface), ExpectedConversionResult.RuntimeError);
            ImplementingClass ic = new ImplementingClass();

            AssertExplicitConvert(ic, (IInterface)ic, ExpectedConversionResult.Succeed);
            ImplementingSealedClass isc = new ImplementingSealedClass();

            AssertExplicitConvert(isc, (IInterface)isc, ExpectedConversionResult.Succeed);
            AssertExplicitConvert(new Struct(), default(IInterface), ExpectedConversionResult.CompileError);
            AssertExplicitConvert(new ImplementingStruct(), new ImplementingStruct(), ExpectedConversionResult.Succeed);
            AssertExplicitConvert(new SealedClass(), default(UnrelatedNonInterface), ExpectedConversionResult.CompileError);
            AssertExplicitConvert(new UnsealedClass(), default(UnrelatedNonInterface), ExpectedConversionResult.CompileError);
            AssertExplicitConvert(new Struct(), default(UnrelatedNonInterface), ExpectedConversionResult.CompileError);
        }