public void NullTest() { using (var reader = new SpreadsheetReader((TextReader)null)) { reader.ReadSpreadsheet(); } }
private Core.Spreadsheet ReadSpreadsheet(string size, IExpression[] expressions) { using (var reader = new SpreadsheetReader(new StringReader(size), s => new SpreadsheetParserMock(expressions))) { return(reader.ReadSpreadsheet()); } }
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 static string Evaluate(string data) { using (var reader = new SpreadsheetReader(new StringReader(data))) { using (var ms = new MemoryStream()) { using (var writer = new SpreadsheetWriter(ms)) { writer.WriteSpreedsheat(new SpreadsheetProcessor(reader.ReadSpreadsheet()).Evaluate(new ParallelProcessingStrategy())); return(Encoding.UTF8.GetString(ms.ToArray())); } } } }
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(); } }