Beispiel #1
0
        public static int Main()
        {
            DisplayIntroduction();

            IReporter reporter = new CmdReporter();
            ILogger logger = new FileLogger();

            Simulator simulator = new Simulator(reporter, logger);

            while(true)
            {
                string input = Console.ReadLine();
                bool exit = simulator.ProcessInstruction(input);
                if (exit)
                    return 0;
            }
        }
        public void TestSimulatorResult()
        {
            using (var sw = new StringWriter())
            {
                Console.SetOut(sw);

                simulator = new Simulator(_reporter, _logger);
                SetupInputs(inputs);
                foreach (string input in inputs)
                {
                    simulator.ProcessInstruction(input);
                }

                var result = sw.ToString();
                //"4,4,EAST\n4,4,NORTH\n4,4,EAST\n0,1,NORTH\n"
                Assert.IsTrue(string.Equals(result, "0,2,NORTH\n1,2,EAST\n1,2,NORTH\n4,4,EAST\n", StringComparison.OrdinalIgnoreCase));
            }
        }