• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala OneAppPerSuite类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中org.scalatestplus.play.OneAppPerSuite的典型用法代码示例。如果您正苦于以下问题:Scala OneAppPerSuite类的具体用法?Scala OneAppPerSuite怎么用?Scala OneAppPerSuite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了OneAppPerSuite类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: givenCleanMetricRegistry

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.agentmapping.support

import com.codahale.metrics.MetricRegistry
import com.kenshoo.play.metrics.Metrics
import org.scalatest.Matchers
import org.scalatestplus.play.OneAppPerSuite

import scala.collection.JavaConversions

trait MetricTestSupport {
  self: OneAppPerSuite with Matchers =>

  private var metricsRegistry: MetricRegistry = _

  def givenCleanMetricRegistry(): Unit = {
    val registry = app.injector.instanceOf[Metrics].defaultRegistry
    for (metric <- JavaConversions.asScalaIterator[String](registry.getMetrics.keySet().iterator())) {
      registry.remove(metric)
    }
    metricsRegistry = registry
  }

  def timerShouldExistsAndBeenUpdated(metric: String): Unit = {
    metricsRegistry.getTimers.get(s"Timer-$metric").getCount should be >= 1L
  }

} 
开发者ID:hmrc,项目名称:agent-mapping,代码行数:28,代码来源:MetricTestSupport.scala


示例2: givenCleanMetricRegistry

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.agentaccesscontrol.support

import com.codahale.metrics.MetricRegistry
import com.kenshoo.play.metrics.Metrics
import org.scalatest.Matchers
import org.scalatestplus.play.OneAppPerSuite

import scala.collection.JavaConversions

trait MetricTestSupport {
  self: OneAppPerSuite with Matchers =>

  private var metricsRegistry: MetricRegistry = _

  def givenCleanMetricRegistry(): Unit = {
    val registry = app.injector.instanceOf[Metrics].defaultRegistry
    for (metric <- JavaConversions.asScalaIterator[String](registry.getMetrics.keySet().iterator())) {
      registry.remove(metric)
    }
    metricsRegistry = registry
  }

  def timerShouldExistsAndBeenUpdated(metric: String): Unit = {
    metricsRegistry.getTimers.get(s"Timer-$metric").getCount should be >= 1L
  }

} 
开发者ID:hmrc,项目名称:agent-access-control,代码行数:28,代码来源:MetricTestSupport.scala


示例3: HomePageControllerSpec

//设置package包名称以及导入依赖的类
package controllers

import org.scalatestplus.play.{OneAppPerSuite, PlaySpec}
import play.api.test.FakeRequest
import play.api.test.Helpers._



class HomePageControllerSpec extends PlaySpec with OneAppPerSuite {

  //TODO: Need to define TimeGreetingService

  object TestHomeControllerTest extends HomeController {
    override def greeter = ???
  }
  val controller = TestHomeControllerTest

  "HomeController" should {
    "not return 404" when {
      "I go to the route /landing" in {
        val result = route(app, FakeRequest(GET, "/landing"))
        status(result.get) must not be NOT_FOUND
      }
    }

    "render the correct page with the expected text" when {
      "I navigate to the homepage" in {
        val result = controller.landing("Good morning Helen").apply(FakeRequest(GET, "/landing"))

        status(result) mustBe OK
        contentAsString(result) must include ("Good morning Helen")
        //arrange
        //action
        //assert
      }
      "I go to the homepage after lunch" in {
        val result = controller.landing("Good afternoon Helen").apply(FakeRequest(GET, "/landing"))

        contentAsString(result) must include ("Good afternoon Helen")
      }
    }
  }
} 
开发者ID:Hejocaso,项目名称:LunchApp,代码行数:44,代码来源:HomePageControllerSpec.scala


示例4: BreakfastAppControllerSpec

//设置package包名称以及导入依赖的类
package controllers

import org.scalatestplus.play.{OneAppPerSuite, PlaySpec}
import play.api.mvc.Result
import play.api.test.FakeRequest
import play.api.test.Helpers._

import scala.concurrent.Future

class BreakfastAppControllerSpec extends PlaySpec with OneAppPerSuite {
  "BreakfastAppController" should {
    "not return 404" when {
      "we try to hit the route /home" in {
        route(app, FakeRequest(GET, "/home")).map(status(_)) must not be Some(NOT_FOUND)
      }
    }
    "reneder a page" when {
      "we try to hit the route /home" in {
        var result: Option[Future[Result]] = route(app, FakeRequest(GET, "/home"))

        result.map(status(_)) mustBe Some(OK)

        val text: String = result.map(contentAsString(_)).get
        text must include ("Welcome to Play")
      }
    }
  }
} 
开发者ID:Hejocaso,项目名称:LunchApp,代码行数:29,代码来源:BreakfastAppControllerSpec.scala


示例5: AddressDetailsControllerTest

//设置package包名称以及导入依赖的类
package controllers

import address.AddressReputationService
import akka.actor.ActorSystem
import akka.stream.{ActorMaterializer, Materializer}
import model.AddressDetails
import org.mockito.Matchers.any
import org.mockito.Mockito._
import org.scalatest.mock.MockitoSugar
import org.scalatestplus.play.{OneAppPerSuite, PlaySpec}
import play.api.libs.json.Reads
import play.api.mvc.Security
import play.api.test.FakeRequest
import play.api.test.Helpers._
import uk.gov.hmrc.http.cache.client.SessionCache
import uk.gov.hmrc.play.http.HeaderCarrier

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future


class AddressDetailsControllerTest extends PlaySpec with MockitoSugar with OneAppPerSuite {

  trait action {
    val cache = mock[SessionCache]
    val ars = mock[AddressReputationService]
    val controller = new AddressDetailsController(ars, cache)
    val req = FakeRequest().withSession(Security.username -> "user")
    val buildingNumber = "25"
    val buildingName = "Starship Enterprise"
    val street = "Waterloo Road"
    val town = "Darlington"
    val postcode = "DL3 5BD"
    val ad = AddressDetails(Some(buildingNumber), Some(buildingName), Some(street), Some(town), postcode)
    implicit val system = ActorSystem("Test")
    implicit def mat: Materializer = ActorMaterializer()
  }

  "get" should {

    "return completed form" in new action {
      // test that when the cache contains address details, we display filled-out form
      when(cache.fetchAndGetEntry[AddressDetails](any[String])(any[HeaderCarrier], any[Reads[AddressDetails]])).thenReturn(Future(Some(ad)))
      val res = call(controller.get(), req)
      status(res) must be(303)
    }

  }

} 
开发者ID:hmrc,项目名称:bank-account-reputation-frontend,代码行数:51,代码来源:AddressDetailsControllerTest.scala


示例6: CatDAOSpec

//设置package包名称以及导入依赖的类
package dao

import models.Cat
import org.scalatest._
import org.scalatestplus.play.{OneAppPerSuite, PlaySpec}
import play.api.Application
import play.api.inject.guice.GuiceApplicationBuilder

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}

class CatDAOSpec extends PlaySpec
    with WordSpecLike
    with OneAppPerSuite {

  implicit override lazy val app = {
    new GuiceApplicationBuilder().configure(
      Map(
        "slick.dbs.animaldb.driver" -> "slick.driver.H2Driver$",
        "slick.dbs.animaldb.db.driver" -> "org.h2.Driver",
        "slick.dbs.animaldb.db.url" -> "jdbc:h2:mem:animaldb;DATABASE_TO_UPPER=false",
        "slick.dbs.animaldb.db.user" -> "sa",
        "slick.dbs.animaldb.db.password" -> "",
        "play.evolutions.db.animaldb.enabled" -> true,
        "play.evolutions.db.animaldb.autoApply" -> true
      )
    ).build()
  }

  "CatDAO" should {
    "work as expected" in {
      val app2dao = Application.instanceCache[CatDAO]
      val dao: CatDAO = app2dao(app)

      val testKitties = Set(
        Cat("kit", "black"),
        Cat("garfield", "orange"),
        Cat("creme puff", "grey")
      )

      Await.result(Future.sequence(testKitties.map(dao.insert)), 1 seconds)
      val storedCats = Await.result(dao.all(), 1 seconds).toVector

      storedCats.sortBy(_.name) mustBe testKitties.toVector.sortBy(_.name)
    }
  }

} 
开发者ID:kpmeen,项目名称:play-slick-pgsql,代码行数:50,代码来源:CatDAOSpec.scala


示例7: ApplicationSpec

//设置package包名称以及导入依赖的类
package controllers

import org.scalatest.WordSpecLike
import org.scalatestplus.play.{OneAppPerSuite, PlaySpec}
import play.api.inject.guice.GuiceApplicationBuilder
import play.api.libs.json.Json
import play.api.test.Helpers._
import play.api.test._

class ApplicationSpec extends PlaySpec with OneAppPerSuite with WordSpecLike {

  implicit override lazy val app = {
    new GuiceApplicationBuilder().configure(
      Map(
        "slick.dbs.animaldb.driver" -> "slick.driver.H2Driver$",
        "slick.dbs.animaldb.db.driver" -> "org.h2.Driver",
        "slick.dbs.animaldb.db.url" -> "jdbc:h2:mem:animaldb;DATABASE_TO_UPPER=false",
        "slick.dbs.animaldb.db.user" -> "sa",
        "slick.dbs.animaldb.db.password" -> "",
        "play.evolutions.db.animaldb.enabled" -> true,
        "play.evolutions.db.animaldb.autoApply" -> true
      )
    ).build()
  }

  "Application" should {

    "render the index page" in {

      val kitty = Json.obj("name" -> "Scarlett", "color" -> "Black & White")
      val postRequest = FakeRequest(
        method = "POST",
        uri = "/cat/insert",
        headers = FakeHeaders(
          Seq("Content-type" -> "application/json")
        ),
        body = kitty
      )
      val Some(result) = route(postRequest)
      status(result) mustBe OK

      val home = route(FakeRequest(GET, "/")).get

      status(home) mustBe OK
      contentType(home) mustBe Some("application/json")
      contentAsString(home) must include("Scarlett")
    }
  }
} 
开发者ID:kpmeen,项目名称:play-slick-pgsql,代码行数:50,代码来源:ApplicationSpec.scala


示例8: ProductSpec

//设置package包名称以及导入依赖的类
import com.google.common.collect.ImmutableMap
import models.ProductService
import org.scalatestplus.play.{OneAppPerSuite, PlaySpec}
import play.api.db.Databases
import play.db.Database

class ProductSpec extends PlaySpec with OneAppPerSuite {

  var productService: ProductService = app.injector.instanceOf(classOf[ProductService])



  Databases.withDatabase(
    driver = "com.mysql.jdbc.Driver",
    url = "jdbc:mysql://localhost/playtest",
    config = Map(
      "user" -> "play",
      "password" -> "demo"
    )
  ) { database =>
    import play.api.db.evolutions._
    Evolutions.applyEvolutions(database)

    "Product" should {
      "be retrieved by Id" in {
        val product = productService.get(23)

        product.get.name must equal("test")
      }
    }
  }

} 
开发者ID:sureshpck,项目名称:foo-scala,代码行数:34,代码来源:ProductSpec.scala


示例9: newAppForTest

//设置package包名称以及导入依赖的类
import org.scalatest.{Suite, TestData}
import org.scalatestplus.play.{OneAppPerSuite, OneAppPerTest, OneServerPerSuite, OneServerPerTest}
import play.api.{BuiltInComponents, _}

trait OneAppPerTestWithComponents[T <: BuiltInComponents]
  extends OneAppPerTest
    with WithApplicationComponents[T] {
  this: Suite =>

  override def newAppForTest(testData: TestData): Application = newApplication
}

trait OneAppPerSuiteWithComponents[T <: BuiltInComponents]
  extends OneAppPerSuite
    with WithApplicationComponents[T] {
  this: Suite =>
  override implicit lazy val app: Application = newApplication
}

trait OneServerPerTestWithComponents[T <: BuiltInComponents]
  extends OneServerPerTest
    with WithApplicationComponents[T] {
  this: Suite =>

  override def newAppForTest(testData: TestData): Application = newApplication
}

trait OneServerPerSuiteWithComponents[T <: BuiltInComponents]
  extends OneServerPerSuite
    with WithApplicationComponents[T] {
  this: Suite =>

  override implicit lazy val app: Application = newApplication
} 
开发者ID:wsargent,项目名称:play-cucumber,代码行数:35,代码来源:ScalaTestWithComponents.scala


示例10: IntegrationSpec

//设置package包名称以及导入依赖的类
import org.scalatestplus.play.OneAppPerSuite
import org.scalatestplus.play.PlaySpec

import play.api.libs.json.Json
import play.api.test._
import play.api.test.Helpers._
import testdata._


class IntegrationSpec extends PlaySpec with OneAppPerSuite with IntegrationSuiteMixin {

  "Application" should {

    "get closest locations from twitter" in {
      val locationsUrl = s"/locations/$latitude/$longitude"
      val Some(result) = route(FakeRequest(GET, locationsUrl))

      status(result) must be(OK)
      contentType(result) must be(Some("application/json"))
      contentAsJson(result) must be(Json.toJson(closetLocationsHavingTrends))
      verifyBearerTokenCall()
    }
  }
  
  "get trends for a place" in {
    val trendsUrl = s"/trends/$woeid"
    val Some(result) = route(FakeRequest(GET, trendsUrl))
    
    status(result) must be(OK)
    contentType(result) must be(Some("application/json"))
    contentAsJson(result) must be(Json.toJson(trendsList))
    verifyBearerTokenCall()
  }

  override implicit lazy val app: FakeApplication = FakeApplication(
    additionalConfiguration = Map(
      "twitter.api.url" -> s"http://$host:$wireMockPort",
      "twitter.consumer.key" -> twitterConsumerKey,
      "twitter.consumer.secret" -> twitterConsumerSecret))
} 
开发者ID:adi3009,项目名称:trendy-maps,代码行数:41,代码来源:IntegrationSpec.scala


示例11: BreakfastAppControllerSpec

//设置package包名称以及导入依赖的类
package controllers

import org.scalatestplus.play.{OneAppPerSuite, PlaySpec}
import play.api.mvc.Result
import play.api.test.FakeRequest
import play.api.test.Helpers._

import scala.concurrent.Future


class BreakfastAppControllerSpec extends PlaySpec with OneAppPerSuite {

  "BreakfastAppController" should {
    "not return 404" when {
      "we try to hit the route /home" in {
        route(app, FakeRequest(GET, "/home")).map(status(_)) must not be Some(NOT_FOUND)
      }
    }
    "render a page" when {
      "we try to hit the route /home" in {
        val result: Option[Future[Result]] = route(app, FakeRequest(GET, "/home"))

        result.map(status(_)) mustBe Some(OK)

        val text: String = result.map(contentAsString(_)).get

        text must include ("Welcome to Play")
      }
    }
  }

} 
开发者ID:rosswilkinson,项目名称:breakfast-club-new,代码行数:33,代码来源:BreakfastAppControllerSpec.scala


示例12: EncryptionServiceSpec

//设置package包名称以及导入依赖的类
package services.auth

import config.ApplicationConfig
import helpers.TestSpec
import org.scalatestplus.play.OneAppPerSuite


class EncryptionServiceSpec extends TestSpec with OneAppPerSuite {

  lazy val config: ApplicationConfig = app.injector.instanceOf[ApplicationConfig]
  lazy val service = new EncryptionService(config)

  "Calling .encrypt" should {
    lazy val result = service.encrypt("testData")

    "return a map" which {

      "contains a nonce of size 64" in {
        result("nonce").length shouldBe 64
      }

      "contains a value of size 32" in {
        result("value").length shouldBe 32
      }
    }
  }

  "Calling .decrypt" should {
    val map = Map(
      "nonce" -> "a954bf74662060335285a4b482055ef8b9b38eeee1808f97ea7602fcde77b2ed",
      "value" -> "33b8c73001f82ca28f3e26e1af1db245"
    )
    lazy val result = service.decrypt(map)

    "return a string of 'testData'" in {
      result shouldBe "testData"
    }
  }
} 
开发者ID:jameshforster,项目名称:OverVerse,代码行数:40,代码来源:EncryptionServiceSpec.scala


示例13: AdminServiceSpec

//设置package包名称以及导入依赖的类
package services

import connectors.MongoConnector
import helpers.TestSpec
import models.coordinates.SectorCoordinateModel
import models.universe.{SectorModel, UniverseModel}
import org.mockito.ArgumentMatchers
import org.scalatestplus.play.OneAppPerSuite
import org.mockito.Mockito._

import scala.concurrent.Future


class AdminServiceSpec extends TestSpec with OneAppPerSuite {

  def setupService(inputResponse: Future[Unit]): AdminService = {
    val mockConnector = mock[MongoConnector]

    when(mockConnector.putEntry(ArgumentMatchers.any(), ArgumentMatchers.any())(ArgumentMatchers.any()))
      .thenReturn(inputResponse)

    new AdminService(mockConnector)
  }

  "Calling .storeUniverse" when {
    val universeModel = UniverseModel(Seq(SectorModel(SectorCoordinateModel(0, 0), Seq()), SectorModel(SectorCoordinateModel(0, 1), Seq())))

    "an error is returned from the connector" should {
      lazy val service = setupService(Future.failed(new Exception("error message")))
      lazy val result = service.storeUniverse("test", universeModel)

      "return the correct error message" in {
        lazy val exception = intercept[Exception](await(result))

        exception.getMessage shouldBe "error message"
      }
    }

    "a success is returned from the connector" should {
      lazy val service = setupService(Future.successful({}))
      lazy val result = service.storeUniverse("test", universeModel)

      "return a Unit" in {
        await(result).isInstanceOf[Unit] shouldBe true
      }
    }
  }
} 
开发者ID:jameshforster,项目名称:OverVerse,代码行数:49,代码来源:AdminServiceSpec.scala


示例14: CandidatesRepoSpec

//设置package包名称以及导入依赖的类
package repos

import db.MongoConnectivity
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.{BeforeAndAfter, Matchers, WordSpec}
import org.scalatestplus.play.OneAppPerSuite
import support.Mongo

class CandidatesRepoSpec extends WordSpec with Matchers with BeforeAndAfter with ScalaFutures with OneAppPerSuite {

  val mongoConnectivity = new MongoConnectivity(app.configuration)
  val repo = new CandidatesRepo(mongoConnectivity)

  val scala = Candidate("scala", "Scala", "The Scala Language", "2.12.0", "http://www.scala-lang.org/", "UNIVERSAL")
  val groovy = Candidate("groovy", "Groovy", "The Groovy Language", "2.4.7", "http://www.groovy-lang.org/", "UNIVERSAL")
  val java = Candidate("java", "Java", "The Java Language", "8u111", "https://www.oracle.com", "MULTI_PLATFORM")

  "candidates repository" should {

    "find all candidates regardless of distribution" in {
      whenReady(repo.findAllCandidates()) { candidates =>
        candidates.size shouldBe 3
        candidates should contain(scala)
        candidates should contain(groovy)
        candidates should contain(java)
      }
    }

    "find candidates in alphabetically sorted order" in {
      whenReady(repo.findAllCandidates()) { candidates =>
        candidates.size shouldBe 3
        candidates(0) shouldBe groovy
        candidates(1) shouldBe java
        candidates(2) shouldBe scala
      }
    }

    "find some single candidate when searching by know candidate identifier" in {
      val candidate = "java"
      whenReady(repo.findByIdentifier(candidate)) { maybeCandidate =>
        maybeCandidate shouldBe defined
        maybeCandidate.foreach(_.candidate shouldBe candidate)
      }
    }

    "find none when searching by unknown candidate identifier" in {
      val candidate = "scoobeedoo"
      whenReady(repo.findByIdentifier(candidate)) { maybeCandidate =>
        maybeCandidate shouldNot be(defined)
      }
    }
  }

  before {
    Mongo.dropAllCollections()
    Mongo.insertCandidates(Seq(scala, groovy, java))
  }

} 
开发者ID:sdkman,项目名称:sdkman-candidates,代码行数:60,代码来源:CandidatesRepoSpec.scala


示例15: MailerControllerIntegration

//设置package包名称以及导入依赖的类
package integration

import mocks.{MailServiceMock, AuthServiceMock, Samples}
import models.Formatters._
import org.scalatestplus.play.OneAppPerSuite
import play.api.Application
import play.api.inject.bind
import play.api.libs.json.Json
import play.api.test.FakeRequest
import play.api.test.Helpers._
import services.{AuthService, MailService}
import traits.TestBuilder


class MailerControllerIntegration extends TestBuilder with OneAppPerSuite {
  implicit override lazy val app: Application = builder
    .overrides(bind[AuthService].to[AuthServiceMock])
    .overrides(bind[MailService].to[MailServiceMock])
    .build()

  it should "not send email without authorization" in {
    val request = FakeRequest(POST, "/send")
      .withJsonBody(Json.toJson(Samples.sendmailAction.copy(auth = AuthServiceMock.invalidBulkEmailAuth)))

    val response = route(app, request).get

    status(response) shouldBe FORBIDDEN
  }

  it should "send email with authorization" in {
    val request = FakeRequest(POST, "/send")
      .withJsonBody(Json.toJson(Samples.sendmailAction.copy(auth = AuthServiceMock.validBulkEmailAuth)))

    val response = route(app, request).get

    status(response) shouldBe OK
  }

} 
开发者ID:waveinch,项目名称:ses-transactional,代码行数:40,代码来源:MailerControllerIntegration.scala


示例16: ApplicationSpec

//设置package包名称以及导入依赖的类
import org.scalatestplus.play.{OneAppPerSuite, PlaySpec}
import play.api.libs.json.JsArray
import play.api.test.Helpers._
import play.api.test._


//@RunWith(classOf[JUnitRunner])
class ApplicationSpec extends PlaySpec with OneAppPerSuite  {
  implicit override lazy val app = new FakeApplication(additionalConfiguration = Map(("minimumSupport","0")))

//  sequential
  "Application" must {

      "send 404 on a bad request" in {
          route(FakeRequest(GET, "/boum"))
      }

      "search for product " in {

          val search = route(FakeRequest(GET, "/products/search/ICE")).get
          status(search) mustBe OK
          contentType(search) mustBe Some("application/json")
          contentAsString(search) must include("ICE")

      }

      "render the index page" in {
        val home = route(FakeRequest(GET, "/")).get

        status(home) mustBe OK
        contentType(home) mustBe Some("text/html")
        contentAsString(home) must include( "Your new application is ready.")
      }

      "post transactions " in {
        val header: FakeHeaders = FakeHeaders(Seq(("Content-Type", "application/json")))
        val trx = route(FakeRequest(POST, "/transactions", header, "[[\"p1\", \"p2\",\"p3\"],[\"p2\",\"p3\",\"p4\"]]")).get
        status(trx) mustBe OK
      }
      "trigger processing " in {
        val trx = route(FakeRequest(POST, "/updateScore")).get
        status(trx) mustBe OK
      }
      "zget asoociation reco " in {
        Thread.sleep(20000) //TODO any better way to test async processing?
        val req = route(FakeRequest(GET, "/products/p2")).get
        status(req) mustBe OK
        println(contentAsString(req))
        val products: JsArray = contentAsJson(req).as[JsArray]
        products.value.length must be > 0
      }

  }
} 
开发者ID:srihari,项目名称:recommendr,代码行数:55,代码来源:ApplicationSpec.scala


示例17: HolidayDataSpec

//设置package包名称以及导入依赖的类
package controllers

import models.{remainingHoliday, HolidayData}
import org.scalatestplus.play.{OneAppPerSuite, PlaySpec}


class HolidayDataSpec extends PlaySpec with OneAppPerSuite {

  "holidayRemaining" must {
    "return the number of holidays remaining" when {
      "given a valid name" in {
        HolidayData.holidayRemaining("Bob") mustBe 3
        HolidayData.holidayRemaining("Nicole") mustBe 10
      }
    }
  }

  "parseHolidayCsv" must {
    "return all the data from the csv file" in {
      HolidayData.parseHolidayCsv mustBe List(
        remainingHoliday("Nicole",10),
        remainingHoliday("Bob",3),
        remainingHoliday("Darwin",12),
        remainingHoliday("Elfriede",16),
        remainingHoliday("Candace",19),
        remainingHoliday("Estela",4),
        remainingHoliday("Marty",6),
        remainingHoliday("Bonnie",8),
        remainingHoliday("Dewey",23),
        remainingHoliday("Corrie",21),
        remainingHoliday("Lora",15),
        remainingHoliday("Brianne",3))
    }
  }

  "checkName" must {
    "return true" when {
      "given a name which is in the data" in {
        HolidayData.checkName("Nicole") mustBe true
      }
    }
    "return false" when {
      "given a name which is not in the data" in {
        HolidayData.checkName("NoName") mustBe false
      }
      "given no name" in {
        HolidayData.checkName("") mustBe false
      }
    }
  }
} 
开发者ID:opencastsoftware,项目名称:holiday-tracker,代码行数:52,代码来源:HolidayDataSpec.scala


示例18: HolidayControllerSpec

//设置package包名称以及导入依赖的类
package controllers

import org.scalatestplus.play.{OneAppPerSuite, PlaySpec}
import play.api.mvc.Result
import play.api.test.FakeRequest
import play.api.test.Helpers._

import scala.concurrent.Future


class HolidayControllerSpec extends PlaySpec with OneAppPerSuite {

  "The Application controller" must {
    "respond with OK" when {
      "a valid GET request is made" in {
        val result: Future[Result] = HolidayController.index.apply(FakeRequest("GET", "/"))

        status(result) mustBe OK
        contentAsString(result) must include("Please enter your name")
      }
    }
  }

  "submit" must {
    "respond with OK" when {
      "given a name" in {
        val name = "Nicole"
        val result: Future[Result] = HolidayController.submit.apply(FakeRequest().withFormUrlEncodedBody("Name" -> name))

        status(result) mustBe OK
        contentAsString(result) must include("You have 10 days of holiday remaining!")
      }
    }
    "respond with BAD_REQUEST" when {
      "given no name" in {
        val result: Future[Result] = HolidayController.submit.apply(FakeRequest().withFormUrlEncodedBody("Name" -> ""))

        status(result) mustBe BAD_REQUEST
        contentAsString(result) must include("Required")
      }
      "given the name of someone who is not on the list" in {
        val result: Future[Result] = HolidayController.submit.apply(FakeRequest().withFormUrlEncodedBody("Name" -> ""))

        status(result) mustBe BAD_REQUEST
        contentAsString(result) must include("Required")
        contentAsString(result) must not include "Not an employee"
      }
    }
  }
} 
开发者ID:opencastsoftware,项目名称:holiday-tracker,代码行数:51,代码来源:HolidayControllerSpec.scala


示例19: waitForDb

//设置package包名称以及导入依赖的类
package testkit.util

import java.time.LocalDateTime

import org.scalatest.BeforeAndAfterAll
import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatestplus.play.{OneAppPerSuite, PlaySpec}
import play.api.inject.guice.GuiceApplicationBuilder
import play.api.{Application, Configuration, Mode}

trait CommonTest { self: OneAppPerSuite ?
  override implicit lazy val app: Application = new GuiceApplicationBuilder().in(Mode.Test).build()

  lazy val config = app.injector.instanceOf[Configuration].underlying
  lazy val jwtHeaderFieldName = config.getString("silhouette.authenticator.jwt.fieldName")
  lazy val waitForDbDuration = config.getDuration("testkit.wait-for-db").getNano / 1000000
  def waitForDb(): Unit =
    Thread.sleep(waitForDbDuration)
}

trait IntegrationTest extends PlaySpec with OneAppPerSuite with CommonTest
  with ScalaFutures with IntegrationPatience
  with BeforeAndAfterAll with PopulateDb with TestAuthDatabaseAccess with AuthSpecHelpers

// Not really unit as they require db, but access should be mocked out
trait UnitTest extends PlaySpec with OneAppPerSuite with CommonTest
  with ScalaFutures with IntegrationPatience with AuthSpecHelpers 
开发者ID:KadekM,项目名称:play-slick-silhouette-auth-api,代码行数:28,代码来源:CommonTestConfigurations.scala


示例20: CarCheckingServiceSpec

//设置package包名称以及导入依赖的类
package service

import infrastructure.CarCheckSpec
import org.scalatestplus.play.OneAppPerSuite
import services.CarCheckService

class CarCheckingServiceSpec extends CarCheckSpec with OneAppPerSuite {
  
  "findCar" should {
    "find an existing car" in {
      CarCheckService.findCar(testRegNumber, testMake, Some(testV5c)).futureValue shouldBe testCar
    }
  }

  "return NONE for non existing car" in {
    CarCheckService.findCar("SomeNumber", "SomeMake", Some(124l)).futureValue shouldBe None
  }

} 
开发者ID:OlegEfrem,项目名称:voa-check-car,代码行数:20,代码来源:CarCheckingServiceSpec.scala



注:本文中的org.scalatestplus.play.OneAppPerSuite类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala Graph类代码示例发布时间:2022-05-23
下一篇:
Scala Matrix类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap