本文整理匯總了C#中Board.PlacePieceAt方法的典型用法代碼示例。如果您正苦於以下問題:C# Board.PlacePieceAt方法的具體用法?C# Board.PlacePieceAt怎麽用?C# Board.PlacePieceAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Board
的用法示例。
在下文中一共展示了Board.PlacePieceAt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: IsSolved_WhenOnlyPartiallySolved_ReturnsFalse
public void IsSolved_WhenOnlyPartiallySolved_ReturnsFalse()
{
// Arrange
var board = new Board(TestBoardSize);
board.PlacePieceAt(new RotatedPiece(Piece.TestPieceA, Orientation.North), 0, 0);
board.PlacePieceAt(new RotatedPiece(Piece.TestPieceB, Orientation.North), 0, 2);
// Act
var actual = board.IsSolved();
// Assert
Assert.That(actual, Is.False);
}
示例2: IsSolved_WhenSolved_ReturnsTrue
public void IsSolved_WhenSolved_ReturnsTrue()
{
// Arrange
var board = new Board(TestBoardSize);
board.PlacePieceAt(new RotatedPiece(Piece.TestPieceA, Orientation.North), 0, 0);
board.PlacePieceAt(new RotatedPiece(Piece.TestPieceB, Orientation.North), 0, 2);
board.PlacePieceAt(new RotatedPiece(Piece.TestPieceC, Orientation.North), 1, 1);
board.PlacePieceAt(new RotatedPiece(Piece.TestPieceD, Orientation.North), 2, 1);
// Act
var actual = board.IsSolved();
// Assert
Assert.That(actual, Is.True);
}
示例3: LayoutNextPiece_GivenThatPieceFirstPieceIsPlacedAndNextPieceIsCompatible_ReturnsTrue
public void LayoutNextPiece_GivenThatPieceFirstPieceIsPlacedAndNextPieceIsCompatible_ReturnsTrue()
{
// Arrange
var board = new Board(TestBoardSize);
board.PlacePieceAt(new RotatedPiece(Piece.TestPieceA, Orientation.North), 0, 0);
// Act
var actual = board.LayoutNextPiece(new RotatedPiece(Piece.TestPieceC, Orientation.North));
// Assert
Assert.That(actual, Is.True);
}
示例4: Reset_GivenThatTheBoardContainsAtLeastOnePiece_SetsColourOfSquareZeroZeroToNull
public void Reset_GivenThatTheBoardContainsAtLeastOnePiece_SetsColourOfSquareZeroZeroToNull()
{
// Arrange
var board = new Board(TestBoardSize);
var squares =
new[]
{
// WBW
new Square(0, 0, Colour.White),
new Square(1, 0, Colour.Black),
new Square(2, 0, Colour.White)
};
var piece = new Piece(squares);
board.PlacePieceAt(piece, 0, 0);
// Act
board.Reset();
// Assert
Assert.That(board.ColourOfSquareZeroZero, Is.Null);
}
示例5: Reset_GivenThatTheBoardContainsAtLeastOnePiece_ClearsAllSqaures
public void Reset_GivenThatTheBoardContainsAtLeastOnePiece_ClearsAllSqaures()
{
// Arrange
var board = new Board(TestBoardSize);
var squares =
new[]
{
// WBW
new Square(0, 0, Colour.White),
new Square(1, 0, Colour.Black),
new Square(2, 0, Colour.White)
};
var piece = new Piece(squares);
board.PlacePieceAt(piece, 0, 0);
// Act
board.Reset();
// Assert
for (int x = 0; x < board.BoardSize; x++) {
for (int y = 0; y < board.BoardSize; y++) {
Assert.That(board.PieceAt(x, y), Is.Null);
}
}
}
示例6: PlacePiece_WhenPlacingTheFirstPieceAtLocationZeroZero_SetsColourOfSquareZeroZeroToCorrectValue
public void PlacePiece_WhenPlacingTheFirstPieceAtLocationZeroZero_SetsColourOfSquareZeroZeroToCorrectValue()
{
// Arrange
var squares =
new[]
{
// WBW
new Square(0, 0, Colour.White),
new Square(1, 0, Colour.Black),
new Square(2, 0, Colour.White)
};
var piece = new Piece(squares);
var board = new Board(TestBoardSize);
// Act
board.PlacePieceAt(piece, 0, 0);
// Assert
Assert.That(board.ColourOfSquareZeroZero, Is.Not.Null);
Assert.That(board.ColourOfSquareZeroZero, Is.EqualTo(Colour.White));
}
示例7: PlacePiece_WhenPlacingTheFirstPieceAtLocationZeroZeroWithOrientationEast_ReturnsTrue
public void PlacePiece_WhenPlacingTheFirstPieceAtLocationZeroZeroWithOrientationEast_ReturnsTrue()
{
// Arrange
var squares =
new[]
{
// WBW
new Square(0, 0, Colour.White),
new Square(1, 0, Colour.Black),
new Square(2, 0, Colour.White)
};
var piece = new Piece(squares);
var board = new Board(TestBoardSize);
// Act
var actual = board.PlacePieceAt(new RotatedPiece(piece, Orientation.North), 0, 0);
// Assert
Assert.That(actual, Is.True);
}
示例8: PlacePiece_GivenInvalidCoordinates_ThrowsException
public void PlacePiece_GivenInvalidCoordinates_ThrowsException(int x, int y)
{
// Arrange
var squares =
new[]
{
// WBW
new Square(0, 0, Colour.White),
new Square(1, 0, Colour.Black),
new Square(2, 0, Colour.White)
};
var piece = new Piece(squares);
var board = new Board(TestBoardSize);
// Act, Assert
Assert.Throws<ArgumentOutOfRangeException>(() => board.PlacePieceAt(piece, x, y));
}
示例9: PlacePiece_GivenAValidPieceAtAValidLocation_ReturnsTrue
public void PlacePiece_GivenAValidPieceAtAValidLocation_ReturnsTrue()
{
// Arrange
var squares =
new[]
{
// WBW
new Square(0, 0, Colour.White),
new Square(1, 0, Colour.Black),
new Square(2, 0, Colour.White)
};
var piece = new Piece(squares);
var board = new Board(TestBoardSize);
// Act
var actual = board.PlacePieceAt(piece, 0, 0);
// Assert
Assert.That(actual, Is.True);
}
示例10: PlacePiece_GivenAYValueAndPieceHeightCombinationThatExceedBoardSize_ReturnsFalse
public void PlacePiece_GivenAYValueAndPieceHeightCombinationThatExceedBoardSize_ReturnsFalse()
{
// Arrange
var squares =
new[]
{
// W
// B
// W
new Square(0, 0, Colour.White),
new Square(0, 1, Colour.Black),
new Square(0, 2, Colour.White)
};
var piece = new Piece(squares);
var board = new Board(TestBoardSize);
// Act
var actual = board.PlacePieceAt(piece, 0, board.BoardSize - piece.Height + 1);
// Assert
Assert.That(actual, Is.False);
}
示例11: PlacePiece_GivenASecondPieceAtAValidLocation_ReturnsTrue
public void PlacePiece_GivenASecondPieceAtAValidLocation_ReturnsTrue()
{
// Arrange
var squares1 =
new[]
{
// WBW
new Square(0, 0, Colour.White),
new Square(1, 0, Colour.Black),
new Square(2, 0, Colour.White)
};
var piece1 = new Piece(squares1);
var squares2 =
new[]
{
// BWB
new Square(0, 0, Colour.Black),
new Square(1, 0, Colour.White),
new Square(2, 0, Colour.Black)
};
var piece2 = new Piece(squares2);
var board = new Board(TestBoardSize);
// Act
var actual1 = board.PlacePieceAt(piece1, 0, 0);
var actual2 = board.PlacePieceAt(piece2, 0, 1);
// Assert
Assert.That(actual1, Is.True);
Assert.That(actual2, Is.True);
}
示例12: PlacePiece_GivenASecondPieceAtAValidLocationButWhereASquareHasTheWrongColour_ReturnsFalse
public void PlacePiece_GivenASecondPieceAtAValidLocationButWhereASquareHasTheWrongColour_ReturnsFalse()
{
// Arrange
var squares1 =
new[]
{
// WBW
new Square(0, 0, Colour.White),
new Square(1, 0, Colour.Black),
new Square(2, 0, Colour.White)
};
var piece1 = new Piece(squares1);
var squares2 =
new[]
{
// BWB
new Square(0, 0, Colour.Black),
new Square(1, 0, Colour.White),
new Square(2, 0, Colour.Black)
};
var piece2 = new Piece(squares2);
var board = new Board(TestBoardSize);
// Act
board.PlacePieceAt(piece1, 0, 0);
var actual = board.PlacePieceAt(piece2, 1, 1);
// Assert
Assert.That(actual, Is.False);
}
示例13: PlacePiece_GivenAnXValueAndPieceWidthCombinationThatExceedBoardSize_ReturnsFalse
public void PlacePiece_GivenAnXValueAndPieceWidthCombinationThatExceedBoardSize_ReturnsFalse()
{
// Arrange
var squares =
new[]
{
// WBW
new Square(0, 0, Colour.White),
new Square(1, 0, Colour.Black),
new Square(2, 0, Colour.White)
};
var piece = new Piece(squares);
var board = new Board(TestBoardSize);
// Act
var actual = board.PlacePieceAt(piece, board.BoardSize - piece.Width + 1, 0);
// Assert
Assert.That(actual, Is.False);
}
示例14: PlacePiece_GivenALocationAndPieceShapeThatCausesAnOverlapWithAnExistingPiece_ReturnsFalse
public void PlacePiece_GivenALocationAndPieceShapeThatCausesAnOverlapWithAnExistingPiece_ReturnsFalse()
{
// Arrange
var squares1 =
new[]
{
// WBW
new Square(0, 0, Colour.White),
new Square(1, 0, Colour.Black),
new Square(2, 0, Colour.White)
};
var piece1 = new Piece(squares1);
var squares2 =
new[]
{
// BWB
new Square(0, 0, Colour.Black),
new Square(1, 0, Colour.White),
new Square(2, 0, Colour.Black)
};
var piece2 = new Piece(squares2);
var board = new Board(TestBoardSize);
// Act
var actual1 = board.PlacePieceAt(piece1, 1, 0);
var actual2 = board.PlacePieceAt(piece2, 0, 0);
// Assert
Assert.That(actual1, Is.True);
Assert.That(actual2, Is.False);
Assert.That(board.PieceAt(0, 0), Is.Null);
Assert.That(board.PieceAt(1, 0), Is.SameAs(piece1));
Assert.That(board.PieceAt(2, 0), Is.SameAs(piece1));
Assert.That(board.PieceAt(3, 0), Is.SameAs(piece1));
}
示例15: PieceAt_GivenUnoccupiedLocation_ReturnsNull
public void PieceAt_GivenUnoccupiedLocation_ReturnsNull()
{
// Arrange
var squares =
new[]
{
// WBW
new Square(0, 0, Colour.White),
new Square(1, 0, Colour.Black),
new Square(2, 0, Colour.White)
};
var piece = new Piece(squares);
var board = new Board(TestBoardSize);
// Act
var actual = board.PlacePieceAt(piece, 1, 0);
// Assert
Assert.That(actual, Is.True);
Assert.That(board.PieceAt(0, 0), Is.Null);
Assert.That(board.PieceAt(0, 1), Is.Null);
}