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

Scala FeatureSpec类代码示例

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

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



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

示例1: AppSpec

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

import org.scalatest.{FeatureSpec, GivenWhenThen}

class AppSpec extends FeatureSpec with GivenWhenThen {

  info("As an app developer I want to be able to access the app, its settings and properties")

  feature("Application class") {
    scenario("can be instantiated in Headless mode") {
      Given("a default location app.Main for the app")
      When("the class is instantiated as a headless")
      val application = new app.Main(true)
      Then("the object should be instantiated")
      assert(application.isInstanceOf[app.Main])
    }
  }
} 
开发者ID:Y-Experiment,项目名称:LW3D,代码行数:19,代码来源:AppSpec.scala


示例2: ReadFromFileSpec

//设置package包名称以及导入依赖的类
import org.scalatest.{FeatureSpec, GivenWhenThen}


class ReadFromFileSpec extends FeatureSpec with GivenWhenThen {

  info("As a user from PSP1")
  info("I want to calculate the mean of a file compound by decimal numbers")
  info("So I don't have to type them manually")
  info("And save my time")

  feature("Calculate mean") {
    scenario("User sends a file with the numbers, one per line") {
      val fileName = getClass.getResource("test.txt").getFile
      Given("the file is not empty")
      assert(scala.io.Source.fromFile(fileName).getLines().nonEmpty)
      Given("the file has just numbers")
      assert(!scala.io.Source.fromFile(fileName).getLines().exists(!ReadFromFile.isAllDigits(_)))
      When("the mean is calculated for that file")
      val list = ReadFromFile.getListFromFile(fileName)
      val mean = list.mean
      Then("the result should be a decimal number")
      assert(mean.isInstanceOf[Double])
    }
  }
} 
开发者ID:camilosampedro,项目名称:PSP-TDD,代码行数:26,代码来源:ReadFromFileSpec.scala


示例3: PtxTrackleTransformerServiceTest

//设置package包名称以及导入依赖的类
package com.ubirch.avatar.transformer.services

import com.typesafe.scalalogging.slf4j.StrictLogging
import com.ubirch.transformer.services.PtxTransformerService
import com.ubirch.util.json.MyJsonProtocol
import org.scalatest.{FeatureSpec, Matchers}


class PtxTrackleTransformerServiceTest extends FeatureSpec
  with Matchers
  with StrictLogging
  with MyJsonProtocol {

  feature("PTX") {
    scenario("temp gt 0") {
      val adc1: BigDecimal = 21285.0
      val t1: BigDecimal = 24.69

      PtxTransformerService.pt100_temperature(adc = adc1).setScale(2, BigDecimal.RoundingMode.HALF_UP) shouldBe t1
    }

    scenario("temp lt 0") {
      val adc1: BigDecimal = 10.0
      val t1: BigDecimal = -241.91

      PtxTransformerService.pt100_temperature(adc = adc1).setScale(2, BigDecimal.RoundingMode.HALF_UP) shouldBe t1
    }
  }
} 
开发者ID:ubirch,项目名称:ubirch-avatar-service,代码行数:30,代码来源:PtxTrackleTransformerServiceTest.scala


示例4: HealthCheckFeature

//设置package包名称以及导入依赖的类
package com.reactivecore.quotes.workshop.api.feature

import com.reactivecore.quotes.workshop.api.QuotesWorkshopApiService
import org.scalatest.concurrent.{PatienceConfiguration, ScalaFutures}
import org.scalatest.time.{Seconds, Span}
import org.scalatest.{FeatureSpec, GivenWhenThen, Matchers}
import play.api.http.Status

class HealthCheckFeature extends FeatureSpec with GivenWhenThen with Matchers with ScalaFutures with PatienceConfiguration {

  override implicit val patienceConfig = PatienceConfig(
    timeout = scaled(Span(1, Seconds))
  )

  feature("health check") {
    scenario("service is healthy") {
      Given("a service")
      val service = QuotesWorkshopApiService()

      When("getting the /health endpoint")
      val response = get(s"http://localhost:${service.port}/health").futureValue

      Then("the response status should be OK")
      response.status should be(Status.OK)

      service.stop()
    }
  }

} 
开发者ID:bschaff,项目名称:quotes-workshop-api,代码行数:31,代码来源:HealthCheckFeature.scala


示例5: OptionsFeature

//设置package包名称以及导入依赖的类
package com.reactivecore.quotes.workshop.api.feature

import com.reactivecore.quotes.workshop.api.QuotesWorkshopApiService
import org.scalatest.concurrent.{PatienceConfiguration, ScalaFutures}
import org.scalatest.time.{Seconds, Span}
import org.scalatest.{FeatureSpec, GivenWhenThen, Matchers}
import play.api.http.Status

class OptionsFeature extends FeatureSpec with GivenWhenThen with Matchers with ScalaFutures with PatienceConfiguration {

  override implicit val patienceConfig = PatienceConfig(
    timeout = scaled(Span(1, Seconds))
  )

  feature("options") {
    scenario("requests options of /items") {
      Given("a service")
      val service = QuotesWorkshopApiService()

      When("requesting for the options of /items endpoint")
      val response = options(s"http://localhost:${service.port}/items").futureValue

      Then("the response status should be OK")
      response.status should be(Status.OK)

      service.stop()
    }
  }

} 
开发者ID:bschaff,项目名称:quotes-workshop-api,代码行数:31,代码来源:OptionsFeature.scala


示例6: GreetingEndpointFeature

//设置package包名称以及导入依赖的类
package org.akka.templates.features

import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.akka.templates.endpoints.GreetingEndpoint
import org.scalatest.{FeatureSpec, Matchers}
import org.akka.templates.response.rejection._


class GreetingEndpointFeature
  extends FeatureSpec
    with Matchers
    with ScalatestRouteTest
    with GreetingEndpoint {

  feature("greeting api") {
    scenario("successful get") {
      Get(s"/api/greetings?name=gabriel&greeting=hello") ~> Route.seal(apiRoute) ~> check {
        status shouldBe StatusCodes.OK
        responseAs[String] should include (s"hello, gabriel")
      }
    }

    scenario("unprocessable entity get") {
      Get(s"/api/greetings?name=gabriel&greeting=") ~> Route.seal(apiRoute) ~> check {
        status shouldBe StatusCodes.UnprocessableEntity
      }
    }
  }
} 
开发者ID:gabfssilva,项目名称:akka-http-microservice-templates,代码行数:32,代码来源:GreetingEndpointFeature.scala


示例7: Prod1FeatureTest

//设置package包名称以及导入依赖的类
package com.stulsoft.pscalatest.prod.integrationTest

import com.stulsoft.pscalatest.prod.Prod1

import org.scalatest.{FeatureSpec, GivenWhenThen}


class Prod1FeatureTest extends FeatureSpec with GivenWhenThen {
  info("As owner")
  info("I want increase age")
  info("So I can increase age when I want")
  feature("Prod1") {
    scenario("Increasing p1") {
      Given("a Prod1 object with p1 = 1")
      val p = Prod1(1, "test")
      When("increase p1 by 1")
      p.incrementP1(1)
      Then("p1 must be 2")
      assert(p.p1 == 2)
    }
  }
} 
开发者ID:ysden123,项目名称:poc,代码行数:23,代码来源:Prod1FeatureTest.scala


示例8: EventSourcingTest

//设置package包名称以及导入依赖的类
package br.com.uol.plataforma.event.sourcing

import java.util.UUID

import br.com.uol.plataforma.event.sourcing.commands.BankAccountCommands._
import br.com.uol.plataforma.event.sourcing.model.{Event, Request}
import br.com.uol.plataforma.event.sourcing.player.EventPlayer._
import br.com.uol.plataforma.event.sourcing.state.BankAccount
import br.com.uol.plataforma.event.sourcing.store.BankAccountEventStore.eventStore
import org.scalatest.{FeatureSpec, Matchers}


class EventSourcingTest extends FeatureSpec with Matchers {
  feature("Creating an account and then closing it") {
    scenario("Create an account and then assert that replay restores the actual state of the BankAccount object") {
      val aggregationId = UUID.randomUUID().toString

      val f =
        createAccount(Request("owner" -> "John Doe", "id" -> 123))
          .andThen(deposit(Request("amount" -> 20)))
          .andThen(changeOwner(Request("newOwner" -> "Jane Doe")))
          .andThen(withdrawal(Request("amount" -> 10)))
          .andThen(close(Request("reason" -> "Unavailable address")))

      val actualState: BankAccount = f(BankAccount(aggregationId))
      val events: Seq[Event[BankAccount]] = eventStore.get(aggregationId)
      val playedState: BankAccount = events.play(BankAccount(aggregationId))

      actualState shouldEqual playedState
    }
  }
} 
开发者ID:gabfssilva,项目名称:event-sourcing-sample,代码行数:33,代码来源:EventSourcingTest.scala


示例9: BlacklistSpecification

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

import java.net.{InetAddress, InetSocketAddress}

import com.typesafe.config.ConfigFactory
import com.wavesplatform.network.PeerDatabaseImpl
import com.wavesplatform.settings.NetworkSettings
import net.ceedubs.ficus.Ficus._
import org.scalatest.{FeatureSpec, GivenWhenThen}

class BlacklistSpecification extends FeatureSpec with GivenWhenThen {
  private val config = ConfigFactory.parseString(
    """waves.network {
      |  known-peers = []
      |  file = null
      |  black-list-residence-time: 1s
      |}""".stripMargin).withFallback(ConfigFactory.load()).resolve()

  private val networkSettings = config.as[NetworkSettings]("waves.network")

  info("As a Peer")
  info("I want to blacklist other peers for certain time")
  info("So I can give them another chance after")

  feature("Blacklist") {
    scenario("Peer blacklist another peer") {

      Given("Peer database is empty")
      val peerDatabase = new PeerDatabaseImpl(networkSettings)

      def isBlacklisted(address: InetSocketAddress) = peerDatabase.blacklistedHosts.contains(address.getAddress)

      assert(peerDatabase.knownPeers.isEmpty)
      assert(peerDatabase.blacklistedHosts.isEmpty)

      When("Peer adds another peer to knownPeers")
      val address = new InetSocketAddress(InetAddress.getByName("localhost"), 1234)
      peerDatabase.touch(address)
      assert(peerDatabase.knownPeers.contains(address))
      assert(!isBlacklisted(address))

      And("Peer blacklists another peer")
      peerDatabase.blacklist(address.getAddress)
      assert(isBlacklisted(address))
      assert(!peerDatabase.knownPeers.contains(address))

      And("Peer waits for some time")
      Thread.sleep(networkSettings.blackListResidenceTime.toMillis + 500)

      Then("Another peer disappear from blacklist")
      assert(!isBlacklisted(address))

      And("Another peer became known")
      assert(peerDatabase.knownPeers.contains(address))
    }
  }
} 
开发者ID:wavesplatform,项目名称:Waves,代码行数:58,代码来源:BlacklistSpecification.scala


示例10: GuaranteeRepositoryTest

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

import domain.Guarantee
import org.scalatest.{FeatureSpec, GivenWhenThen}

import scala.concurrent.Await


class GuaranteeRepositoryTest extends FeatureSpec with GivenWhenThen{

  feature("Create guarantee") {
    info("Add guarantee")
    scenario("Add new guarantee ") {
      Given("Given all data")
      val guaranteeId = "12345678"
      val amount = 120000
      val currency = "US"

      Then("Add guarantee ")
      val guarantee = Guarantee(guaranteeId, amount, currency)
      val guaranteeRepo = GuaranteeRepository
      guaranteeRepo.save(guarantee)
      Then("Display All ")
      val displayAllGuarantee = Await.result(guaranteeRepo.getGuaranteeById(guaranteeId), 2 minutes)
      displayAllGuarantee.foreach(i => println("Guarantee=======>", i))
      val displayIdStatus = Await.result(guaranteeRepo.getGuaranteeById(guaranteeId), 2 minutes)
      displayIdStatus.foreach(i => println("GuaranteeStatus=======>", i))
    }
  }
} 
开发者ID:boniface,项目名称:opsapi,代码行数:31,代码来源:GuaranteeRepositoryTest.scala


示例11: FeatureRepositoryTest

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

import domain.Feature
import org.scalatest.{FeatureSpec, GivenWhenThen}


class FeatureRepositoryTest extends FeatureSpec with GivenWhenThen{

  feature("Create feature") {
    info("Add an feature")
    scenario("Add new feature ") {
      Given("Given all data")
      val featureId = "123456"
      val code = "code"
      val featureOf = "featureOf"
      val relatedItem = "relatedItem"
      val title = "title"
      val description = "description"
      val enum = "featurevalue"

      Then("Add feature ")
      val feature = Feature(featureId, code, featureOf, relatedItem, title, description, enum)
      val featureRepo = FeatureRepository
      featureRepo.save(feature)
      Then("Display All ")
      val displayAllcancelled = Await.result(featureRepo.getFeatureById(featureId), 2 minutes)
      displayAllfeature.foreach(i => println("Feature=======>", i))
      val displayIdStatus = Await.result(featureRepo.getFeatureById(featureId), 2 minutes)
      displayIdStatus.foreach(i => println("FeatureStatus=======>", i))
    }
    }
  } 
开发者ID:boniface,项目名称:opsapi,代码行数:33,代码来源:FeatureRepositoryTest.scala


示例12: CancellationRepositoryTest

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

import domain.Cancellation
import org.scalatest.{FeatureSpec, GivenWhenThen}
import repositories.CancellationRepository

import scala.concurrent.Await


class CancellationRepositoryTest extends FeatureSpec with GivenWhenThen {

  feature("Create cancellation") {
    info("Add an cancellation")
    scenario("Add new cancellation ") {
      Given("Given cancellationId,reason,date,status,document,cancellationOf,relatedLot")
      val cancellationId = "12345"
      val reason = "Nothing"
      val date = "26/18/12"
      val status = "Done"
      val documents = "Documnets"
      val cancellationOf = "Bond"
      val relatedLot = "related"

      Then("Add cancellation ")
      val cancellation = Cancellation(cancellationId,reason,date,status,documents,cancellationOf,cancellationOf,relatedLot)
      val cancellationRepo = CancellationRepository
      cancellationRepo.save(cancellation)
      Then("Display All ")
      val displayAllcancelled = Await.result(cancellationRepo.getCancellationById(cancellationId), 2 minutes)
      displayAllcancelled.foreach(i => println("Cancellation=======>", i))
      val displayIdStatus = Await.result(cancellationRepo.getCancellationById(cancellationId), 2 minutes)
      displayIdStatus.foreach(i => println("CancellationStatus=======>", i))
    }
  }

} 
开发者ID:boniface,项目名称:opsapi,代码行数:37,代码来源:CancellationRepositoryTest.scala


示例13: RevisionRepositoryTest

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

import domain.{Revision}
import org.scalatest.{FeatureSpec, GivenWhenThen}

import scala.collection.mutable
import scala.concurrent.Await


class RevisionRepositoryTest extends FeatureSpec with GivenWhenThen{

  feature("Create revision") {
    info("Add revision")
    scenario("Add new revision ") {
      Given("Given all data")
      val revisionId = "12345678"
      val date = "25/12/2016"
      val changes = mutable.MutableList[Object]()

      Then("Add guarantee ")
      val revision = Revision(revisionId, date, changes)
      val revisionRepo = RevisionRepository
      revisionRepo.save(revision)
      Then("Display All ")
      val displayAllRevision= Await.result(revisionRepo.getGuaranteeById(revisionId), 2 minutes)
      displayAllRevision.foreach(i => println("Revision=======>", i))
      val displayIdStatus = Await.result(revisionRepo.getGuaranteeById(revisionId), 2 minutes)
      displayIdStatus.foreach(i => println("RevisionStatus=======>", i))
    }
  }
} 
开发者ID:boniface,项目名称:opsapi,代码行数:32,代码来源:RevisionRepositoryTest.scala


示例14: ConfigurationTest

//设置package包名称以及导入依赖的类
package com.microsoft.azure.iot.iothubreact.checkpointing

import com.microsoft.azure.iot.iothubreact.checkpointing.backends.cassandra.lib.Auth
import com.typesafe.config.{Config, ConfigException}
import org.mockito.Mockito._
import org.scalatest.mockito.MockitoSugar
import org.scalatest.{FeatureSpec, GivenWhenThen}

class ConfigurationTest extends FeatureSpec with GivenWhenThen with MockitoSugar {

  info("As a configured instance")
  info("I want logic around returned values to be consistent with application expectations")

  val confPath = "iothub-react.checkpointing."
  Feature("Configuration Cassandra authorization") {

    Scenario("Only one of username or password is supplied") {
      var cfg = mock[Config]
      when(cfg.getString(confPath + "storage.cassandra.username")).thenReturn("username")
      when(cfg.getString(confPath + "storage.cassandra.password")).thenThrow(new ConfigException.Missing("path"))
      assert(new CPConfiguration(cfg).cassandraAuth == None)

      cfg = mock[Config]
      when(cfg.getString(confPath + "storage.cassandra.username")).thenThrow(new ConfigException.Missing("path"))
      when(cfg.getString(confPath + "storage.cassandra.password")).thenReturn("password")
      assert(new CPConfiguration(cfg).cassandraAuth == None)
    }

    Scenario("Both username and password are supplied") {
      var cfg = mock[Config]
      when(cfg.getString(confPath + "storage.cassandra.username")).thenReturn("username")
      when(cfg.getString(confPath + "storage.cassandra.password")).thenReturn("password")
      assert(new CPConfiguration(cfg).cassandraAuth == Some(Auth("username", "password")))
    }
  }

  Feature("Storage namespace") {

    Scenario("Cassandra has a special namespace value") {
      var cfg = mock[Config]
      when(cfg.getString(confPath + "storage.namespace")).thenReturn("")

      when(cfg.getString(confPath + "storage.backendType")).thenReturn("anythingbutcassandra")
      assert(new CPConfiguration(cfg).storageNamespace == "iothub-react-checkpoints")

      when(cfg.getString(confPath + "storage.backendType")).thenReturn("AZUREBLOB")
      assert(new CPConfiguration(cfg).storageNamespace == "iothub-react-checkpoints")

      when(cfg.getString(confPath + "storage.backendType")).thenReturn("CASSANDRA")
      assert(new CPConfiguration(cfg).storageNamespace == "iothub_react_checkpoints")
    }
  }
} 
开发者ID:Azure,项目名称:toketi-iothubreact,代码行数:54,代码来源:ConfigurationTest.scala


示例15: CPConfigurationTest

//设置package包名称以及导入依赖的类
// Copyright (c) Microsoft. All rights reserved.

package com.microsoft.azure.iot.iothubreact.checkpointing

import com.microsoft.azure.iot.iothubreact.checkpointing.backends.cassandra.lib.Auth
import com.typesafe.config.{Config, ConfigException}
import org.mockito.Mockito._
import org.scalatest.mockito.MockitoSugar
import org.scalatest.{FeatureSpec, GivenWhenThen}

class CPConfigurationTest extends FeatureSpec with GivenWhenThen with MockitoSugar {

  info("As a configured instance")
  info("I want logic around returned values to be consistent with application expectations")

  val confPath = "iothub-react.checkpointing."
  Feature("Configuration Cassandra authorization") {

    Scenario("Only one of username or password is supplied") {
      var cfg = mock[Config]
      when(cfg.getString(confPath + "storage.cassandra.username")).thenReturn("username")
      when(cfg.getString(confPath + "storage.cassandra.password")).thenThrow(new ConfigException.Missing("path"))
      assert(new CPConfiguration(cfg).cassandraAuth == None)

      cfg = mock[Config]
      when(cfg.getString(confPath + "storage.cassandra.username")).thenThrow(new ConfigException.Missing("path"))
      when(cfg.getString(confPath + "storage.cassandra.password")).thenReturn("password")
      assert(new CPConfiguration(cfg).cassandraAuth == None)
    }

    Scenario("Both username and password are supplied") {
      var cfg = mock[Config]
      when(cfg.getString(confPath + "storage.cassandra.username")).thenReturn("username")
      when(cfg.getString(confPath + "storage.cassandra.password")).thenReturn("password")
      assert(new CPConfiguration(cfg).cassandraAuth == Some(Auth("username", "password")))
    }
  }

  Feature("Storage namespace") {

    Scenario("Cassandra has a special namespace value") {
      var cfg = mock[Config]
      when(cfg.getString(confPath + "storage.namespace")).thenReturn("")

      when(cfg.getString(confPath + "storage.backendType")).thenReturn("anythingbutcassandra")
      assert(new CPConfiguration(cfg).storageNamespace == "iothub-react-checkpoints")

      when(cfg.getString(confPath + "storage.backendType")).thenReturn("AZUREBLOB")
      assert(new CPConfiguration(cfg).storageNamespace == "iothub-react-checkpoints")

      when(cfg.getString(confPath + "storage.backendType")).thenReturn("CASSANDRA")
      assert(new CPConfiguration(cfg).storageNamespace == "iothub_react_checkpoints")
    }
  }
} 
开发者ID:Azure,项目名称:toketi-iothubreact,代码行数:56,代码来源:CPConfigurationTest.scala


示例16: SparkBirthdays

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

import main.scala.desafio.SparkBirthdays
import org.scalatest.{FeatureSpec, GivenWhenThen}


class SparkBirthdays$Test extends FeatureSpec with GivenWhenThen {

  feature("Calling main method when there are no application.config file"){
    scenario("Not passing any input CSV file nor output path"){
      assertThrows[Exception] {
        SparkBirthdays.main(Array[String]())
      }
    }
    scenario("Not passing any input CSV file but passing output path"){
      assertThrows[Exception] {
        SparkBirthdays.main(Array("Out.json"))
      }

    }
    scenario("Passing an MISSING input CSV and output path"){
      assertThrows[Exception] {
        SparkBirthdays.main(Array("data/NonExisting.csv", "Out.json"))
      }
    }
    scenario("Passing both input CSV and output path"){
      SparkBirthdays.main(Array("data/Mock.csv","Out.json"))
    }
  }
} 
开发者ID:gabrielmathias,项目名称:desafio,代码行数:31,代码来源:SparkBirthdays$Test.scala


示例17: beforeEach

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

import java.util.UUID

import org.scalatest.concurrent.{Eventually, ScalaFutures}
import org.scalatest.{BeforeAndAfterEach, FeatureSpec, GivenWhenThen, Matchers}
import play.api.http.Status
import uk.gov.hmrc.fileupload.read.envelope.Repository
import uk.gov.hmrc.mongo.MongoSpecSupport

import scala.concurrent.ExecutionContext.Implicits._

trait IntegrationSpec extends FeatureSpec with GivenWhenThen  with ScalaFutures
  with Matchers with Status with Eventually with FakeConsumingService
  with BeforeAndAfterEach with MongoSpecSupport {

  val nextId = () => UUID.randomUUID().toString

  override def beforeEach {
    new Repository(mongo).removeAll().futureValue
  }

  override def afterAll {
    mongo.apply().drop.futureValue
  }
} 
开发者ID:hmrc,项目名称:file-upload-nos3,代码行数:27,代码来源:IntegrationSpec.scala


示例18: ToguruClientSpec

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

import org.scalatest.mockito.MockitoSugar
import org.scalatest.{FeatureSpec, _}
import toguru.api.Activations.Provider

class ToguruClientSpec extends FeatureSpec with MustMatchers with MockitoSugar {

  val mockClientInfo = ClientInfo()

  val mockClientProvider: ClientInfo.Provider[String] = _ => mockClientInfo

  def activationProvider(activations: Activations = DefaultActivations, health: Boolean): Activations.Provider =
    new Provider {
      def healthy() = health
      def apply() = activations
    }

  def toguruClient(clientProvider: ClientInfo.Provider[String] = mockClientProvider, activations: Activations.Provider) =
    new ToguruClient(clientProvider, activations)


  feature("health check") {
    scenario("activations provider is healthy") {
      val client = toguruClient(activations = activationProvider(health = true))

      client.healthy() mustBe true
    }

    scenario("activations provider is unhealthy") {
      val client = toguruClient(activations = activationProvider(health = false))

      client.healthy() mustBe false
    }
  }

  feature("client info provider") {
    scenario("client info requested") {
      val myActivations = mock[Activations]
      val myInfo: ClientInfo = ClientInfo().withAttribute("user", "me")
      val client = toguruClient(
        clientProvider = _ => myInfo,
        activations = activationProvider(health = true, activations = myActivations))

      val toggling = client.apply("client")

      toggling.activations mustBe myActivations
      toggling.client mustBe myInfo
    }
  }
} 
开发者ID:AutoScout24,项目名称:toguru-scala-client,代码行数:52,代码来源:ToguruClientSpec.scala


示例19: ConditionSpec

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

import org.scalatest.{FeatureSpec, _}

class ConditionSpec extends FeatureSpec with MustMatchers {

  feature("Off Condition") {
    scenario("can be created by API") {
      Condition.Off mustBe a[Condition]
    }
  }

  feature("On Condition") {
    scenario("can be created") {
      Condition.On mustBe a[Condition]
    }
  }

  feature("Rollout Range Condition") {
    scenario("can be created") {
      Condition.UuidRange(1 to 20) mustBe a[Condition]
    }
  }

  feature("Attribute Condition") {
    scenario("can be created") {
      Condition.Attribute("myAttribute", "one", "two", "three") mustBe a[Condition]
    }
  }

  feature("Combined Condition") {
    scenario("can be created") {
      import Condition._
      Condition(
        UuidRange(1 to 20),
        Attribute("myAttribute", "one", "two", "three")) mustBe a[Condition]
    }

    scenario("when created from one condition yields the given condition") {
      Condition(Condition.Off) mustBe Condition.Off
    }

    scenario("when created from empty conditions yields Condition 'On'") {
      Condition() mustBe Condition.On
    }
  }
} 
开发者ID:AutoScout24,项目名称:toguru-scala-client,代码行数:48,代码来源:ConditionSpec.scala


示例20: ToggleSpec

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

import org.scalatest.{FeatureSpec, MustMatchers}
import toguru.test.TestActivations

class ToggleSpec extends FeatureSpec with MustMatchers {

  val emptyToggleInfo = TogglingInfo(ClientInfo(), new TestActivations.Impl()())

  feature("Toggle creation") {
    scenario("default condition is false") {
      val toggle1 = Toggle("toggle-1")
      implicit val toggleInfo = emptyToggleInfo

      toggle1.isOn mustBe false
      toggle1.isOff mustBe true
    }

    scenario("default condition is respected") {
      val toggle1 = Toggle("toggle-1", default = Condition.On)
      implicit val toggleInfo = emptyToggleInfo

      toggle1.isOn mustBe true
      toggle1.isOff mustBe false
    }
  }
} 
开发者ID:AutoScout24,项目名称:toguru-scala-client,代码行数:28,代码来源:ToggleSpec.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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