84 lines
2.8 KiB
C#
84 lines
2.8 KiB
C#
using GameModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GameHandler.UnitTests
|
|
{
|
|
[TestFixture]
|
|
public class ThrowHandlerTests
|
|
{
|
|
ThrowHandler _th;
|
|
|
|
[SetUp]
|
|
public void SetUp()
|
|
{
|
|
_th = new ThrowHandler();
|
|
}
|
|
|
|
[Test]
|
|
public void CreateFullPicAfterEachThrowInRepositionMode()
|
|
{
|
|
var bs = _th.Init(ThrowMode.Reposition, 3);
|
|
|
|
var bs2 = _th.Update(bs, new PinThrow(1, PinPicture.Create(2,PinState.Down),false,false));
|
|
|
|
Assert.That(bs.BoardState.PinPicture.UpCount, Is.EqualTo(9));
|
|
}
|
|
|
|
[Test]
|
|
public void SinkThrowReturnsSameGameStateAsBefore()
|
|
{
|
|
var bs = _th.Init(ThrowMode.Reposition, 3);
|
|
|
|
var bs2 = _th.Update(bs, new PinThrow(1, PinPicture.Create(2, PinState.Down), false, false));
|
|
var bs3 = _th.Update(bs, new PinThrow(1, PinPicture.Create(2, PinState.Down), false, true));
|
|
|
|
Assert.That(bs2, Is.EqualTo(bs3));
|
|
}
|
|
|
|
[Test]
|
|
public void CreateFullPicAfterBoardIsClearedInDecreaseMode()
|
|
{
|
|
var bs = _th.Init(ThrowMode.Decrease, 3);
|
|
|
|
var bs2 = _th.Update(bs, new PinThrow(1, PinPicture.Create(2, PinState.Down), false, false));
|
|
Assert.That(bs2.BoardState.PinPicture.DownCount, Is.EqualTo(1));
|
|
|
|
var bs3 = _th.Update(bs, new PinThrow(1, PinPicture.CreateAllPins(), false, false));
|
|
Assert.That(bs3.BoardState.PinPicture.DownCount, Is.EqualTo(0));
|
|
}
|
|
|
|
[Test]
|
|
public void Update_ThrowCounterIncreasedAfterEachThrow()
|
|
{
|
|
var bs = _th.Init(ThrowMode.Decrease, 3);
|
|
Assert.That(bs.ThrowCount, Is.EqualTo(0));
|
|
|
|
var bs2 = _th.Update(bs, new PinThrow(1, PinPicture.Create(2, PinState.Down), false, false));
|
|
Assert.That(bs2.ThrowCount, Is.EqualTo(1));
|
|
|
|
var bs3 = _th.Update(bs2, new PinThrow(1, PinPicture.CreateAllPins(), false, false));
|
|
Assert.That(bs3.ThrowCount, Is.EqualTo(2));
|
|
}
|
|
|
|
[Test]
|
|
public void Update_ThrowCounterResetToZeroAfterFullRound()
|
|
{
|
|
var bs = _th.Init(ThrowMode.Decrease, 3);
|
|
Assert.That(bs.ThrowCount, Is.EqualTo(0));
|
|
|
|
var bs2 = _th.Update(bs, new PinThrow(1, PinPicture.Create(2, PinState.Down), false, false));
|
|
Assert.That(bs2.ThrowCount, Is.EqualTo(1));
|
|
|
|
var bs3 = _th.Update(bs2, new PinThrow(1, PinPicture.CreateAllPins(), false, false));
|
|
Assert.That(bs3.ThrowCount, Is.EqualTo(2));
|
|
|
|
var bs4 = _th.Update(bs3, new PinThrow(1, PinPicture.CreateAllPins(), false, false));
|
|
Assert.That(bs4.ThrowCount, Is.EqualTo(0));
|
|
}
|
|
}
|
|
}
|