当前位置: 首页>>代码示例>>Scala>>正文


Scala Inside类代码示例

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


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

示例1: TestBase

//设置package包名称以及导入依赖的类
package uk.co.appministry.scathon.client

import org.scalatest.concurrent._
import org.scalatest.time.{Millis, Seconds, Span}
import org.scalatest.{BeforeAndAfterAll, Inside, Matchers, WordSpec}
import uk.co.appministry.scathon.testServer.TestMarathon

class TestBase extends WordSpec
  with Eventually
  with ScalaFutures
  with Inside
  with Matchers
  with BeforeAndAfterAll
  with AsyncAssertions {

  implicit override val patienceConfig = PatienceConfig(timeout = scaled(Span(10, Seconds)), interval = scaled(Span(100, Millis)))

  var client: Client = _
  var server: TestMarathon = _

  override def beforeAll: Unit = {
    server = new TestMarathon
    server.start()
    client = new Client(port = server.port.get)
  }

  override def afterAll: Unit = {
    server.stop()
  }

} 
开发者ID:AppMinistry,项目名称:scathon,代码行数:32,代码来源:TestBase.scala

示例2: MesosConstraintsTests

//设置package包名称以及导入依赖的类
package uk.co.appministry.scathon.models.mesos

import uk.co.appministry.scathon.models.v2.{Application, ApplicationParser}
import org.scalatest.{Inside, Matchers, WordSpec}
import play.api.libs.json.Json

class MesosConstraintsTests extends WordSpec
  with Matchers
  with ApplicationParser
  with ConstraintParser
  with Inside {

  "ConstraintParser" should {
    "parse valid looking constraints" in {
      Json.parse("""["hostname", "UNIQUE"]""").as[Constraint] shouldBe( UniqueConstraint("hostname") )
      Json.parse("""["rack", "CLUSTER", "value"]""").as[Constraint] shouldBe( ClusterConstraint("rack", "value") )
      Json.parse("""["hostname", "GROUP_BY"]""").as[Constraint] shouldBe( GroupByConstraint("hostname") )
      Json.parse("""["hostname", "GROUP_BY", "with_value"]""").as[Constraint] shouldBe( GroupByConstraint("hostname", Some("with_value")) )
      Json.parse("""["rack", "LIKE", "rack-[1-3]"]""").as[Constraint] shouldBe( LikeConstraint("rack", "rack-[1-3]") )
      Json.parse("""["rack", "UNLIKE", "rack-[1-3]"]""").as[Constraint] shouldBe( UnlikeConstraint("rack", "rack-[1-3]") )
    }

    "parse an application with constraints" in {

      val constraints = List(
        UniqueConstraint("hostname"),
        ClusterConstraint("rack", "value"),
        GroupByConstraint("hostname"),
        GroupByConstraint("hostname", Some("with_value")),
        LikeConstraint("rack", "rack-[1-3]"),
        UnlikeConstraint("rack", "rack-[1-3]") )

      val parsed = applicationFormat.writes( Application(
        id = "/some-test-id",
        constraints = Some(constraints) ) ).toString()

      inside( Json.parse(parsed).asOpt[ Application ] ) {
        case Some(parsedApp) =>
          inside( parsedApp.constraints ) {
            case Some(vals) => vals should be(constraints)
            case None => fail("Expected Some, got None.")
          }
        case None => fail("Expected Some, got None.")
      }

    }

  }

} 
开发者ID:AppMinistry,项目名称:scathon,代码行数:51,代码来源:MesosConstraintsTests.scala

示例3: StateTransitionTest

//设置package包名称以及导入依赖的类
package com.github.kelebra.akka.js.snake.state

import com.github.kelebra.akka.js.snake.{Block, `?`, `?`}
import org.scalatest.{Inside, Matchers, WordSpec}

class StateTransitionTest extends WordSpec with Matchers with StateTransition with Inside {

  "State transition" should {

    "initialize empty state" in {
      val empty = State()
      val start = Block(0, 1, 1)

      inside(initialized(empty, ?, start)) { case State(direction, blocks, _) =>
        blocks should be(start :: Nil)
        direction should be(?)
      }
    }

    "not initialize state one more time" in {
      val empty = State()
      val block = Block(0, 0, 1)
      val direction = ?

      val init = initialized(empty, direction, block)
      init should be(initialized(init, direction.opposite, Block(0, 0, 2)))
    }

    "change direction and reverse blocks for opposite direction" in {
      val direction = ?
      val blocks = Block(1, 2, 3) :: Block(3, 2, 1) :: Nil
      val state = State(direction, blocks, None)

      directed(state, direction.opposite) should be(state.copy(direction = direction.opposite, body = blocks.reverse))
    }

    "change direction only" in {
      val direction = `?`
      val blocks = Block(1, 2, 3) :: Block(3, 2, 1) :: Nil
      val state = State(direction, blocks, None)

      directed(state, `?`) should be(state.copy(direction = `?`))
    }
  }
} 
开发者ID:kelebra,项目名称:akka-js-snake,代码行数:46,代码来源:StateTransitionTest.scala

示例4: BaseAppSuite

//设置package包名称以及导入依赖的类
package im.actor.server

import java.time.Instant

import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.time.{ Seconds, Span }
import org.scalatest.{ FlatSpecLike, Inside, Matchers }

import scala.concurrent.ExecutionContext
import im.actor.server.db.DbExtension
import im.actor.server.migrations.v2.{ MigrationNameList, MigrationTsActions }

abstract class BaseAppSuite(_system: ActorSystem = {
                              ActorSpecification.createSystem()
                            })
  extends ActorSuite(_system)
  with FlatSpecLike
  with ScalaFutures
  with MessagingSpecHelpers
  with Matchers
  with Inside
  with ServiceSpecMatchers
  with ServiceSpecHelpers
  with ActorSerializerPrepare {

  protected implicit val materializer: ActorMaterializer = ActorMaterializer()
  implicit lazy val ec: ExecutionContext = _system.dispatcher

  protected implicit lazy val (db, conn) = {
    DbExtension(_system).clean()
    DbExtension(_system).migrate()
    val ext = DbExtension(_system)
    (ext.db, ext.connector)
  }

  system.log.debug("Writing migration timestamps")
  MigrationTsActions.insertTimestamp(
    MigrationNameList.MultiSequence,
    Instant.now.toEpochMilli
  )(conn)
  MigrationTsActions.insertTimestamp(
    MigrationNameList.GroupsV2,
    Instant.now.toEpochMilli
  )(conn)

  override implicit def patienceConfig: PatienceConfig =
    new PatienceConfig(timeout = Span(15, Seconds))

  override protected def beforeAll(): Unit = {
    super.beforeAll()
    db
  }
} 
开发者ID:wex5,项目名称:dangchat-server,代码行数:56,代码来源:BaseAppSuite.scala

示例5: ConcordanceSpec

//设置package包名称以及导入依赖的类
package com.phasmid.concordance

import org.scalatest.{ FlatSpec, Matchers, Inside }


class ConcordanceSpec extends FlatSpec with Matchers with Inside {
  
  def parse(s: String) = {
    val p = new ConcordanceParser
    p.parseAll(p.sentence,s) match {
      case p.Success(ws,_) => ws
      case p.Failure(e,_) => println(e); List()
      case p.Error(e,_) => println(e); List()
    }
  }

  "Concordance" should "read Hello World!" in {
    val r = parse("Hello World!")
    r should matchPattern { case h::tail => }
    r.head should matchPattern { case PositionalString("Hello") => }
    inside(r.head) { case p @ PositionalString(_) =>
        p.pos.line shouldBe (1)
        p.pos.column shouldBe (1)
    }
    r.tail.head should matchPattern { case PositionalString("World!") => }
    inside(r.tail.head) { case p @ PositionalString(_) =>
        p.pos.line shouldBe (1)
        p.pos.column shouldBe (7)
    }
  }
    it should "read Hello<newline>World!" in {
    val r = parse("Hello\nWorld!")
    r should matchPattern { case h::tail => }
    r.head should matchPattern { case PositionalString("Hello") => }
    inside(r.head) { case p @ PositionalString(_) =>
        p.pos.line shouldBe (1)
        p.pos.column shouldBe (1)
    }
    r.tail.head should matchPattern { case PositionalString("World!") => }
    inside(r.tail.head) { case p @ PositionalString(_) =>
        p.pos.line shouldBe (2)
        p.pos.column shouldBe (1)
    }
  }
} 
开发者ID:menezesl,项目名称:Scala-repo,代码行数:46,代码来源:ConcordanceSpec.scala

示例6: MiniDatabase2Spec

//设置package包名称以及导入依赖的类
package edu.neu.coe.scala.minidatabase2

import org.scalatest.{ FlatSpec, Matchers, Inside }
import scala.util._


class MiniDatabase2Spec extends FlatSpec with Inside with Matchers {

  "Height" should "parse 6 ft 5 in" in {
    Height.parse("6 ft 5 in") should matchPattern { case Success(h) => }
  }
  it should """parse 6' 5"""" in {
    Height.parse("""6' 5"""") should matchPattern { case Success(h) => }
  }
  it should """not parse 6'""" in {
    Height.parse("""6'""") should matchPattern { case Failure(x) => }
  }
  it should "equal 77 inches and be considered tall" in {
    val height = Height.parse("6 ft 5 in")    
    inside(height) {
      case Success(h) => h should matchPattern { case Height(6,5) => }
    }
    inside(height) {
      case Success(h) => h.inches shouldEqual (77)
    }
    inside(height) {
      case Success(h) => MiniDatabase2.measure(h) should be ("tall")
    }
  }

  "Name" should "parse Tom Brady" in {
    Name.parse("Tom Brady") should matchPattern { case Success(h) => }
  }
  
  it should """parse Thomas E. P. "Tom" Brady""" in {
    Name.parse("""Thomas E. P. "Tom" Brady""") should matchPattern { case Success(h) => }
  }
  
  "Entry" should """parse Thomas E. P. "Tom" Brady, etc.""" in {
    Entry.parse("""Thomas E. P. "Tom" Brady, 078-05-1120, Aug 3rd 1977, 6 ft 4 in, 225""".split(",")) should matchPattern { case Success(h) => }
  }
  
//  it should """parse Thomas E. P. "Tom" Brady""" in {
//    Name.parse("""Thomas E. P. "Tom" Brady""") should matchPattern { case Success(h) => }
//  }
} 
开发者ID:menezesl,项目名称:Scala-repo,代码行数:47,代码来源:MiniDatabaseSpec2.scala

示例7: AkkaCompatSpec

//设置package包名称以及导入依赖的类
package swave.compat.akka

import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.stream.scaladsl._

import scala.concurrent.duration._
import org.scalatest.{BeforeAndAfterAll, FreeSpec, Inside, Matchers}
import swave.core._
import swave.core.util._

class AkkaCompatSpec extends FreeSpec with Matchers with Inside with BeforeAndAfterAll {

  implicit val env          = StreamEnv()
  implicit val system       = ActorSystem()
  implicit val materializer = ActorMaterializer()

  "Akka compatibility should work as expected" - {

    "Source.toSpout" in {
      Source(1 to 10).toSpout.drainToList(100).await() shouldEqual (1 to 10)
    }

    "Spout.toAkkaSource" in {
      Spout(1 to 10).toAkkaSource.runWith(Sink.seq).await() shouldEqual (1 to 10)
    }

    "Flow.toPipe" in {
      val flow = Flow[Int].map(_ * -1)
      Spout(1 to 10).via(flow.toPipe).drainToList(100).await() shouldEqual (-1 to -10 by -1)
    }

    "Pipe.toAkkaFlow" in {
      val pipe = Pipe[Int].map(_ * -1)
      Source(1 to 10).via(pipe.toAkkaFlow).runWith(Sink.seq).await() shouldEqual (-1 to -10 by -1)
    }

    "Sink.toDrain" in {
      val sink = Sink.seq[Int]
      Spout(1 to 10).drainTo(sink.toDrain).await() shouldEqual (1 to 10)
    }

    "Drain.toAkkaSink" in {
      val drain = Drain.seq[Int](100)
      Source(1 to 10).runWith(drain.toAkkaSink).await() shouldEqual (1 to 10)
    }
  }

  override val invokeBeforeAllAndAfterAllEvenIfNoTestsAreExpected = true

  override protected def afterAll(): Unit = {
    val envTermination = env.shutdown()
    system.terminate().await(2.seconds)
    envTermination.awaitTermination(2.seconds)
  }
} 
开发者ID:sirthias,项目名称:swave,代码行数:57,代码来源:AkkaCompatSpec.scala

示例8: NoInvitationsPlatformISpec

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

import org.scalatest.{Inside, Inspectors}
import org.scalatest.concurrent.Eventually
import uk.gov.hmrc.agentinvitations.support._
import uk.gov.hmrc.domain.{AgentCode, Nino}
import uk.gov.hmrc.play.test.UnitSpec

class NoInvitationsPlatformISpec extends UnitSpec with MongoAppAndStubs with Inspectors with Inside with Eventually with Requests {

  private implicit val arn = RandomArn()
  private implicit val agentCode = AgentCode("LMNOP123456")
  private val nino: Nino = nextNino

  "Before the Agency has sent any invitations" in {
    val agency = new AgencyRequests(this, arn, port)
    val client = new ClientRequests(this, nino, port)

    given().agentAdmin(arn, agentCode).isLoggedInWithSessionId().andIsSubscribedToAgentServices()
    given().client(clientId = nino).isLoggedInWithSessionId()

    info("the Agency sent invitations should be empty")
    val agencyResponse = agency.sentInvitations()
    agencyResponse.numberOfInvitations shouldBe 0
    agencyResponse.links.invitations shouldBe 'empty
    agencyResponse.links.selfLink shouldBe s"/agent-invitations/agencies/${arn.value}/invitations/sent"
    agencyResponse.embedded.isEmpty shouldBe true

    info("the Clients received invitations should be empty")
    val clientResponse = client.getInvitations()
    clientResponse.numberOfInvitations shouldBe 0
    clientResponse.links.invitations shouldBe 'empty
    clientResponse.links.selfLink shouldBe s"/agent-invitations/clients/ni/${nino.value}/invitations/received"
    clientResponse.embedded.isEmpty shouldBe true
  }
} 
开发者ID:hmrc,项目名称:agent-invitations,代码行数:37,代码来源:NoInvitationsISpec.scala

示例9: UnitSpec

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

import org.mongodb.scala.bson.collection.immutable.Document
import org.scalatest.FunSuite
import org.scalatest.Inside
import org.scalatest.Inspectors
import org.scalatest.Matchers
import org.scalatest.OptionValues

abstract class UnitSpec extends FunSuite
  with Matchers
  with OptionValues
  with Inside
  with Inspectors


class MongoQueryParserTest extends UnitSpec {

  trait Fixture {
    val parser = new MongoQueryParser()
  }

  test("Parse query") {
    new Fixture {

      val query: String =
        """
          |{
          |"name" : "The Lord of The Rings",
          |"author" : "J. R. R. Tolkien",
          |"isHardcover" : true,
          |"pages" : 1178,
          |"price" : 13.60,
          |"currency" : "GBP"
          |}
        """.stripMargin

      val expected: String =
        """{
          |"name" : "The Lord of The Rings",
          |"author" : "J. R. R. Tolkien",
          |"isHardcover" : true,
          |"pages" : 1178,
          |"price" : { "$numberDecimal" : "13.60" },
          |"currency" : "GBP"
          |}
        """.stripMargin

      val document: Document = parser.parse(query)
      assert(normalize(document.toJson()) === normalize(expected))
    }
  }

  private def normalize(s: String): String = s.split('\n').map(_.trim.filter(_ != ' ')).mkString

} 
开发者ID:dougsleite,项目名称:oak,代码行数:57,代码来源:MongoQueryParserTest.scala

示例10: GroupSpec

//设置package包名称以及导入依赖的类
package com.github.tarao.namedcap

import org.scalatest.{FunSpec, Matchers, OptionValues, Inside, Inspectors}

class GroupSpec extends FunSpec with Matchers
    with OptionValues with Inside with Inspectors
    with Implicits {
  describe("Constructor method") {
    it("should give a specified name") {
      val g1 = Group("foo", "[a-zA-Z0-9]+")
      g1.name shouldBe "foo"
      g1.pattern shouldBe "[a-zA-Z0-9]+"
      g1.names shouldBe Seq("foo")
      g1.allNames shouldBe Seq("foo")

      val p1 = pattern"$g1:$g1"

      val g2 = NestedGroup("bar", p1)
      g2.name shouldBe "bar"
      g2.pattern shouldBe "([a-zA-Z0-9]+):([a-zA-Z0-9]+)"
      g2.names shouldBe Seq("bar")
      g2.allNames shouldBe Seq("bar", "foo", "foo")

      val p2 = pattern"$g2-$g2"
      val g3 = NestedGroup("baz", p2)
      g3.name shouldBe "baz"
      g3.pattern shouldBe "(([a-zA-Z0-9]+):([a-zA-Z0-9]+))-(([a-zA-Z0-9]+):([a-zA-Z0-9]+))"
      g3.names shouldBe Seq("baz")
      g3.allNames shouldBe Seq("baz", "bar", "foo", "foo", "bar", "foo", "foo")

      val g4 = UnnamedGroup(p1)
      g4.name shouldBe "UnnamedGroup(${foo}:${foo})"
      g4.pattern shouldBe "([a-zA-Z0-9]+):([a-zA-Z0-9]+)"
      g4.names shouldBe Seq("foo", "foo")
      g4.allNames shouldBe Seq("foo", "foo")

      val g5 = UnnamedGroup(p2)
      g5.name shouldBe "UnnamedGroup(${bar}-${bar})"
      g5.pattern shouldBe "(([a-zA-Z0-9]+):([a-zA-Z0-9]+))-(([a-zA-Z0-9]+):([a-zA-Z0-9]+))"
      g5.names shouldBe Seq("bar", "bar")
      g5.allNames shouldBe Seq("bar", "foo", "foo", "bar", "foo", "foo")
    }
  }
} 
开发者ID:tarao,项目名称:namedcap-scala,代码行数:45,代码来源:GroupSpec.scala

示例11: SaltedPasswordCacheTest

//设置package包名称以及导入依赖的类
package rere.sasl.scram.cache

import org.scalatest.{Inside, Matchers, WordSpec}

class SaltedPasswordCacheTest extends WordSpec with Matchers with Inside {

  "SaltedPasswordCache object" should {
    "create stateful instance of cache using `apply` method" in {
      val cache = SaltedPasswordCache()
      cache.put("qwerty", "salt", 4096, Array[Byte](97, 98, 99))
      inside(cache.get("qwerty", "salt", 4096)) {
        case Some(salted) =>
          salted.toVector shouldBe Vector[Byte](97, 98, 99)
      }
    }

    "crate stateless instance of cache using `dummy` method" in {
      val cache = SaltedPasswordCache.dummy()
      cache.put("qwerty", "salt", 4096, Array[Byte](97, 98, 99))
      cache.get("qwerty", "salt", 4096) shouldBe None
    }
  }

} 
开发者ID:pbaun,项目名称:rere,代码行数:25,代码来源:SaltedPasswordCacheTest.scala

示例12: withServer

//设置package包名称以及导入依赖的类
package com.lightbend.lagom.it

import java.util.function.{ Function => JFunction }
import akka.stream.Materializer
import akka.stream.scaladsl.Source
import org.scalatest.{ Inside, Matchers, WordSpecLike }
import play.api.Application
import play.inject.guice.GuiceApplicationBuilder
import scala.concurrent.Await
import scala.concurrent.duration._
import scala.reflect.ClassTag
import akka.japi.function.Procedure
import com.lightbend.lagom.javadsl.testkit.ServiceTest
import com.lightbend.lagom.javadsl.testkit.ServiceTest.TestServer

trait ServiceSupport extends WordSpecLike with Matchers with Inside {

  def withServer(configureBuilder: GuiceApplicationBuilder => GuiceApplicationBuilder)(block: Application => Unit): Unit = {
    val jConfigureBuilder = new JFunction[GuiceApplicationBuilder, GuiceApplicationBuilder] {
      override def apply(b: GuiceApplicationBuilder): GuiceApplicationBuilder = {
        configureBuilder(b)
      }
    }
    val jBlock = new Procedure[TestServer] {
      override def apply(server: TestServer): Unit = {
        block(server.app.getWrappedApplication)
      }
    }
    val setup = ServiceTest.defaultSetup.configureBuilder(jConfigureBuilder).withCluster(false)
    ServiceTest.withServer(setup, jBlock)
  }

  def withClient[T: ClassTag](configureBuilder: GuiceApplicationBuilder => GuiceApplicationBuilder)(block: Application => T => Unit): Unit = {
    withServer(configureBuilder) { application =>
      val client = application.injector.instanceOf[T]
      block(application)(client)
    }
  }

  implicit def materializer(implicit app: Application): Materializer = app.materializer

  def consume[T](source: Source[T, _])(implicit mat: Materializer): List[T] = {
    Await.result(source.runFold(List.empty[T])((list, t) => t :: list), 10.seconds).reverse
  }
} 
开发者ID:lagom,项目名称:lagom,代码行数:46,代码来源:ServiceSupport.scala

示例13: GrammarTest

//设置package包名称以及导入依赖的类
package com.github.kczulko.isc.dhcp

import com.github.kczulko.isc.dhcp.data.MultipleLeases._
import com.github.kczulko.isc.dhcp.data.SingleLeaseWithServerDuid._
import com.github.kczulko.isc.dhcp.data.SingleLeaseWithoutSomeData._
import com.github.kczulko.isc.dhcp.model.Result
import org.scalatest.{EitherValues, FlatSpec, Inside, Matchers}

class GrammarTest
    extends FlatSpec
    with Matchers
    with Inside
    with EitherValues {

  val grammar = new Grammar

  "leases parser" should "parse valid single entry without some data" in {
    inside(Grammar(singleLeaseWithoutSomeData._1).right.value) {
      case Result(leases, serverDuid) =>
        serverDuid shouldEqual None
        leases should have length 1
        leases should contain only
          singleLeaseWithoutSomeData._2
    }
  }

  it should "parse multiple entries" in {
    inside(Grammar(multipleLeases._1).right.value) {
      case Result(leases, serverDuid) =>
        serverDuid shouldEqual None
        leases.length shouldEqual multipleLeases._2.length
        leases should contain theSameElementsAs multipleLeases._2
    }
  }

  it should "parse entry with server-duid" in {
    inside(Grammar(singleLeaseWithServerDuid._1).right.value) {
      case result @ Result(leases, serverDuid) =>
        result shouldEqual singleLeaseWithServerDuid._2
    }
  }

  it should "not fail when unknow entry appears in file stream" in {
    Grammar(singleLeaseWithServerDuid._1 + "\n whatever can be here\n").isRight shouldBe true
  }

  it should "not fail when comment line appears in file stream" in {
    Grammar("# any comment here\n" + singleLeaseWithServerDuid._1).isRight shouldBe true
  }
} 
开发者ID:kczulko,项目名称:isc-dhcp-leases-parser,代码行数:51,代码来源:GrammarTest.scala


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