Exemple #1
0
        public void Test01_Exception_When_Incorrect_File()
        {
            #region Arrange
            Carrera          carrera;
            string           ruta   = $"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\\carrera.xmll";
            GestorDeArchivos gestor = new GestorDeArchivos(ruta);

            #endregion
            #region Act
            carrera = gestor.LeerXML();
            #endregion
        }
        /// <summary>
        /// EventHandler form closing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmCarrera_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Alumno:serializar carrera
            string           path   = $"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\\carrera.xml";
            GestorDeArchivos gestor = new GestorDeArchivos(path);

            this.DialogResult = DialogResult.OK; //Establezco el resultado en OK para finalizar el primer FORM
            try {
                if (!(this.thread is null) && this.thread.IsAlive)
                {
                    this.thread.Abort();
                }
                this.carrera.InformarAvance  -= AvanzarAuto;
                this.carrera.InformarLlegada -= ImprimirMensaje;
                gestor.Guardar(this.carrera);
            } catch (Exception exe) {
                MessageBox.Show(exe.Message);
            }
        }
Exemple #3
0
        public void Test02_SerializeXML()
        {
            #region Arrange

            Carrera carrera = new Carrera(15);
            AutoF1  auto    = new AutoF1("Ferrari", 4, 4);
            carrera += auto;
            Carrera          carrera2;
            string           ruta   = $"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\\carreraTest.xml";
            GestorDeArchivos gestor = new GestorDeArchivos(ruta);

            #endregion

            #region Act
            gestor.Guardar(carrera);
            carrera2 = gestor.LeerXML();
            #endregion

            #region Assert
            Assert.AreEqual(carrera.Autos.Count, carrera2.Autos.Count);
            #endregion
        }