dev
This commit is contained in:
parent
a6508da7a5
commit
6c090e29d0
|
|
@ -0,0 +1,39 @@
|
|||
using GameHandler.GameHandler;
|
||||
using GameModel;
|
||||
using GameModel.FreeGame;
|
||||
using NuGet.Frameworks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameHandler.UnitTests.GameHandler
|
||||
{
|
||||
[TestFixture]
|
||||
internal class FreeGameHandlerTests
|
||||
{
|
||||
private FreeGameHandler _gh;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_gh = new FreeGameHandler();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Init_ReturnsModelWithThrowModelPerPlayer()
|
||||
{
|
||||
var model = _gh.InitGameModel(new[] { 1, 2, 3, 4 }, null) as FreeGameModel;
|
||||
Assert.That(model, Is.Not.Null);
|
||||
Assert.That(model.Throws.Count(), Is.EqualTo(4));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Update_ThrowsExceptionWhenModelIsNotInitialized()
|
||||
{
|
||||
Assert.That(() => _gh.Update(PinThrow.Create(2, false, true), BoardState.Create()), Throws.TypeOf<FreeGameThrowExcepetion>());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -38,8 +38,7 @@ namespace GameHandler.GameHandler
|
|||
var model = throws.FirstOrDefault(_ => _.PlayerId == pinThrow.PlayerId);
|
||||
if (model == null)
|
||||
{
|
||||
model = FreeGameThrow.Create(pinThrow.PlayerId);
|
||||
throws.Add(model);
|
||||
throw new FreeGameThrowExcepetion("game model not initialized");
|
||||
}
|
||||
var model2 = model + pinThrow;
|
||||
var idx = throws.IndexOf(model);
|
||||
|
|
|
|||
Loading…
Reference in New Issue