KoogleV4/GameHandler.UnitTests/GameServiceTests.cs

62 lines
1.8 KiB
C#

using GameModel;
using GameModel.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GameHandler.UnitTests
{
[TestFixture]
internal class GameServiceTests
{
[Test]
public void Start_InvalidStartStatusThrowInvalidGameStateExcpetion()
{
GameService service = new GameService();
service.Start();
Assert.That(() => service.Start(), Throws.TypeOf<InvalidGameStateExcpetion>());
}
[Test]
public void Stop_InvalidStopStatusThrowInvalidGameStateExcpetion()
{
GameService service = new GameService();
Assert.That(() => service.Stop(), Throws.TypeOf<InvalidGameStateExcpetion>());
}
[Test]
public void HandleThrow_NotPossibleBeforeStart()
{
GameService service = new GameService();
Assert.That(() => service.HandleThrow(null), Throws.TypeOf<InvalidGameStateExcpetion>());
}
[Test]
public void HandleThrow_NotPossibleAfterStop()
{
GameService service = new GameService();
service.Start();
service.Stop();
Assert.That(() => service.HandleThrow(null), Throws.TypeOf<InvalidGameStateExcpetion>());
}
[Test]
public void HandleThrow_UpdateTheBoardState()
{
GameService service = new GameService();
var ts1 = service.Start();
var bs1 = ts1.BoardState;
var pinThrow = PinThrow.Create(1,PinPicture.Create(1,PinState.Down), false, false);
var ts2 = service.HandleThrow(pinThrow);
var bs2 = ts2.BoardState;
Assert.That(bs2, Is.Not.EqualTo(bs1));
}
}
}