Created
November 28, 2011 00:06
-
-
Save agnaldo4j/1398517 to your computer and use it in GitHub Desktop.
Utilizando BDD tentando não aumentar a complexibilidade.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.softsimples.persistence | |
import mongodb.DataWrapperMongoDB | |
import org.specs2.mutable._ | |
import org.junit.runner._ | |
import org.specs2.runner._ | |
@RunWith(classOf[JUnitRunner]) | |
class DataWrapperMongoDBSpec extends Specification { | |
"Para executar persistencia com mongodb" should { | |
"Criar dataWrapper para base test e collection test" in datawrapper().connect | |
"dataWrapper deve salvar um JSON simples" in datawrapper().save | |
"dataWrapper deve buscar todos JSONs salvos" in datawrapper().findAll | |
"dataWrapper deve saber excluir todos JSONs salvos" in datawrapper().deleteAll | |
} | |
case class datawrapper() { | |
val dataWrapper = DataWrapperMongoDB.buildDBWrapper("test", "test") | |
def connect = dataWrapper must not beNull | |
def save = dataWrapper.save(json) get("_id") must not beEmpty | |
private def json: Map[String, Any] = Map[String, Any]("teste" -> "novo teste", "teste2" -> "novo teste2") | |
def findAll = dataWrapper.findAll() must have size 1 | |
def deleteAll = { | |
val array = dataWrapper.findAll() | |
array must have size 1 | |
for (cada <- array) dataWrapper.remove( cada ) | |
dataWrapper.findAll() must have size 0 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment