Ajout d'une correction possible
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
using FakeItEasy;
|
||||
using MiniJeuxFinal.Games.PierrePapierCiseaux.Actions;
|
||||
using MiniJeuxFinal.Games.PierrePapierCiseaux.Factories;
|
||||
using MiniJeuxFinal.Games.PierrePapierCiseaux.Players;
|
||||
using NFluent;
|
||||
|
||||
namespace MiniJeuxFinal.Test.Games.PierrePapierCiseaux.Players
|
||||
{
|
||||
public class PlayerPpcTest
|
||||
{
|
||||
private readonly IActionPpcFactory _actionPpcFactory = A.Fake<IActionPpcFactory>();
|
||||
|
||||
|
||||
|
||||
private PlayerPpc CreateTarget() => new PlayerPpc("Paul", _actionPpcFactory);
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Should_initialize_target()
|
||||
{
|
||||
var player = CreateTarget();
|
||||
|
||||
Check.That(player.Name).IsEqualTo("Paul");
|
||||
Check.That(player.ToString()).IsEqualTo("Paul: 0");
|
||||
Check.That(player.Score).IsEqualTo(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_increment_score()
|
||||
{
|
||||
var player = CreateTarget();
|
||||
Check.That(player.Score).IsEqualTo(0);
|
||||
player.IncrementScore();
|
||||
Check.That(player.Score).IsEqualTo(1);
|
||||
player.IncrementScore();
|
||||
player.IncrementScore();
|
||||
Check.That(player.Score).IsEqualTo(3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_add_a_single_action_and_get()
|
||||
{
|
||||
var player = CreateTarget();
|
||||
var action1 = A.Fake<IActionPpc>();
|
||||
A.CallTo(() => _actionPpcFactory.GetAction(A<IList<IActionPpc>>._)).Returns(action1);
|
||||
player.AddAction(action1);
|
||||
var result = player.Play();
|
||||
|
||||
Check.That(result).IsEqualTo(action1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_add_a_multiple_actions_and_get()
|
||||
{
|
||||
var player = CreateTarget();
|
||||
var action1 = A.Fake<IActionPpc>();
|
||||
var action2 = A.Fake<IActionPpc>();
|
||||
var action3 = A.Fake<IActionPpc>();
|
||||
A.CallTo(() => _actionPpcFactory.GetAction(A<IList<IActionPpc>>._)).Returns(action2);
|
||||
player.AddAction(action1, action2, action3);
|
||||
var result = player.Play();
|
||||
|
||||
Check.That(result).IsEqualTo(action2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_throw_when_has_no_action()
|
||||
{
|
||||
var player = CreateTarget();
|
||||
Check.ThatCode(() => player.Play()).Throws<InvalidOperationException>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user