当前位置: 首页>>代码示例>>C#>>正文


C# Grid.AddTile方法代码示例

本文整理汇总了C#中Grid.AddTile方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.AddTile方法的具体用法?C# Grid.AddTile怎么用?C# Grid.AddTile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Grid的用法示例。


在下文中一共展示了Grid.AddTile方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestCanSwapMethodToReturnFalseValueWhenCurrentTileCannotBeSwapped

        public void TestCanSwapMethodToReturnFalseValueWhenCurrentTileCannotBeSwapped()
        {
            var grid = new Grid();
            for (int i = 0; i < 5; i++)
            {
                var tile = new Tile(string.Empty + i + string.Empty, i, TileType.Number);
                grid.AddTile(tile);
            }

            var emptyTile = new Tile(string.Empty, GlobalConstants.TotalTilesCount - 1, TileType.Empty);
            grid.AddTile(emptyTile);
            var tileToTest = grid.GetTileFromLabel("1");
            var actual = grid.CanSwap(tileToTest);
            var expected = false;
            Assert.AreEqual(expected, actual);
        }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:16,代码来源:GridTests.cs

示例2: TestCanSwapMethodToReturnFalseValueWhenCurrentTileCanBeSwapped

        public void TestCanSwapMethodToReturnFalseValueWhenCurrentTileCanBeSwapped()
        {
            var grid = new Grid();
            for (int i = 0; i < 5; i++)
            {
                var tile = new Tile(i.ToString(), i, TileType.Number);
                grid.AddTile(tile);
            }

            var emptyTile = new Tile(string.Empty, 5, TileType.Empty);
            grid.AddTile(emptyTile);
            var tileToTest = grid.GetTileFromLabel("4");
            var actual = grid.CanSwap(tileToTest);
            var expected = true;
            Assert.AreEqual(expected, actual);
        }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:16,代码来源:GridTests.cs

示例3: TestAddTileMethodToRetturnAccurateValue

        public void TestAddTileMethodToRetturnAccurateValue()
        {
            var grid = new Grid();
            for (int i = 0; i < 5; i++)
            {
                var tile = new Tile(string.Empty + i + string.Empty, i, TileType.Number);
                grid.AddTile(tile);
            }

            var actual = grid.TilesCount;
            var expected = 5;
            Assert.AreEqual(actual, expected);
        }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:13,代码来源:GridTests.cs

示例4: TestCheckIfSortedWhenGridIsNotSorted

        public void TestCheckIfSortedWhenGridIsNotSorted()
        {
            var grid = new Grid();
            var emptyTile = new Tile(string.Empty, 0, TileType.Empty);
            grid.AddTile(emptyTile);

            for (int i = GlobalConstants.TotalTilesCount - 1; i > 0; i--)
            {
                Tile tile = emptyTile.CloneMemberwise();
                tile.Label = (i + 1).ToString();
                tile.Position = i;
                tile.Type = TileType.Number;
                grid.AddTile(tile);
            }

            bool actual = grid.IsSorted;
            var expected = false;
            Assert.AreEqual(expected, actual);
        }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:19,代码来源:GridTests.cs

示例5: TestSwapTiles

        public void TestSwapTiles()
        {
            var grid = new Grid();

            var emptyTile = new Tile(string.Empty, 0, TileType.Empty);
            grid.AddTile(emptyTile);

            Tile tile = emptyTile.CloneMemberwise();
            tile.Label = "1";
            tile.Position = 1;
            tile.Type = TileType.Number;
            grid.AddTile(tile);

            grid.SwapTiles(tile);

            var actual = tile.Position;
            var expected = 0;

            Assert.AreEqual(expected, actual);
        }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:20,代码来源:GridTests.cs

示例6: TestMementoToReturnValidObjectState

        public void TestMementoToReturnValidObjectState()
        {
            var grid = new Grid();
            var tile = new Tile("1", 1, TileType.Number);
            var emptyTile = new Tile(string.Empty, GlobalConstants.TotalTilesCount - 1, TileType.Empty);
            var anotherTile = new Tile("2", 2, TileType.Number);
            grid.AddTile(tile);
            grid.AddTile(emptyTile);
            Memento memento = grid.SaveMemento();

            grid.AddTile(anotherTile);
            grid.RestoreMemento(memento);

            var actual = grid.TilesCount;
            var expected = 2;
            Assert.AreEqual(expected, actual);
        }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:17,代码来源:GridTests.cs

示例7: TestGetTileFromLabelMethodToReturnNullWhenNoValidDataIsProvided

 public void TestGetTileFromLabelMethodToReturnNullWhenNoValidDataIsProvided()
 {
     var grid = new Grid();
     var tile = new Tile("1", 1, TileType.Number);
     var anotherTile = new Tile("2", 2, TileType.Number);
     grid.AddTile(tile);
     grid.AddTile(anotherTile);
     var actual = grid.GetTileFromLabel("3");
     Assert.AreEqual(null, actual);
 }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:10,代码来源:GridTests.cs

示例8: TestGetTileFromLabelMethodToReturnValidTile

 public void TestGetTileFromLabelMethodToReturnValidTile()
 {
     var grid = new Grid();
     var tile = new Tile("1", 1, TileType.Number);
     var anotherTile = new Tile("2", 2, TileType.Number);
     grid.AddTile(tile);
     grid.AddTile(anotherTile);
     var actual = grid.GetTileFromLabel("2");
     var expected = anotherTile;
     Assert.AreEqual(expected, actual);
 }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:11,代码来源:GridTests.cs

示例9: TestGetTileAtPositionMethodToThrowWhenNoValidPositionIsProvided

 public void TestGetTileAtPositionMethodToThrowWhenNoValidPositionIsProvided()
 {
     var grid = new Grid();
     var tile = new Tile("3", 3, TileType.Number);
     var anotherTile = new Tile("4", 4, TileType.Number);
     grid.AddTile(tile);
     grid.AddTile(anotherTile);
     var actual = grid.GetTileAtPosition(2);
     var expected = anotherTile;
     Assert.AreEqual(expected, actual);
 }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:11,代码来源:GridTests.cs

示例10: TestGetTileAtPositionMethodToReturnValidPositionOfTile

 public void TestGetTileAtPositionMethodToReturnValidPositionOfTile()
 {
     var grid = new Grid();
     var tile = new Tile("3", 3, TileType.Number);
     var anotherTile = new Tile("4", 4, TileType.Number);
     grid.AddTile(tile);
     grid.AddTile(anotherTile);
     var actual = grid.GetTileAtPosition(1);
     var expected = anotherTile;
     Assert.AreEqual(expected, actual);
 }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:11,代码来源:GridTests.cs

示例11: TestGetEnumerator

        public void TestGetEnumerator()
        {
            var grid = new Grid();

            var emptyTile = new Tile(string.Empty, 0, TileType.Empty);
            grid.AddTile(emptyTile);

            Tile tile = emptyTile.CloneMemberwise();
            tile.Label = "1";
            tile.Position = 1;
            tile.Type = TileType.Number;
            grid.AddTile(tile);

            foreach (Tile item in grid)
            {
                item.Label = "test";
            }

            var actual = emptyTile.Label;
            var expected = "test";

            Assert.AreEqual(expected, actual);
        }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:23,代码来源:GridTests.cs

示例12: TestClearMethodToRetturnZeroValue

 public void TestClearMethodToRetturnZeroValue()
 {
     var grid = new Grid();
     var tile = new Tile("1", 1, TileType.Number);
     grid.AddTile(tile);
     grid.Clear();
     var actual = grid.TilesCount;
     var expected = 0;
     Assert.AreEqual(actual, expected);
 }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:10,代码来源:GridTests.cs

示例13: TestRenderPlayScreenToWorkCorrectly

        public void TestRenderPlayScreenToWorkCorrectly()
        {
            var mockedWrited = new Mock<HelperWriter>();
            Console.SetOut(mockedWrited.Object);

            ConsoleRenderer rende = new ConsoleRenderer(new BorderStyleFactory());
            Scoreboard scoreBoard = Scoreboard.Instance;
            Grid grid = new Grid();
            int timesToBePrinted = GlobalConstants.GridSize * GlobalConstants.GridSize;
            for (int i = 0; i < timesToBePrinted - 1; i++)
            {
                grid.AddTile(new Tile((i + 1).ToString(), i, TileType.Number));
            }

            grid.AddTile(new Tile(" ", 15, TileType.Empty));

            rende.RenderPlayScreen(grid);

            mockedWrited.Verify(w => w.Write(It.IsAny<string>()), Times.AtLeast(timesToBePrinted / GlobalConstants.GridSize));
        }
开发者ID:TeamGameFifteen1-Telerik,项目名称:GameFifteen,代码行数:20,代码来源:ConsoleRendererTests.cs


注:本文中的Grid.AddTile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。