Skip to content

Commit

Permalink
Increase test coverage, test Commands
Browse files Browse the repository at this point in the history
  • Loading branch information
patzly committed Jan 22, 2024
1 parent 73cf28f commit cc94eca
Show file tree
Hide file tree
Showing 29 changed files with 338 additions and 209 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ lazy val root = project

scalaVersion := "3.3.1",

libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.16",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.15" % "test",
libraryDependencies += "org.scalatestplus" %% "mockito-5-8" % "3.2.17.0" % "test",
libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "3.0.0",
libraryDependencies += "net.codingwell" %% "scala-guice" % "7.0.0",
libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "2.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package de.htwg.se.set.controller.controller.base

import de.htwg.se.set.controller.{ICommand, IController}
import de.htwg.se.set.model.GameMode.{GAME_END, IN_GAME, SETTINGS}
import de.htwg.se.set.model.game.base.{Deck, Player, Triplet}
import de.htwg.se.set.model.game.{Deck, Player, Triplet}
import de.htwg.se.set.model.{ICard, ITriplet}
import de.htwg.se.set.util.PrintUtil
import play.api.libs.json.{JsValue, Json}

import scala.xml.{Node, Utility}

private class Command(controller: IController) extends ICommand(controller):
class Command(controller: IController) extends ICommand(controller):

private var snapshot: Option[Snapshot] = None

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.htwg.se.set.controller.controller.base

import de.htwg.se.set.controller.{IController, ISnapshot, IState}
import de.htwg.se.set.model.game.base.Game
import de.htwg.se.set.model.settings.base.Settings
import de.htwg.se.set.model.game.Game
import de.htwg.se.set.model.settings.Settings
import de.htwg.se.set.model.{IGame, ISettings}
import play.api.libs.json.{JsValue, Json}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.htwg.se.set.model.game.base
package de.htwg.se.set.model.game

import de.htwg.se.set.model.{Color, ICard, Shading, Symbol}
import de.htwg.se.set.util.PrintUtil
import play.api.libs.json.{JsError, JsSuccess, JsValue, Json, Reads, Writes}
import play.api.libs.json.*

import scala.xml.{Elem, Node}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.htwg.se.set.model.game.base
package de.htwg.se.set.model.game

import com.google.inject.Inject
import com.google.inject.name.Named
import de.htwg.se.set.model.{Color, ICard, IDeck, ITriplet, Shading, Symbol}
import play.api.libs.json.{JsError, JsObject, JsResult, JsSuccess, JsValue, Json, OWrites, Reads, Writes}
import play.api.libs.json.*

import scala.util.Random
import scala.xml.{Elem, Node}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.htwg.se.set.model.game.base
package de.htwg.se.set.model.game

import com.google.inject.Inject
import com.google.inject.name.Named
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.htwg.se.set.model.game.base
package de.htwg.se.set.model.game

import de.htwg.se.set.model.{ICard, IGrid}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.htwg.se.set.model.game.base
package de.htwg.se.set.model.game

import de.htwg.se.set.model.{IPlayer, ITriplet}
import de.htwg.se.set.util.PrintUtil
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.htwg.se.set.model.game.base
package de.htwg.se.set.model.game

import de.htwg.se.set.model.{ICard, ITriplet}
import play.api.libs.json.{JsValue, Json, Reads, Writes}
Expand Down
41 changes: 0 additions & 41 deletions src/main/scala/de/htwg/se/set/model/game/stub/GameStub.scala

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.htwg.se.set.model.settings.base
package de.htwg.se.set.model.settings

import com.google.inject.Inject
import com.google.inject.name.Named
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/scala/de/htwg/se/set/module/SetModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import com.google.inject.AbstractModule
import com.google.inject.name.Names
import de.htwg.se.set.controller.IController
import de.htwg.se.set.controller.controller.base.Controller
import de.htwg.se.set.model.game.base.{Deck, Game}
import de.htwg.se.set.model.settings.base.Settings
import de.htwg.se.set.model.game.{Deck, Game}
import de.htwg.se.set.model.settings.Settings
import de.htwg.se.set.model.{GameMode, ICard, IDeck, IGame, IPlayer, ISettings}
import net.codingwell.scalaguice.ScalaModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package de.htwg.se.set.view.panel

import de.htwg.se.set.controller.IController
import de.htwg.se.set.controller.controller.base.SelectPlayerAction
import de.htwg.se.set.model.game.base.Player
import de.htwg.se.set.model.game.Player
import de.htwg.se.set.util.PanelUtil.CompatButton
import de.htwg.se.set.util.ResUtil

Expand Down
22 changes: 22 additions & 0 deletions src/test/resources/invalid_progress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"hash" : "91bea172a951eb0652bae3f59ac4e83ff7a7dc45928daa37469beb3890200447",
"snapshot" : {
"settings" : {
"playerCount" : 2,
"easy" : false,
"mode" : "SETTINGS"
},
"game" : {
"columns" : 4,
"deck" : {
"easy" : false
},
"tableCards" : [ ],
"playersCards" : [ ],
"players" : [ ],
"selectedPlayer" : null,
"message" : ""
},
"state" : "SettingsState"
}
}
23 changes: 23 additions & 0 deletions src/test/resources/invalid_progress.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version='1.0' encoding='UTF-8'?>
<progress>
<hash>8bd0d93049a8bb327db6fcdc580ede81361d89447df96afb655297fe1a18b0d7</hash>
<snapshot>
<settings>
<playerCount>2</playerCount>
<easy>false</easy>
<mode>SETTINGS</mode>
</settings>
<game>
<columns>4</columns>
<deck>
<easy>false</easy>
</deck>
<tableCards/>
<playersCards/>
<players/>
<selectedPlayer/>
<message/>
</game>
<state>SettingsState</state>
</snapshot>
</progress>
22 changes: 22 additions & 0 deletions src/test/resources/valid_progress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"hash" : "91bea172a951eb0652bae3f59ac4e83ff7a7dc45928daa37469beb3890200447",
"snapshot" : {
"settings" : {
"playerCount" : 1,
"easy" : false,
"mode" : "SETTINGS"
},
"game" : {
"columns" : 4,
"deck" : {
"easy" : false
},
"tableCards" : [ ],
"playersCards" : [ ],
"players" : [ ],
"selectedPlayer" : null,
"message" : ""
},
"state" : "SettingsState"
}
}
23 changes: 23 additions & 0 deletions src/test/resources/valid_progress.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version='1.0' encoding='UTF-8'?>
<progress>
<hash>8bd0d93049a8bb327db6fcdc580ede81361d89447df96afb655297fe1a18b0d7</hash>
<snapshot>
<settings>
<playerCount>1</playerCount>
<easy>false</easy>
<mode>SETTINGS</mode>
</settings>
<game>
<columns>4</columns>
<deck>
<easy>false</easy>
</deck>
<tableCards/>
<playersCards/>
<players/>
<selectedPlayer/>
<message/>
</game>
<state>SettingsState</state>
</snapshot>
</progress>
Loading

0 comments on commit cc94eca

Please sign in to comment.