public void NoFailWhenNotFoundWhenConstructor()
 {
     // ReSharper disable once ObjectCreationAsStatement
     // The result not neaded, only that does not fails
     Assert.DoesNotThrow(() =>
                         new CharGameMapReader(FileFromTestsReader.GetFile("CharGameMapReaderFailWhenNotFoundTest.txt")));
 }
예제 #2
0
        public void CorrectPlayerSet()
        {
            var game = new Game(
                new CharGameMapReader(FileFromTestsReader.GetFile("GameBoundedMapTest.txt")));

            game.MapChanged += (sender, args) =>
            {
                Assert.AreEqual(args.Player.X, 1);
                Assert.AreEqual(args.Player.Y, 1);
            };
            game.Start();
        }
예제 #3
0
        public void CorrectPlayerNoMove()
        {
            var game = new Game(
                new CharGameMapReader(FileFromTestsReader.GetFile("GameBoundedMapTest.txt")));

            game.MapChanged += (sender, args) =>
            {
                Assert.AreEqual(args.Player.X, 1);
                Assert.AreEqual(args.Player.Y, 1);
            };
            game.Start();
            game.NewGameIteration(null, new KeyPressedArgs(ConsoleKey.LeftArrow));
            game.NewGameIteration(null, new KeyPressedArgs(ConsoleKey.DownArrow));
            game.NewGameIteration(null, new KeyPressedArgs(ConsoleKey.UpArrow));
            game.NewGameIteration(null, new KeyPressedArgs(ConsoleKey.RightArrow));
        }
        public void ReadCorrectRandom()
        {
            var gameMap = new CharGameMapReader(
                FileFromTestsReader.GetFile("CharGameMapReaderRandomTest.txt")).GetMap();

            for (var i = 0; i < 3; ++i)
            {
                for (var j = 0; j < 3; ++j)
                {
                    if (i == 1 && j == 1)
                    {
                        Assert.IsTrue(gameMap.CanGo(i, j));
                    }
                    else
                    {
                        Assert.IsFalse(gameMap.CanGo(i, j));
                    }
                }
            }
        }
예제 #5
0
        public void CorrectPlayerMove()
        {
            var game = new Game(
                new CharGameMapReader(FileFromTestsReader.GetFile("GameFreeMapTest.txt")));

            int[] x = { 0 };
            int[] y = { 0 };
            game.MapChanged += (sender, args) =>
            {
                Assert.AreEqual(args.Player.X, x[0]);
                Assert.AreEqual(args.Player.Y, y[0]);
            };
            game.Start();
            x[0] = 1;
            game.NewGameIteration(null, new KeyPressedArgs(ConsoleKey.RightArrow));
            x[0] = 0;
            game.NewGameIteration(null, new KeyPressedArgs(ConsoleKey.LeftArrow));
            y[0] = 1;
            game.NewGameIteration(null, new KeyPressedArgs(ConsoleKey.DownArrow));
            y[0] = 0;
            game.NewGameIteration(null, new KeyPressedArgs(ConsoleKey.UpArrow));
        }
 public void ReadSuccessRandom()
 {
     Assert.NotNull(new CharGameMapReader(
                        FileFromTestsReader.GetFile("CharGameMapReaderRandomTest.txt")).GetMap());
 }
 public void FailWhenNotFoundWhenRead()
 {
     Assert.Throws <FileNotFoundException>(() =>
                                           new CharGameMapReader(
                                               FileFromTestsReader.GetFile("CharGameMapReaderFailWhenNotFoundTest.txt")).GetMap());
 }
예제 #8
0
 public void CorrectConstructor()
 {
     Assert.DoesNotThrow(() =>
                         new Game(new CharGameMapReader(FileFromTestsReader.GetFile("GameBoundedMapTest.txt"))));
 }