コード例 #1
0
        private string Write(Stock stock)
        {
            StringBuilder sb     = new StringBuilder();
            IStockWriter  writer = new TextStockWriter(line => sb.AppendLine(line));

            writer.Write(stock);
            return(sb.ToString());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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());
        }