本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}