Пример #1
0
        public void Create_RandomGeneratorIsNull_ThrowsException()
        {
            var ex = Record.Exception(() => mazeFactory.Create(null, MazeType.VerySimpleMaze, 0));

            Assert.NotNull(ex);
            Assert.IsType <ArgumentNullException>(ex);
        }
Пример #2
0
        static async Task Main(string[] args)
        {
            ServiceCollection serviceCollection = ConfigureServices();

            var             services   = serviceCollection.BuildServiceProvider();
            IPonyAPIClient  ponyAPI    = services.GetRequiredService <IPonyAPIClient>();
            IMazeFactory    factory    = services.GetRequiredService <IMazeFactory>();
            IMazePathfinder pathfinder = services.GetRequiredService <IMazePathfinder>();
            IMazeWalker     walker     = services.GetRequiredService <IMazeWalker>();

            Maze maze = null;

            while (maze is null)
            {
                Console.WriteLine("Enter a maze GUID or press enter for a new maze:");
                string input = Console.ReadLine();
                if (input != "")
                {
                    if (Guid.TryParse(input, out Guid mazeId))
                    {
                        maze = await factory.FromID(mazeId);
                    }
                    else
                    {
                        Console.WriteLine("Could not parse mazeId");
                    }
                }
                else
                {
                    maze = await factory.Create();

                    Console.WriteLine($"Maze ID {maze.MazeId} created.");
                }
            }
            Console.WriteLine(await ponyAPI.GetVisualMaze(maze.MazeId));

            Path ponyPath = pathfinder.Solve(maze);

            Console.WriteLine("Here's the ideal path of the pony, let's see it in action:");
            Console.WriteLine(ponyPath);
            await walker.Walk(ponyPath);

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();

            services.Dispose();
        }