using Autofac; using GameHandler.DeathGame; using GameModel; using GameModel.Contract; using GameModel.Exceptions; using GameModel.Mocks; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace GameHandler.UnitTests { [TestFixture] internal class GameServiceTests { private GameService service; [SetUp] public void SetUp() { var builder = new ContainerBuilder(); builder.RegisterType().As(); service = new GameService(builder.Build()); } [Test] public void Start_InvalidStartStatusThrowInvalidGameStateExcpetion() { service.Start(); Assert.That(() => service.Start(), Throws.TypeOf()); } [Test] public void Stop_InvalidStopStatusThrowInvalidGameStateExcpetion() { Assert.That(() => service.Stop(), Throws.TypeOf()); } [Test] public void HandleThrow_NotPossibleBeforeStart() { Assert.That(() => service.HandleThrow(null), Throws.TypeOf()); } [Test] public void HandleThrow_NotPossibleAfterStop() { service.Start(); service.Stop(); Assert.That(() => service.HandleThrow(null), Throws.TypeOf()); } [Test] public void HandleThrow_UpdatesTheBoardState() { var ts1 = service.Start(DeathGameHandler.GAMENAME_DEATHBOX); var bs1 = ts1.ThrowState.BoardState; var pinThrow = PinThrow.Create(1,PinPicture.Create(1,PinState.Down), false, false); var ts2 = service.HandleThrow(pinThrow); var bs2 = ts2.ThrowState.BoardState; Assert.That(bs2, Is.Not.EqualTo(bs1)); } } }