public void NullTest()
 {
     using (var reader = new SpreadsheetReader((TextReader)null))
     {
         reader.ReadSpreadsheet();
     }
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var isConsoleInput = args.Length < 1;
            var isConsoleOutput = args.Length < 2;
            try
            {
                var input = isConsoleInput ? Console.OpenStandardInput() : File.Open(args[0], FileMode.Open);
                var output = isConsoleOutput ? Console.OpenStandardOutput() : File.Create(args[1]);
                using (var reader = new SpreadsheetReader(input))
                {
                    Console.WriteLine(isConsoleInput ? Resources.EnterTable : Resources.ReadingTable);
                    var spreadsheet = reader.ReadSpreadsheet();

                    Console.WriteLine(Resources.Processing);
                    var processor = new SpreadsheetProcessor(spreadsheet);
                    var result = processor.Evaluate(new ParallelProcessingStrategy());

                    Console.WriteLine(isConsoleOutput ? Resources.ResultTable : Resources.WritingResult);
                    using (var write = new SpreadsheetWriter(output))
                    {
                        write.WriteSpreedsheat(result);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }

            if (isConsoleOutput)
            {
                Console.Write(Resources.PressAnyKeyForExit);
                Console.ReadKey();
            }
        }
 public void ExсeptionTest()
 {
     var exception = new ExpressionParsingException("error");
     using (var reader = new SpreadsheetReader(new StringReader("12 6"),
                                   s => new SpreadsheeParsertWithExceptionMock(exception)))
     {
         Assert.AreEqual(exception, reader.ReadSpreadsheet().First().Evaluate(null));
     }
 }
 private Core.Spreadsheet ReadSpreadsheet(string size, IExpression[] expressions)
 {
     using (var reader = new SpreadsheetReader(new StringReader(size),
                                               s => new SpreadsheetParserMock(expressions)))
     {
         return reader.ReadSpreadsheet();
     }
 }