public void _01_Cotacoes_Historicas_Por_Papel_Mercado()
        {
            var motor = new FileHelpers.FileHelperEngine <CodingCraftEX06HangFire.ViewModels.Bovespa.Detail>();

            var registro = motor.ReadString(linha_01).First();

            Assert.AreEqual(01, registro.TipReg);
            Assert.AreEqual(new DateTime(2017, 1, 2), registro.DataDoPregao);
            Assert.AreEqual("02", registro.CodBdi);
            Assert.AreEqual("AALR3       ", registro.CodNeg);
            Assert.AreEqual(010, registro.TpMerc);
            Assert.AreEqual("ALLIAR      ", registro.NomRes);
            Assert.AreEqual("ON      NM", registro.Especi);
            Assert.AreEqual("   ", registro.PrazoT);
            Assert.AreEqual("R$  ", registro.ModRef);
            Assert.AreEqual(14.62M, registro.PreAbe);
            Assert.AreEqual(14.88M, registro.PreMax);
            Assert.AreEqual(14.40M, registro.PreMin);
            Assert.AreEqual(14.58M, registro.PreMed);
            Assert.AreEqual(14.60M, registro.PreUlt);
            Assert.AreEqual(14.60M, registro.PreOfc);
            Assert.AreEqual(14.73M, registro.PreOfv);
            Assert.AreEqual(00087, registro.TotNeg);
            Assert.AreEqual(000000000000035900, registro.QuatTot);
            Assert.AreEqual(0000000000523505.00M, registro.VolTot);
            Assert.AreEqual(0M, registro.PreExe);
            Assert.AreEqual(0, registro.IndOpc);
            Assert.AreEqual(new DateTime(9999, 12, 31), registro.DataVen);
            Assert.AreEqual(1, registro.FatCot);
            Assert.AreEqual(0, registro.PtoExe);
            Assert.AreEqual("BRAALRACNOR6", registro.CodIsi);
            Assert.AreEqual(100, registro.DisMes);
        }
        public int FileHelpersBenchmark()
        {
            var totalLength = 0;

            var engine = new FileHelpers.FileHelperEngine <Record>();

            var records    = engine.ReadString(this.str);
            var numRecords = records.Length;

            for (var recordNum = 0; recordNum < numRecords; recordNum++)
            {
                var record = records[recordNum];
                totalLength += record.Value0.Length;
                totalLength += record.Value1.Length;
                totalLength += record.Value2.Length;
                totalLength += record.Value3.Length;
                totalLength += record.Value4.Length;
                totalLength += record.Value5.Length;
                totalLength += record.Value6.Length;
                totalLength += record.Value7.Length;
                totalLength += record.Value8.Length;
                totalLength += record.Value9.Length;
            }

            return(totalLength);
        }
Example #3
0
        public static Respondent[] LoadRespondentsFromFile()
        {
            const string csvPath = @"sporgeskema3.csv";

            var reader = new FileHelpers.FileHelperEngine<Respondent> { Options = { IgnoreFirstLines = 2 } };

            var respondents = reader.ReadString(ReadFromAssemblyResource(Assembly.GetExecutingAssembly(), csvPath));
            return respondents;
        }
        public void _00_Header()
        {
            var motor    = new FileHelpers.FileHelperEngine <CodingCraftEX06HangFire.ViewModels.Bovespa.Header>();
            var registro = motor.ReadString(linha_00).First();

            Assert.AreEqual(0, registro.TipoDeRegistro);
            Assert.AreEqual("COTAHIST.2017", registro.NomeDoArquivo);
            Assert.AreEqual("BOVESPA ", registro.CodigoDaOrigem);
            Assert.AreEqual(new DateTime(2017, 9, 1), registro.DataDaGeracaoDoArquivo);
            Assert.AreEqual("".PadLeft(214), registro.Reserva);
        }
        public void _99_Trailer()
        {
            var motor = new FileHelpers.FileHelperEngine <CodingCraftEX06HangFire.ViewModels.Bovespa.Trailer>();

            var registro = motor.ReadString(linha_99).First();

            Assert.AreEqual(99, registro.TipoDeRegistro);
            Assert.AreEqual("COTAHIST.2017", registro.NomeDoArquivo);
            Assert.AreEqual("BOVESPA ", registro.CodigoDaOrigem);
            Assert.AreEqual(new DateTime(2017, 9, 1), registro.DataDaGeracaoDoArquivo);
            Assert.AreEqual(00000323986, registro.TotalDeRegistros);
            Assert.AreEqual("".PadRight(203), registro.Reserva);
        }
Example #6
0
        public int FileHelpers()
        {
            var totalLength = 0;

            if (Columns == 10)
            {
                var engine = new FileHelpers.FileHelperEngine <Record10>();

                var records    = engine.ReadString(StringFile);
                var numRecords = records.Length;
                for (var recordNum = 0; recordNum < numRecords; recordNum++)
                {
                    var record = records[recordNum];
                    totalLength += record.column1.Length;
                    totalLength += record.column2.Length;
                    totalLength += record.column3.Length;
                    totalLength += record.column4.Length;
                    totalLength += record.column5.Length;
                    totalLength += record.column6.Length;
                    totalLength += record.column7.Length;
                    totalLength += record.column8.Length;
                    totalLength += record.column9.Length;
                    totalLength += record.column10.Length;
                }

                return(totalLength);
            }
            else
            {
                var engine = new FileHelpers.FileHelperEngine <Record50>();

                var records    = engine.ReadString(StringFile);
                var numRecords = records.Length;
                for (var recordNum = 0; recordNum < numRecords; recordNum++)
                {
                    var record = records[recordNum];
                    totalLength += record.column1.Length;
                    totalLength += record.column2.Length;
                    totalLength += record.column3.Length;
                    totalLength += record.column4.Length;
                    totalLength += record.column5.Length;
                    totalLength += record.column6.Length;
                    totalLength += record.column7.Length;
                    totalLength += record.column8.Length;
                    totalLength += record.column9.Length;
                    totalLength += record.column10.Length;
                    totalLength += record.column11.Length;
                    totalLength += record.column12.Length;
                    totalLength += record.column13.Length;
                    totalLength += record.column14.Length;
                    totalLength += record.column15.Length;
                    totalLength += record.column16.Length;
                    totalLength += record.column17.Length;
                    totalLength += record.column18.Length;
                    totalLength += record.column19.Length;
                    totalLength += record.column20.Length;
                    totalLength += record.column21.Length;
                    totalLength += record.column22.Length;
                    totalLength += record.column23.Length;
                    totalLength += record.column24.Length;
                    totalLength += record.column25.Length;
                    totalLength += record.column26.Length;
                    totalLength += record.column27.Length;
                    totalLength += record.column28.Length;
                    totalLength += record.column29.Length;
                    totalLength += record.column30.Length;
                    totalLength += record.column31.Length;
                    totalLength += record.column32.Length;
                    totalLength += record.column33.Length;
                    totalLength += record.column34.Length;
                    totalLength += record.column35.Length;
                    totalLength += record.column36.Length;
                    totalLength += record.column37.Length;
                    totalLength += record.column38.Length;
                    totalLength += record.column39.Length;
                    totalLength += record.column40.Length;
                    totalLength += record.column41.Length;
                    totalLength += record.column42.Length;
                    totalLength += record.column43.Length;
                    totalLength += record.column44.Length;
                    totalLength += record.column45.Length;
                    totalLength += record.column46.Length;
                    totalLength += record.column47.Length;
                    totalLength += record.column48.Length;
                    totalLength += record.column49.Length;
                    totalLength += record.column50.Length;
                }

                return(totalLength);
            }
        }