Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var consoleOutputManager = new ConsoleOutputManager();
            var timeProvider = new TimeProvider();
            var messageRepository = new MessagesRepository();
            var followingRepository = new FollowingRepository();

            consoleOutputManager.WriteLine("Welcome to RetroTwitter");
            consoleOutputManager.WriteLine();
            ShowInstructions(consoleOutputManager);
            consoleOutputManager.WriteLine();

            consoleOutputManager.WriteLine("What do you want to do today?");

            var commandFactory = new CommandCreatorsFactory(consoleOutputManager, timeProvider, messageRepository, followingRepository);
            while (true)
            {
                consoleOutputManager.Write(">");
                var commandString = consoleOutputManager.ReadLine();
                var command = commandFactory.ParseStringToCommand(commandString);
                if (command != null)
                {
                    command.Execute();
                }
                else
                {
                    consoleOutputManager.WriteLine("Sorry, I didn't catch that.");
                }
            }

            consoleOutputManager.WriteLine("RetroTwitter is terminating and all the collected data are being destroyed.");

            // ReSharper disable once FunctionNeverReturns
        }
        public void EmptyUsage()
        {
            // arrange
            ConsoleOutputManager manager = new ConsoleOutputManager();
            List <NetworkData>   data    = new List <NetworkData>()
            {
            };
            var        stream = new MemoryStream();
            TextWriter writer = new StreamWriter(stream);

            // act
            manager.Write(writer, data);
            writer.Flush();
            string actual = Encoding.UTF8.GetString(stream.ToArray());

            // assert
            StringAssert.AreEqualIgnoringCase("", actual);
        }
        public void BasicUsage()
        {
            // arrange
            ConsoleOutputManager manager = new ConsoleOutputManager();
            List <NetworkData>   data    = new List <NetworkData>()
            {
                new NetworkData()
                {
                    Name = "NIC1",
                    IP   = "1.2.3.4"
                }
            };
            var        stream = new MemoryStream();
            TextWriter writer = new StreamWriter(stream);

            // act
            manager.Write(writer, data);
            writer.Flush();
            string actual = Encoding.UTF8.GetString(stream.ToArray());

            // assert
            StringAssert.AreEqualIgnoringCase("NIC: NIC1 (1.2.3.4)\r\n", actual);
        }