Exemple #1
0
 void FtData(FormatTxt txt, float data)
 {
     if (txt)
     {
         txt.Data(data);
     }
 }
Exemple #2
0
        public void AddToFileTest()
        {
            Alumno al_test = new Alumno("H", 1, 1, "1");

            FormatTxt formattxt = new FormatTxt();

            formattxt.AddToFile(al_test);

            string[] readed    = this.ReadFromTxt();
            string   linefinal = "";

            foreach (string line in readed)
            {
                linefinal = line;
            }
            Assert.IsTrue(al_test.Equals(FromTxtToAl(linefinal)));

            throw new NotImplementedException();
        }
        public void AddAlumnoTxtTest(int id, string nombre, string apellido, string dni)
        {
            string    path = "C:/Users/Daniel Madrigal/Downloads/Fichero/FicheroTests1/bin/Debug/Registro.txt";
            Guid      guid = Guid.NewGuid();
            Alumno    al   = new Alumno(guid, id, nombre, apellido, dni);
            FormatTxt ft   = new FormatTxt("txt");

            ft.Add(al);
            Assert.IsTrue(File.Exists(path));


            Alumno        registrado;
            List <Alumno> Alumnos    = new List <Alumno>();
            bool          Encontrado = false;

            using (FileStream fl = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader sw = new StreamReader(fl))
                {
                    string line;
                    while ((line = sw.ReadLine()) != null)
                    {
                        string[] lines = line.Split(',');
                        registrado = new Alumno(guid, Convert.ToInt32(lines[0]), lines[1], lines[2], lines[3]);
                        Alumnos.Add(registrado);
                    }
                }
            }

            foreach (var i in Alumnos)
            {
                if (al.Equals(i))
                {
                    Encontrado = true;
                }
            }
            Assert.IsTrue(Encontrado);
        }