예제 #1
0
        public void MetodoInstanciaOtraClase()
        {
            OtraClase objeto = new OtraClase();

            try
            {
                objeto.MiMetodoInstancia();
                Assert.Fail();
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(MiExcepcion));
                Assert.IsInstanceOfType(e.InnerException, typeof(UnaExcepcion));
                Assert.IsInstanceOfType(e.InnerException.InnerException, typeof(DivideByZeroException));
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            string ruta = String.Format("{0}{1}{2}-{3}{4}.txt", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute);

            try
            {
                OtraClase aux = new OtraClase();
                aux.MiMetodoInstancia();  //1)Llama al metodo de la clase OtraClase...
            }
            catch (Exception e)
            { //9) Aca llega DivideByZero + UnaException + MiException
                if (!object.ReferenceEquals(e.InnerException, null))
                {
                    do
                    {
                        Console.WriteLine(e.Message);
                        ArchivoTexto.Guardar(ruta, e.Message);
                        e = e.InnerException;
                    } while (!object.ReferenceEquals(e, null));
                }
            }
            Console.ReadKey();
        }