private Stock Read(string text)
        {
            using var streamReader = new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(text)));
            TextStockReader reader = new TextStockReader(() => streamReader.ReadLine());

            return(reader.Read());
        }
Пример #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());
        }