Exemplo n.º 1
0
        public List <Tax> LoadFromTxt()
        {
            List <Tax>   results = new List <Tax>();
            StreamReader sr      = null;

            try
            {
                sr = new StreamReader(FILENAME);
                sr.ReadLine();
                string row = "";
                while ((row = sr.ReadLine()) != null)
                {
                    Tax c = TaxMapper.StringToTax(row);
                    results.Add(c);
                }
            }
            catch (FileNotFoundException fileNotFound)
            {
                Console.WriteLine(fileNotFound.FileName + " was not found");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
            }
            return(results);
        }
Exemplo n.º 2
0
        public void ToTaxMapperTest(string row, string stateAbbreviation, string stateName, decimal taxRate)
        {
            Tax tax = new Tax();

            tax.StateAbbreviation = stateAbbreviation;
            tax.StateName         = stateName;
            tax.TaxRate           = taxRate;

            Tax result = TaxMapper.StringToTax(row);

            Assert.AreEqual(result.StateAbbreviation, tax.StateAbbreviation);
            Assert.AreEqual(result.StateName, tax.StateName);
            Assert.AreEqual(result.TaxRate, tax.TaxRate);
        }
        public static List <Tax> GetTaxes()
        {
            List <Tax> taxes = new List <Tax>();

            string[] rows = File.ReadAllLines(@"C:\Users\nthny\Documents\Bitbucket\anthony-dahl-individual-work\MasteryFlooring\MasteryFlooring.Data\Taxes.txt");
            foreach (string row in rows)
            {
                if (row != null)
                {
                    taxes.Add(TaxMapper.StringToTax(row));
                }
            }
            return(taxes);
        }