test
continuous-integration/drone/push Build is failing Details

test_old_branch
Jérémy Mouyon 12 months ago
parent e24c8a8828
commit f57eeb6b0c

@ -14,6 +14,11 @@ namespace QwirkleClassLibrary
public TileBag(int nbSet)
{
if (nbSet < 0 || nbSet < 3)
{
throw new ArgumentException(nbSet.ToString());
}
for (int i = 0; i < nbSet; i++)
{
foreach (Shape s in Enum.GetValues(typeof(Shape)))
@ -28,20 +33,27 @@ namespace QwirkleClassLibrary
TilesBag = tiles.AsReadOnly();
}
public void AddTileInBag(Tile tile)
public bool AddTileInBag(Tile tile)
{
if (tiles == null)
{
return false;
}
tiles.Add(tile);
return true;
}
public void RemoveTileInBag(Tile tile)
public bool RemoveTileInBag(Tile tile)
{
for (int i = 0; i < tiles.Count; i++)
{
if (tiles[i] == tile)
{
tiles.RemoveAt(i);
return true;
}
}
return false;
}
}
}

@ -0,0 +1,39 @@
using QwirkleClassLibrary;
namespace TestBase;
public class TestTileBag
{
[Theory]
[InlineData(false, 5)]
[InlineData(false, -5)]
[InlineData(true, 2)]
public void Test_TileBagConstructor(bool isValid, int nbset)
{
if (!isValid)
{
Assert.Throws<ArgumentException>(() => new TileBag(nbset));
return;
}
TileBag bag = new TileBag(nbset);
Assert.Equal(bag.TilesBag.Count, nbset);
}
[Fact]
public void Test_AddTileInBag()
{
Tile t = null;
Tile tok = new(Shape.Club, Color.Green);
TileBag bag = new TileBag(2);
if (bag.AddTileInBag(t) == false)
{
Assert.True(bag.AddTileInBag(tok));
}
}
}
Loading…
Cancel
Save