示例#1
0
 public void TestMixed()
 {
     var game = new Game();
     game.SetNumber(3, 1, 2);
     game.SetNumber(3, 2, 2);
     game.SetNumber(3, 3, 4);
     var res = game.Update(Direction.Up);
     Assert.AreEqual<uint>(2, game.GetNumber(0, 1));
     Assert.AreEqual<uint>(2, game.GetNumber(0, 2));
     Assert.AreEqual<uint>(4, game.GetNumber(0, 3));
     Assert.AreEqual(new Coordinate(0, 1), game.Transformations[3, 1].Destination);
     Assert.AreEqual(new Coordinate(0, 2), game.Transformations[3, 2].Destination);
     Assert.AreEqual(new Coordinate(0, 3), game.Transformations[3, 3].Destination);
     Assert.AreEqual(-1, game.Smoothness());
     Assert.AreEqual(1, game.Coherence());
     Assert.AreEqual<uint>(0, res.MergedCount);
     res = game.Update(Direction.Right);
     Assert.AreEqual<uint>(0, game.GetNumber(0, 1));
     Assert.AreEqual<uint>(4, game.GetNumber(0, 2));
     Assert.AreEqual<uint>(4, game.GetNumber(0, 3));
     Assert.AreEqual<uint>(1, res.MergedCount);
     Assert.AreEqual(new Coordinate(0, 2), game.Transformations[0, 1].Destination);
     Assert.AreEqual(true, game.Transformations[0, 2].WasNew);
     Assert.AreEqual(1, game.Coherence());
     res = game.Update(Direction.Left);
     Assert.AreEqual<uint>(8, game.GetNumber(0, 0));
     Assert.AreEqual<uint>(0, game.GetNumber(0, 2));
     Assert.AreEqual<uint>(0, game.GetNumber(0, 3));
     Assert.AreEqual(new Coordinate(0, 0), game.Transformations[0, 2].Destination);
     Assert.AreEqual(true, game.Transformations[0, 0].WasNew);
     Assert.AreEqual<uint>(1, res.MergedCount);
 }
示例#2
0
 public void TestMoveRightTrivial()
 {
     var game = new Game();
     game.SetNumber(1, 0, 2);
     game.Update(Direction.Right);
     Assert.AreEqual<uint>(2, game.GetNumber(1, 3));
     Assert.AreEqual<uint>(0, game.GetNumber(1, 1));
     Assert.AreEqual<uint>(0, game.GetNumber(1, 2));
 }
示例#3
0
 public void TestMoveRightRight()
 {
     var game = new Game();
     game.SetNumber(1, 3, 4);
     game.Update(Direction.Right);
     Assert.AreEqual<uint>(4, game.GetNumber(1, 3));
     Assert.AreEqual<uint>(0, game.GetNumber(1, 2));
     Assert.AreEqual<uint>(0, game.GetNumber(1, 1));
     foreach (var trans in game.Transformations)
         Assert.AreEqual(Coordinate.Nowhere, trans.Destination);
 }
示例#4
0
        public void TestMoveRightMulti()
        {
            var game = new Game();
            game.SetNumber(1, 0, 2);
            game.SetNumber(1, 1, 2);
            game.SetNumber(1, 2, 4);
            game.Update(Direction.Right);
            Assert.AreEqual<uint>(0, game.GetNumber(1, 0));
            Assert.AreEqual<uint>(0, game.GetNumber(1, 1));
            Assert.AreEqual<uint>(4, game.GetNumber(1, 2));
            Assert.AreEqual<uint>(4, game.GetNumber(1, 3));
            var info = game.Transformations[1, 0];
            Assert.AreEqual(new Coordinate(1, 2), info.Destination);
            Assert.AreEqual<uint>(2, info.PreviousNumber);
            info = game.Transformations[1, 2];
            Assert.AreEqual(true, info.WasNew);

            game.Update(Direction.Right);
            Assert.AreEqual<uint>(0, game.GetNumber(1, 0));
            Assert.AreEqual<uint>(0, game.GetNumber(1, 1));
            Assert.AreEqual<uint>(0, game.GetNumber(1, 2));
            Assert.AreEqual<uint>(8, game.GetNumber(1, 3));
        }
示例#5
0
        public void TestMoveDownMulti()
        {
            var game = new Game();
            game.SetNumber(1, 0, 4);
            game.SetNumber(2, 0, 2);
            game.SetNumber(3, 0, 2);
            game.Update(Direction.Down);
            Assert.AreEqual<uint>(0, game.GetNumber(1, 0));
            Assert.AreEqual<uint>(4, game.GetNumber(2, 0));
            Assert.AreEqual<uint>(4, game.GetNumber(3, 0));
            var info = game.Transformations[1, 0];
            Assert.AreEqual(new Coordinate(2, 0), info.Destination);
            Assert.AreEqual<uint>(4, info.PreviousNumber);
            info = game.Transformations[3, 0];
            Assert.AreEqual(true, info.WasNew);

            game.Update(Direction.Down);
            Assert.AreEqual<uint>(0, game.GetNumber(1, 0));
            Assert.AreEqual<uint>(0, game.GetNumber(2, 0));
            Assert.AreEqual<uint>(8, game.GetNumber(3, 0));
            info = game.Transformations[2, 0];
            Assert.AreEqual(new Coordinate(3, 0), info.Destination);
            Assert.AreEqual<uint>(4, info.PreviousNumber);
            info = game.Transformations[3, 0];
            Assert.AreEqual(true, info.WasNew);
        }
示例#6
0
 public void TestMoveDownBottom()
 {
     var game = new Game();
     game.SetNumber(3, 0, 4);
     game.Update(Direction.Down);
     Assert.AreEqual<uint>(4, game.GetNumber(3, 0));
     Assert.AreEqual<uint>(0, game.GetNumber(1, 0));
     Assert.AreEqual<uint>(0, game.GetNumber(2, 0));
     foreach (var trans in game.Transformations)
         Assert.AreEqual(Coordinate.Nowhere, trans.Destination);
 }