Fixed code smell + added test
continuous-integration/drone/push Build is passing Details

master
Jules LASCRET 1 year ago
parent 3455682073
commit 9ea98eaa90

File diff suppressed because one or more lines are too long

@ -61,7 +61,7 @@ public class Cell : INotifyPropertyChanged
/// <returns>True if the cell is empty, false if the cell contains a tile.</returns> /// <returns>True if the cell is empty, false if the cell contains a tile.</returns>
public bool IsFree public bool IsFree
{ {
get { return Tile == null; } get { return Tile! == null!; }
} }
@ -72,7 +72,7 @@ public class Cell : INotifyPropertyChanged
/// <returns>True if added succefully (if the cell didn't already contain a tile), false if there already was a tile in this cell.</returns> /// <returns>True if added succefully (if the cell didn't already contain a tile), false if there already was a tile in this cell.</returns>
public bool SetTile(Tile addedTile) public bool SetTile(Tile addedTile)
{ {
if (Tile == null) if (Tile! == null!)
{ {
Tile = addedTile; Tile = addedTile;

@ -559,7 +559,7 @@ namespace QwirkleClassLibrary.Games
/// <param name="nbTiles"></param> /// <param name="nbTiles"></param>
/// <param name="checkdoubles"></param> /// <param name="checkdoubles"></param>
/// <returns></returns> /// <returns></returns>
private static bool CheckTileInCompletedLines(Tile? t1, ref int nbTiles, ref List<Tile> checkdoubles) public static bool CheckTileInCompletedLines(Tile? t1, ref int nbTiles, ref List<Tile> checkdoubles)
{ {
if (t1! != null!) if (t1! != null!)
{ {

@ -62,7 +62,7 @@ namespace QwirkleClassLibrary.Tiles
{ {
if (obj == null) if (obj == null)
{ {
throw new NullReferenceException(); throw new NullReferenceException("The object is null.");
} }
var otherTile = obj as Tile; var otherTile = obj as Tile;

@ -381,6 +381,23 @@ public class TestGame
} }
[Fact]
public void Test_CheckTileInCompletedLines()
{
int nbTiles = 0;
var checkdoubles = new List<Tile>()
{
new(Shape.Club, Color.Blue),
new(Shape.Club, Color.Red),
new(Shape.Club, Color.Green),
};
var t1 = new Tile(Shape.Club, Color.Green);
Assert.False(Game.CheckTileInCompletedLines(t1, ref nbTiles, ref checkdoubles));
}
[Theory] [Theory]
[InlineData(3, 1, 4, 1, 5, 1, 5)] [InlineData(3, 1, 4, 1, 5, 1, 5)]
[InlineData(2, 2, 3, 2, 4, 2, 5)] [InlineData(2, 2, 3, 2, 4, 2, 5)]

Loading…
Cancel
Save