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>
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>
public bool SetTile(Tile addedTile)
{
if (Tile == null)
if (Tile! == null!)
{
Tile = addedTile;

@ -559,7 +559,7 @@ namespace QwirkleClassLibrary.Games
/// <param name="nbTiles"></param>
/// <param name="checkdoubles"></param>
/// <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!)
{

@ -62,7 +62,7 @@ namespace QwirkleClassLibrary.Tiles
{
if (obj == null)
{
throw new NullReferenceException();
throw new NullReferenceException("The object is null.");
}
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]
[InlineData(3, 1, 4, 1, 5, 1, 5)]
[InlineData(2, 2, 3, 2, 4, 2, 5)]

Loading…
Cancel
Save