private string Write(Stock stock) { StringBuilder sb = new StringBuilder(); IStockWriter writer = new TextStockWriter(line => sb.AppendLine(line)); writer.Write(stock); return(sb.ToString()); }
private static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; IStockReader reader = new TextStockReader(() => System.Console.ReadLine()); IStockWriter writer = new TextStockWriter(line => System.Console.WriteLine(line)); Stock stock = reader.Read(); writer.Write(stock); }
public void Example1() { using var inputReader = new StreamReader(GetResourceStream($"{ResourceLocation}.Example1_in.txt")); IStockReader reader = new TextStockReader(() => inputReader.ReadLine()); StringBuilder output = new StringBuilder(); IStockWriter writer = new TextStockWriter(line => { output.AppendLine(line); Output.WriteLine(line); }); Stock stock = reader.Read(); writer.Write(stock); string expected = GetResourceText($"{ResourceLocation}.Example1_out.txt"); Assert.Equal(expected, output.ToString()); }