feat: update draw offer test to include draw decline scenario
Build & Test (NowChessSystems) TeamCity build failed

This commit is contained in:
2026-04-19 22:17:12 +02:00
parent a5beb3e1de
commit c29c1e6480
@@ -194,7 +194,7 @@ class GameEngineDrawOfferTest extends AnyFunSuite with Matchers:
case other => case other =>
fail(s"Expected InvalidMoveEvent, but got $other") fail(s"Expected InvalidMoveEvent, but got $other")
test("Draw offer is cleared when game ends by resignation"): test("Draw offer is cleared when game ends by resignation (accept)"):
val engine = new GameEngine() val engine = new GameEngine()
val observer = new DrawOfferMockObserver() val observer = new DrawOfferMockObserver()
engine.subscribe(observer) engine.subscribe(observer)
@@ -214,6 +214,26 @@ class GameEngineDrawOfferTest extends AnyFunSuite with Matchers:
case other => case other =>
fail(s"Expected InvalidMoveEvent, but got $other") fail(s"Expected InvalidMoveEvent, but got $other")
test("Draw offer is cleared when game ends by resignation"):
val engine = new GameEngine()
val observer = new DrawOfferMockObserver()
engine.subscribe(observer)
engine.offerDraw(Color.White)
observer.events.clear()
engine.resign(Color.Black)
// Try to accept the now-cleared draw offer
observer.events.clear()
engine.declineDraw(Color.White)
observer.events should have length 1
observer.events.head match
case event: InvalidMoveEvent =>
event.reason shouldBe InvalidMoveReason.GameAlreadyOver
case other =>
fail(s"Expected InvalidMoveEvent, but got $other")
private class DrawOfferMockObserver extends Observer: private class DrawOfferMockObserver extends Observer:
val events = mutable.ListBuffer[GameEvent]() val events = mutable.ListBuffer[GameEvent]()