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

Scala MustMatchers类代码示例

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

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



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

示例1: IssuesSpec

//设置package包名称以及导入依赖的类
package io.scalaland.chimney

import org.scalatest.{MustMatchers, WordSpec}
import shapeless.HNil

class IssuesSpec extends WordSpec with MustMatchers {

  import dsl._

  "IssuesSpec" should {

    "fix issue #19" in {
      case class NewEntity(name: String)
      case class Entity(id: Long, name: String, isDeleted: Boolean)

      NewEntity("name")
        .into[Entity]
        .withFieldConst('id, 0L)
        .withFieldConst('isDeleted, false)
        .transform mustBe
        Entity(0, "name", isDeleted = false)
    }

    "fix issue #21" in {
      import shapeless.tag
      import shapeless.tag._
      sealed trait Test

      case class EntityWithTag1(id: Long, name: String @@ Test)
      case class EntityWithTag2(name: String @@ Test)

      // This test doesn't work on 2.12+ due to:
      // https://github.com/milessabin/shapeless/pull/726
      // EntityWithTag1(0L, tag[Test]("name")).transformInto[EntityWithTag2] mustBe EntityWithTag2(tag[Test]("name"))
    }
  }

} 
开发者ID:scalalandio,项目名称:chimney,代码行数:39,代码来源:IssuesSpec.scala


示例2: ActionsTest

//设置package包名称以及导入依赖的类
package com.wegtam.amws.reports

import org.scalatest.{ MustMatchers, WordSpec }

class ActionsTest extends WordSpec with MustMatchers {

  "RequestReport" must {
    val a = Actions.RequestReport

    "provide toParameterValue" in {
      a.toParameterValue mustEqual "RequestReport"
    }
  }

  "GetReportRequestList" must {
    val a = Actions.GetReportRequestList

    "provide toParameterValue" in {
      a.toParameterValue mustEqual "GetReportRequestList"
    }
  }

  "GetReportList" must {
    val a = Actions.GetReportList

    "provide toParameterValue" in {
      a.toParameterValue mustEqual "GetReportList"
    }
  }
} 
开发者ID:wegtam,项目名称:amws-scala,代码行数:31,代码来源:ActionsTest.scala


示例3: RegionsTest

//设置package包名称以及导入依赖的类
package com.wegtam.amws.common

import java.net.URI

import com.wegtam.amws.common.MarketPlaces._
import com.wegtam.amws.common.Regions._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{ MustMatchers, WordSpec }

import scala.collection.immutable.Seq

class RegionsTest extends WordSpec with MustMatchers with PropertyChecks {
  private final val expectedEndpoints = Table(
    ("Region", "Endpoint"),
    (NorthAmerica, new URI("https://mws.amazonservices.com")),
    (Brazil, new URI("https://mws.amazonservices.com")),
    (Europe, new URI("https://mws-eu.amazonservices.com")),
    (India, new URI("https://mws.amazonservices.in")),
    (China, new URI("https://mws.amazonservices.com.cn")),
    (Japan, new URI("https://mws.amazonservices.jp"))
  )
  private final val expectedMarketplaces = Table(
    ("Region", "Marketplaces"),
    (NorthAmerica, Seq(CA, MX, US)),
    (Brazil, Seq(BR)),
    (Europe, Seq(DE, ES, FR, IT, UK)),
    (India, Seq(IN)),
    (China, Seq(CN)),
    (Japan, Seq(JP))
  )

  "endpoint" must {
    "return the correct region endpoint" in {
      forAll(expectedEndpoints) { (r: Region, u: URI) =>
        r.endPoint mustEqual u
      }
    }
  }

  "marketPlaces" must {
    "return the correct marketplaces for the region" in {
      forAll(expectedMarketplaces) { (r: Region, mps: Seq[MarketPlace]) =>
        r.marketPlaces mustEqual mps
      }
    }
  }

} 
开发者ID:wegtam,项目名称:amws-scala,代码行数:49,代码来源:RegionsTest.scala


示例4: AbstractSpec

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

import actors.Receptionist
import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit}
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, MustMatchers}

class AbstractSpec extends TestKit(ActorSystem("test-system"))
  with FlatSpecLike
  with ImplicitSender
  with BeforeAndAfterAll
  with MustMatchers {

  val receptionist = system.actorOf(Receptionist.props(), "receptionist")


  override def afterAll = {
    TestKit.shutdownActorSystem(system)
  }

} 
开发者ID:Sengab-platform,项目名称:backend,代码行数:22,代码来源:AbstractSpec.scala


示例5: ExistentialPrerequisitesSpec

//设置package包名称以及导入依赖的类
package com.example.catfood.existentials

import org.scalatest.{ FreeSpec, MustMatchers }

class ExistentialPrerequisitesSpec extends FreeSpec with MustMatchers {

  "must work a as a type erasure" in {

    trait Existential {
      type Inner
      val value: Inner
    }

    case class ExOne(value: Int) extends Existential {
      override type Inner = Int
    }

    val ex1: Existential = ExOne(1)
    println(ex1.getClass)

    final case class TypeErasor[A](value: A) extends Existential { type Inner = A }

    val intErased: Existential = TypeErasor(1)
    println(intErased)
    val v1: intErased.Inner = intErased.value
    val stringErased        = TypeErasor("abc")
    println(stringErased)
    val v2: stringErased.Inner = stringErased.value
    val caseErased             = TypeErasor(ExOne(4))
    println(caseErased)
    val v3: caseErased.Inner = caseErased.value

    // we lost the information about the type of the .value of each Existential instance.
    //  but we can still add restrictions to it

  }

} 
开发者ID:ksilin,项目名称:catfood,代码行数:39,代码来源:ExistentialPrerequisitesSpec.scala


示例6: EitherErrorSpec

//设置package包名称以及导入依赖的类
package com.example.catfood.errors

import com.example.catfood.errors.ApplicationDomain._
import org.scalatest.{ FreeSpec, MustMatchers }

class EitherErrorSpec extends FreeSpec with MustMatchers {

  def arm: Either[SystemOffline, Nuke]      = Right(Nuke())
  def aim: Either[RotationNeedsOil, Target] = Right(Target())
  def launch(target: Target, nuke: Nuke): Either[MissedByMeters, Impacted] =
    Left(MissedByMeters(5))

  def attack(): Either[NukeException, Impacted] =
    for {
      nuke     <- arm
      target   <- aim
      impacted <- launch(target, nuke)
    } yield impacted

  "must attack" in {
    attack() mustBe Left(MissedByMeters(5))
  }

} 
开发者ID:ksilin,项目名称:catfood,代码行数:25,代码来源:EitherErrorSpec.scala


示例7: TextDSLSpec

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

import org.scalatest.{FlatSpec, MustMatchers}

class TextDSLSpec extends FlatSpec with MustMatchers with TextDSL {

  "aligncolumns" must "align columns" in {

    val doc: Document =
      """|---x--
         |---x--x----x--
         |-x--
         |-xxxxx""".stripMargin.document

    val expected: Document =
      """|---x--
         |---x--x----x--
         |-  x--
         |-  x  x    x  xx""".stripMargin.document

    toText(alignColumns("x")(doc)) mustEqual toText(expected)
  }

  "document" must "convert a string to a Document" in {
    val text =
      """hi
        |bye""".stripMargin

    document(text) mustEqual Vector("hi", "bye")
  }

  it must "support different line feed characters" in {
    document("HiXBye")(new LineFeed("X")) mustEqual Vector("Hi", "Bye")
  }
} 
开发者ID:channingwalton,项目名称:textdsl,代码行数:36,代码来源:TextDSLSpec.scala


示例8: ObsoletePersistenceSpec

//设置package包名称以及导入依赖的类
package io.scalac.frees.modules

import cats.Id
import freestyle._
import freestyle.implicits._
import io.scalac.frees.login.handlers.id.{Level, RecordingLogger}
import io.scalac.frees.login.obsolete.{AlreadyExists, Database, InMemoryDatabase, Persistence}
import io.scalac.frees.login.types._
import org.scalatest.{MustMatchers, WordSpec}


class ObsoletePersistenceSpec extends WordSpec with MustMatchers {

  val Email1 = "email1"
  val Password1 = "abc"
  val Password2 = "def"
  val User1Credentials = Credentials(Email1, Password1)

  "Persistence" when {
    "inserting user" should {
      "log line before trying to insert to DB" in new Context {
        persistence.insertUser(Email1, Password1).interpret[Id]
        logHandler.getRecords.filter(e => e.lvl == Level.INFO && e.msg.matches(s"Inserting.*$Email1.*")) must have size 1
      }
      "log line in case of success" in new Context {
        persistence.insertUser(Email1, Password1).interpret[Id]
        logHandler.getRecords.filter(e => e.lvl == Level.INFO && e.msg.contains("inserted")) must have size 1
      }

      "fail when same email address is used again" in new Context {
        val result = persistence.insertUser(Email1, Password1).flatMap { _ =>
          persistence.insertUser(Email1, Password2)
        }.interpret[Id]
        result mustBe AlreadyExists
      }

      "log line in case of failure" in new Context {
        persistence.insertUser(Email1, Password1).flatMap { _ =>
          persistence.insertUser(Email1, Password1)
        }.interpret[Id]
        logHandler.getRecords.filter(e => e.lvl == Level.WARN && e.msg.matches(s".*$Email1.*already exists.*")) must have size 1
      }
      
      "be able to get user back by email" in new Context {
        val u = (for {
          result <- persistence.insertUser(Email1, Password1)
          u <- persistence.database.getUserByEmail(Email1)
        } yield u).interpret[Id]
        u.isDefined mustEqual true
      }
    }
  }

  trait Context {
    implicit lazy val logHandler = new RecordingLogger
    implicit lazy val dbHandler: Database.Handler[Id] = new InMemoryDatabase
    implicit lazy val persistence = implicitly[Persistence[Persistence.Op]]
  }

} 
开发者ID:LGLO,项目名称:freestyle-login,代码行数:61,代码来源:ObsoletePersistenceSpec.scala


示例9: LircParserSpec

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

import javax.inject.Provider

import io.TestableProcessLogger
import org.scalatest.{FlatSpec, MustMatchers}
import org.scalamock.scalatest.MockFactory

import scala.sys.process._


class LircParserSpec extends FlatSpec with MustMatchers with MockFactory {

  "The irsend command" should "find devices" in {

    val process = mock[ProcessCreation]
    val builder = mock[ProcessBuilder]
    val provider = mock[Provider[TestableProcessLogger]]
    val logger = mock[TestableProcessLogger]

    (process.apply(_:String,_:Seq[String])).expects("irsend", Seq("list", "", "")).returns(builder)
    (logger.processLogger _).expects().returns(null)
    (logger.lines _).expects().returns(List("irsend: sony", "irsend: jvc"))
    (provider.get _).expects().returns(logger)
    (builder.lineStream_! (_: ProcessLogger)).expects(*)

    val lircParser = new DefaultLircParser(process, provider)
    lircParser.listDevices must be(Seq("sony", "jvc"))
  }

  it should "find buttons for a device" in {

    val process = mock[ProcessCreation]
    val builder = mock[ProcessBuilder]
    val provider = mock[Provider[TestableProcessLogger]]
    val logger = mock[TestableProcessLogger]

    (process.apply(_:String,_:Seq[String])).expects("irsend", Seq("list", "sony", "")).returns(builder)
    (logger.processLogger _).expects().returns(null)
    (logger.lines _).expects().returns(List("irsend: 0000000000000481 KEY_VOLUMEUP", "irsend: 0000000000000c81 KEY_VOLUMEDOWN"))
    (provider.get _).expects().returns(logger)
    (builder.lineStream_! (_:ProcessLogger)).expects(*)

    val lircParser = new DefaultLircParser(process, provider)
    lircParser.listButtons("sony") must be(Seq("KEY_VOLUMEUP", "KEY_VOLUMEDOWN"))
  }

  it should "press buttons for a device" in {

    val process = mock[ProcessCreation]
    val builder = mock[ProcessBuilder]
    val provider = mock[Provider[TestableProcessLogger]]
    val logger = mock[TestableProcessLogger]

    (process.apply(_:String,_:Seq[String])).expects("irsend", Seq("SEND_ONCE", "sony", "KEY_VOLUMEUP")).returns(builder)
    (builder.! _).expects().returns(0)

    val lircParser = new DefaultLircParser(process, null)
    lircParser.pressButton("sony", "KEY_VOLUMEUP") must be(true)
  }
} 
开发者ID:jimnybob,项目名称:smartii-ir,代码行数:62,代码来源:LircParserSpec.scala


示例10: RuleGeneratorTest

//设置package包名称以及导入依赖的类
package de.zalando.play.generator.routes

import de.zalando.apifirst.Application.StrictModel
import de.zalando.apifirst.naming.Path
import org.scalatest.{ FunSpec, MustMatchers }
import play.routes.compiler.{ DynamicPart, StaticPart }


class RuleGeneratorTest extends FunSpec with MustMatchers {

  implicit val model = StrictModel(Nil, Map.empty, Map.empty, Map.empty, "/base/", None, Map.empty, Map.empty)

  val routes = Map(
    "/" -> Nil, "/a/b/c/d" -> List(StaticPart("a/b/c/d")), "/a/b/c/d/" -> List(StaticPart("a/b/c/d/")), "/a/{b}/c/{d}" -> List(StaticPart("a/"), DynamicPart("b", """[^/]+""", true), StaticPart("/c/"), DynamicPart("d", """[^/]+""", true)), "/{a}/{b}/{c}/{d}/" -> List(DynamicPart("a", """[^/]+""", true), StaticPart("/"), DynamicPart("b", """[^/]+""", true), StaticPart("/"), DynamicPart("c", """[^/]+""", true), StaticPart("/"), DynamicPart("d", """[^/]+""", true), StaticPart("/")), "/{a}/b/{c}/d/" -> List(DynamicPart("a", """[^/]+""", true), StaticPart("/b/"), DynamicPart("c", """[^/]+""", true), StaticPart("/d/"))
  )

  describe("RuleGeneratorTest") {
    routes.foreach {
      case (path, expected) =>
        it(s"should parse $path as expected") {
          val result = RuleGenerator.convertPath(Path(path)).parts
          result must contain theSameElementsInOrderAs expected
        }
    }
  }
} 
开发者ID:LappleApple,项目名称:api-first-hand,代码行数:27,代码来源:RuleGeneratorTest.scala


示例11: ScalaNameTest

//设置package包名称以及导入依赖的类
package de.zalando.apifirst

import de.zalando.apifirst.ScalaName._
import de.zalando.apifirst.naming.dsl._
import org.scalatest.{ FunSpec, MustMatchers }

class ScalaNameTest extends FunSpec with MustMatchers {

  it("must correctly capitalize names") {
    ("one" / "two" / "three").names mustBe (("one", "Two", "three"))
    ("ONE" / "TWO" / "THREE").names mustBe (("one", "TWO", "tHREE"))
    ("OnE" / "TwO" / "ThReE").names mustBe (("one", "TwO", "thReE"))
  }

  it("must correctly recognize short names") {
    ("one" / "two").names mustBe (("one", "Two", "two"))
  }

  it("must correctly escape scala names") {
    ("catch" / "if" / "match").names mustBe (("`catch`", "If", "`match`"))
  }

  it("must be able to produce import statemets") {
    ("java.util" / "date").qualifiedName("", "") mustBe (("java.util", "Date"))
  }

  it("must correctly concat names") {
    ("definitions" / "Example" / "nestedArrays" / "Opt" / "Arr:").names mustBe (("definitions", "Example", "arr_esc"))
  }

} 
开发者ID:LappleApple,项目名称:api-first-hand,代码行数:32,代码来源:ScalaNameTest.scala


示例12: SecurityDefinitionDeserializerTest

//设置package包名称以及导入依赖的类
package de.zalando.swagger

import java.io.File

import de.zalando.swagger.strictModel._
import org.scalatest.{ MustMatchers, FunSpec }


class SecurityDefinitionDeserializerTest extends FunSpec with MustMatchers with ExpectedResults {

  val file = new File(resourcesPath + "examples/security.api.yaml")

  describe("SecurityDefinitionDeserializer") {
    it(s"should parse security definitions in the ${file.getName}") {
      val (uri, model) = StrictYamlParser.parse(file)
      val result = model.securityDefinitions
      result.size mustBe 6
      result("petstoreImplicit") mustBe a[Oauth2ImplicitSecurity]
      result("githubAccessCode") mustBe a[Oauth2AccessCodeSecurity]
      result("petstorePassword") mustBe a[Oauth2PasswordSecurity]
      result("justBasicStuff") mustBe a[BasicAuthenticationSecurity]
      result("petstoreApplication") mustBe a[Oauth2ApplicationSecurity]
      result("internalApiKey") mustBe a[ApiKeySecurity]
    }
  }
} 
开发者ID:LappleApple,项目名称:api-first-hand,代码行数:27,代码来源:SecurityDefinitionDeserializerTest.scala


示例13: SecurityConstraintsIntegrationTest

//设置package包名称以及导入依赖的类
package de.zalando.swagger

import java.io.File

import org.scalatest.{ FunSpec, MustMatchers }


class SecurityConstraintsIntegrationTest extends FunSpec with MustMatchers with ExpectedResults {

  override val expectationsFolder = super.expectationsFolder + "security_constraints/"

  val fixtures = new File("swagger-parser/src/test/resources/examples").listFiles

  describe("Swagger ApiCall Converter with security constraints") {
    fixtures.filter(_.getName.endsWith(".yaml")).foreach { file =>
      testSecurityConverter(file)
    }
  }

  def testSecurityConverter(file: File): Unit = {
    it(s"should convert security constraints in ${file.getName}") {
      val (base, model) = StrictYamlParser.parse(file)
      val ast = ModelConverter.fromModel(base, model, Option(file))
      val fullResult = ast.calls.filter(_.security.nonEmpty).flatMap(_.security).distinct.mkString("\n")
      val expected = asInFile(file, "types")
      if (expected.isEmpty && fullResult.trim.nonEmpty)
        dump(fullResult, file, "types")
      clean(fullResult) mustBe clean(expected)
    }
  }

} 
开发者ID:LappleApple,项目名称:api-first-hand,代码行数:33,代码来源:SecurityConstraintsIntegrationTest.scala


示例14: SecurityConverterIntegrationTest

//设置package包名称以及导入依赖的类
package de.zalando.swagger

import java.io.File

import de.zalando.swagger.strictModel.SwaggerModel
import org.scalatest.{ FunSpec, MustMatchers }


class SecurityConverterIntegrationTest extends FunSpec with MustMatchers with ExpectedResults {

  override val expectationsFolder = super.expectationsFolder + "security_definitions/"

  val fixtures = new File(resourcesPath + "examples").listFiles

  describe("Swagger Security Converter") {
    fixtures.filter(_.getName.endsWith(".yaml")).foreach { file =>
      testSecurityConverter(file)
    }
  }

  def testSecurityConverter(file: File): Unit = {
    it(s"should convert security definitions from ${file.getName}") {
      val (base, model) = StrictYamlParser.parse(file)
      model mustBe a[SwaggerModel]
      val securityDefs = SecurityConverter.convertDefinitions(model.securityDefinitions)
      val fullResult = securityDefs.mkString("\n")
      val expected = asInFile(file, "types")
      if (expected.isEmpty)
        dump(fullResult, file, "types")
      clean(fullResult) mustBe clean(expected)
    }
  }
} 
开发者ID:LappleApple,项目名称:api-first-hand,代码行数:34,代码来源:SecurityConverterIntegrationTest.scala


示例15: TypeConverterTest

//设置package包名称以及导入依赖的类
package de.zalando.swagger

import java.io.File

import de.zalando.swagger.strictModel.SwaggerModel
import org.scalatest.{ FunSpec, MustMatchers }

class TypeConverterTest extends FunSpec with MustMatchers with ExpectedResults {

  override val expectationsFolder = super.expectationsFolder + "types/"

  val modelFixtures = new File(resourcesPath + "model").listFiles

  val exampleFixtures = new File(resourcesPath + "examples").listFiles

  describe("Strict Swagger Parser model") {
    modelFixtures.filter(_.getName.endsWith(".yaml")).foreach { file =>
      testTypeConverter(file)
    }
  }

  describe("Strict Swagger Parser examples") {
    exampleFixtures.filter(_.getName.endsWith(".yaml")).foreach { file =>
      testTypeConverter(file)
    }
  }

  def testTypeConverter(file: File): Unit = {
    it(s"should parse the yaml swagger file ${file.getName} as specification") {
      val (base, model) = StrictYamlParser.parse(file)
      model mustBe a[SwaggerModel]
      val typeDefs = ModelConverter.fromModel(base, model, Some(file)).typeDefs
      val typeMap = typeDefs map { case (k, v) => k -> ("\n\t" + de.zalando.apifirst.util.ShortString.toShortString("\t\t")(v)) }
      val typesStr = typeMap.toSeq.sortBy(_._1.parts.size).map(p => p._1 + " ->" + p._2).mkString("\n")
      val expected = asInFile(file, "types")
      if (expected.isEmpty) dump(typesStr, file, "types")
      clean(typesStr) mustBe clean(expected)
    }
  }

} 
开发者ID:LappleApple,项目名称:api-first-hand,代码行数:42,代码来源:TypeConverterTest.scala


示例16: ScalaBaseControllerGeneratorIntegrationTest

//设置package包名称以及导入依赖的类
package de.zalando.apifirst.generators

import de.zalando.ExpectedResults
import de.zalando.model._
import org.scalatest.{ FunSpec, MustMatchers }

class ScalaBaseControllerGeneratorIntegrationTest extends FunSpec with MustMatchers with ExpectedResults {

  override val expectationsFolder = super.expectationsFolder + "base_controllers/"

  describe("ScalaBaseControllerGenerator should generate controller bases") {
    (model ++ examples).foreach { ast =>
      testScalaBaseControllerGenerator(ast)
    }
  }

  def testScalaBaseControllerGenerator(ast: WithModel): Unit = {
    val name = nameFromModel(ast)
    it(s"from model $name") {
      val model = ast.model
      val scalaModel = new ScalaGenerator(model).playScalaControllerBases(name, ast.model.packageName.getOrElse(name))
      val expected = asInFile(name, "base.scala")
      if (expected.isEmpty)
        dump(scalaModel, name, "base.scala")
      clean(scalaModel) mustBe clean(expected)
    }
  }

} 
开发者ID:LappleApple,项目名称:api-first-hand,代码行数:30,代码来源:ScalaBaseControllerGeneratorIntegrationTest.scala


示例17: ScalaSecurityGeneratorIntegrationTest

//设置package包名称以及导入依赖的类
package de.zalando.apifirst.generators

import de.zalando.ExpectedResults
import de.zalando.model.WithModel
import org.scalatest.{ FunSpec, MustMatchers }

class ScalaSecurityGeneratorIntegrationTest extends FunSpec with MustMatchers with ExpectedResults {

  override val expectationsFolder = super.expectationsFolder + "security/"

  describe("ScalaSecurityGenerator should generate security plumbing files") {
    examples.foreach { ast =>
      testScalaSecurityGenerator(ast)
    }
  }

  describe("ScalaSecurityGenerator should generate security helper files") {
    examples.foreach { ast =>
      testScalaSecurityExtractorsGenerator(ast)
    }
  }

  def testScalaSecurityGenerator(ast: WithModel): Unit = {
    val name = nameFromModel(ast)
    it(s"from model $name") {
      val model = ast.model
      val scalaModel = new ScalaGenerator(model).playScalaSecurity(name, ast.model.packageName.getOrElse(name))
      val expected = asInFile(name, "scala")
      if (expected.isEmpty)
        dump(scalaModel, name, "scala")
      clean(scalaModel) mustBe clean(expected)
    }
  }

  def testScalaSecurityExtractorsGenerator(ast: WithModel): Unit = {
    val name = nameFromModel(ast)
    it(s"from model $name") {
      val model = ast.model
      val scalaModel = new ScalaGenerator(model).playScalaSecurityExtractors(name, ast.model.packageName.getOrElse(name))
      val expected = asInFile(name, "extractor.scala")
      if (expected.isEmpty)
        dump(scalaModel, name, "extractor.scala")
      clean(scalaModel) mustBe clean(expected)
    }
  }

} 
开发者ID:LappleApple,项目名称:api-first-hand,代码行数:48,代码来源:ScalaSecurityGeneratorIntegrationTest.scala


示例18: ScalaPlayTestsGeneratorIntegrationTest

//设置package包名称以及导入依赖的类
package de.zalando.apifirst.generators

import de.zalando.ExpectedResults
import de.zalando.model.WithModel
import org.scalatest.{ FunSpec, MustMatchers }

class ScalaPlayTestsGeneratorIntegrationTest extends FunSpec with MustMatchers with ExpectedResults {

  override val expectationsFolder = super.expectationsFolder + "tests/"

  describe("ScalaGenerator should generate tests") {
    (examples ++ model ++ validations).foreach { file =>
      testScalaFormParserGenerator(file)
    }
  }

  def testScalaFormParserGenerator(ast: WithModel): Unit = {
    val name = nameFromModel(ast)
    it(s"from model $name") {
      val model = ast.model
      val scalaModel = new ScalaGenerator(model).playScalaTests(name, ast.model.packageName.getOrElse(name))
      val expected = asInFile(name, "scala")
      if (expected.isEmpty)
        dump(scalaModel, name, "scala")
      clean(scalaModel) mustBe clean(expected)
    }
  }

} 
开发者ID:LappleApple,项目名称:api-first-hand,代码行数:30,代码来源:ScalaPlayTestsGeneratorIntegrationTest.scala


示例19: AmazonFineFoodManagerSpec

//设置package包名称以及导入依赖的类
package com.taintech.aff.actor

import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit}
import com.taintech.aff.actor.AmazonFineFoodManager.{Review, ReviewParser}
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, MustMatchers}


class AmazonFineFoodManagerSpec  extends TestKit(ActorSystem("test-system"))
  with FlatSpecLike
  with ImplicitSender
  with BeforeAndAfterAll
  with MustMatchers {

  import AmazonFineFoodManagerSpec._

  "ReviewParser" should "parse test line with values test" in {
    val rp = new ReviewParser()
    rp.parse(testLine) must equal(Review("test3", "test2", "test10"))
  }

  
}

object AmazonFineFoodManagerSpec {
  val testLine = "test1,test2,test3,test4,test5,test6,test7,test8,test9,test10"
  val mockReview: String => Review = _ => Review("test user", "test product", "test text")
} 
开发者ID:taintech,项目名称:AmazonFineFoods,代码行数:29,代码来源:AmazonFineFoodManagerSpec.scala


示例20: StringCounterSpec

//设置package包名称以及导入依赖的类
package com.taintech.common.actor

import akka.actor.{ActorSystem, Props}
import akka.testkit.{ImplicitSender, TestKit, TestProbe}
import StringCounter.{GetTopStrings, StringCount}
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, MustMatchers}


class StringCounterSpec extends TestKit(ActorSystem("test-system"))
  with FlatSpecLike
  with ImplicitSender
  with BeforeAndAfterAll
  with MustMatchers {
  override def afterAll {
    TestKit.shutdownActorSystem(system)
  }

  "Counter Actor" should "handle GetTopString message with using TestProbe" in {
    val sender = TestProbe()

    val counter = system.actorOf(Props[StringCounter])

    sender.send(counter, "a")
    sender.send(counter, "c")
    sender.send(counter, "c")
    sender.send(counter, "b")
    sender.send(counter, "b")
    sender.send(counter, "c")

    sender.send(counter, GetTopStrings(2))
    val state = sender.expectMsgType[List[StringCount]]
    state must equal(List(StringCount("c", 3), StringCount("b", 2)))
  }
} 
开发者ID:taintech,项目名称:AmazonFineFoods,代码行数:35,代码来源:StringCounterSpec.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala Broadcast类代码示例发布时间:2022-05-23
下一篇:
Scala JsPath类代码示例发布时间: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