public static void LoadCsv(this ITillContext till, IFileSystem _fileSystem, string filePath)
        {
            using (StreamReader inputReader = _fileSystem.File.OpenText(filePath))
            {
                var     i     = 0;
                decimal price = 0;
                while (!inputReader.EndOfStream)
                {
                    var newline = inputReader.ReadLine();
                    var ln      = newline.Split(',');
                    if (ln.GetLength(0) != 2)
                    {
                        throw new Exception($"Wrong line format expected <name>,<price> but get'{newline}' ");
                    }
                    ;

                    if (!Decimal.TryParse(ln[1], out price))
                    {
                        throw new Exception($"Wrong price format expected decimal but get'{ln[1]}' ");
                    }
                    ;

                    var fruit = new Fruit
                    {
                        Id    = i++,
                        Name  = ln[0],
                        Price = price
                    };
                    till.Fruits.Add(fruit);
                }
            }
        }
Ejemplo n.º 2
0
 public TillBL(ITillContext tillContext)
 {
     this.TillContext = tillContext;
 }
Ejemplo n.º 3
0
 public ConsoleInterface(ITillContext tillContext, ITillBL tillBL)
 {
     this.TillContext = tillContext;
     this.TillBL      = tillBL;
 }
Ejemplo n.º 4
0
 public void InitializeTest()
 {
     tillContextUT = new TillContext();
 }