public void CleanTest() { DocumentsManager docManager = new DocumentsManager(TipoFichero.TXT); File.Delete(docManager.GetPath()); docManager.tipo = TipoFichero.JSON; File.Delete(docManager.GetPath()); docManager.tipo = TipoFichero.XML; File.Delete(docManager.GetPath()); }
public void TestInit() { _log.Info("Inicialiazamos Tests"); _log.Debug("Limpiamos de ficheros existentes"); DocumentsManager docMan = new DocumentsManager(TipoFichero.JSON); String filename = docMan.GetPath(); if (File.Exists(filename)) { File.Delete(filename); } _log.Debug("Obtenemos el alumno DAO con el formato actual."); iAlumnoDao = new AlumnoDao <Alumno>(DAOFactory <Alumno> .getFormat()); }
public void InitTest() { DocumentsManager docManager = new DocumentsManager(TipoFichero.TXT); if (File.Exists(docManager.GetPath())) { File.Delete(docManager.GetPath()); } docManager.tipo = TipoFichero.JSON; if (File.Exists(docManager.GetPath())) { File.Delete(docManager.GetPath()); } docManager.tipo = TipoFichero.XML; if (File.Exists(docManager.GetPath())) { File.Delete(docManager.GetPath()); } }
public T Insert(T entity) { try { Log.Info("Inicio XML " + System.Reflection.MethodBase.GetCurrentMethod().Name); _log.Info("Inicio XML " + System.Reflection.MethodBase.GetCurrentMethod().Name); List <T> entityList = SelectAll(); XmlSerializer xSeriz = new XmlSerializer(typeof(List <Alumno>)); if (entityList == null) { entityList = new List <T>(); } using (FileStream fs1 = new FileStream(docManager.GetPath(), FileMode.Create)) { entityList.Add(entity); xSeriz.Serialize(fs1, entityList); } return(Select(entity.Guid)); } catch (ArgumentNullException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (PathTooLongException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (DirectoryNotFoundException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (UnauthorizedAccessException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (NotSupportedException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (SecurityException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (IOException ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (Exception ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } finally { _log.Info("Fin de XML " + System.Reflection.MethodBase.GetCurrentMethod().Name); } }