Skip to content

Commit

Permalink
Testing Guice module now
Browse files Browse the repository at this point in the history
  • Loading branch information
NotLe0n committed Dec 30, 2023
1 parent a1aa445 commit 76c8dc1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/test/scala/de/htwg/se/minesweeper/MinesweeperModuleSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package de.htwg.se.minesweeper

import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import com.google.inject.{Guice, Injector}
import de.htwg.se.minesweeper.controller.ControllerInterface
import de.htwg.se.minesweeper.controller.baseController.BaseController
import de.htwg.se.minesweeper.model.fieldComponent.FieldFactory
import de.htwg.se.minesweeper.model.fieldComponent.field.RandomFieldFactory

class MinesweeperModuleSpec extends AnyWordSpec with Matchers {
"A MinesweeperModule" should {
"configure Guice bindings" in {
val injector: Injector = Guice.createInjector(new MinesweeperModule)

// Test the binding for FieldFactory
val fieldFactory: FieldFactory = injector.getInstance(classOf[FieldFactory])
fieldFactory shouldBe a[RandomFieldFactory]

// Test the binding for ControllerInterface
val controller: ControllerInterface = injector.getInstance(classOf[ControllerInterface])
controller shouldBe a[BaseController]
}
}
}

0 comments on commit 76c8dc1

Please # to comment.