Example #1
0
        static void Main(string[] args)
        {
            try
            {
                MiOtraClase aux = new MiOtraClase();
                aux.MiMetodoInstancia();
            }


            catch (MiException e)
            {
                //e.	MiException serĂ¡ capturada en el Main,
                // mostrando el mensaje de error que esta almacena por pantalla
                // y los mensajes de todas las excepciones almacenadas en sus innerException.
                Console.WriteLine(e.Message);
                if (!object.ReferenceEquals(e.InnerException, null))
                {
                    Exception ex = e.InnerException;
                    do
                    {
                        Console.WriteLine(ex.Message);
                        ex = ex.InnerException;
                    } while (!object.ReferenceEquals(ex, null));
                }
            }
            Console.ReadKey();
        }
        public void MiOtraClase_MiMetodoInstancia_MiException_Throws()
        {
            //Arrange
            MiOtraClase moc = new MiOtraClase();

            moc.MiMetodoInstancia();

            //Assert es manejado en el ExpectedException
        }
Example #3
0
        static void Main(string[] args)
        {
            MiClase obj = new MiClase("Valor string");

            obj.PropiedadSE = 98;
            Console.WriteLine(obj.PropiedadSL);
            Console.WriteLine(obj.PropiedadLE);

            double a = obj.MetodoConParametros(2, 8);


            obj.MetodoSinRetornoNiParametros();

            MiClaseDerivada mcd = new MiClaseDerivada("valor1", "valor2");

            mcd.OtroMetodo();
            mcd.MetodoSinRetornoNiParametros();


            IMiInterface     miVariable;
            MiClase          miOtraVariable;
            IMiOtraInterface otraOtraVariable;

            miOtraVariable   = obj;
            miOtraVariable   = mcd;
            miVariable       = obj;
            miVariable       = mcd;
            otraOtraVariable = mcd;
            /// otraOtraVariable = obj;


            ClaseIMiembrosRepetidos cmr = new ClaseIMiembrosRepetidos();



            cmr.Metodo();
            ((IMiembrosRepetidos2)cmr).Metodo();



            IMiInterface variableInterface;

            variableInterface = obj;

            Program.Mostrar(obj);
            Program.Mostrar(variableInterface);

            //Program.Mostrar("asdfasd"); //ERROR, no es de tipo IMiInterface


            ClaseConstructorDefecto objClaseConstructorDefecto = new ClaseConstructorDefecto();
            MiOtraClase             miOtraClase = new MiOtraClase();

            miOtraClase.Metodo(objClaseConstructorDefecto);
            objClaseConstructorDefecto = miOtraClase.MetodoRetorno(objClaseConstructorDefecto);

            ClaseGenerica <MiOtraClase> objGenerica = new ClaseGenerica <MiOtraClase>();

            objGenerica.Metodo(new MiOtraClase());



            Console.ReadLine();
        }
        public void MetodoDeInstanciaDeMiOtraClase()
        {
            MiOtraClase miOtraClase = new MiOtraClase();

            miOtraClase.MiMetodoDeInstancia();
        }