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

Scala Assertions类代码示例

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

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



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

示例1: CodecTestUtils

//设置package包名称以及导入依赖的类
package wow.common.codecs

import org.scalatest.{Assertion, Assertions, Matchers}
import scodec.Attempt.{Failure, Successful}
import scodec.bits.BitVector
import scodec.{Codec, DecodeResult}


object CodecTestUtils extends Assertions with Matchers {
  def decode[A](bits: BitVector, expectedValue: A)(implicit codec: Codec[A]): Assertion = {
    codec.decode(bits) match {
      case Successful(DecodeResult(x, remainder)) if remainder.nonEmpty =>
        fail(s"non empty remainder: $x / $remainder")
      case Successful(DecodeResult(parsedValue, BitVector.empty)) =>
        parsedValue shouldEqual expectedValue
      case Failure(err) => fail(err.toString())
    }
  }

  def encode[A](expectedBits: BitVector, value: A)(implicit codec: Codec[A]): Assertion = {
    codec.encode(value) match {
      case Successful(bits) =>
        bits.toHex shouldEqual expectedBits.toHex
        bits shouldEqual expectedBits
      case Failure(err) => fail(err.toString())
    }
  }

} 
开发者ID:SKNZ,项目名称:SpinaciCore,代码行数:30,代码来源:CodecTestUtils.scala


示例2: Utf8ExtractorTest

//设置package包名称以及导入依赖的类
package sds.classfile.constant_pool

import org.junit.Test
import org.scalatest.Assertions
import sds.classfile.constant_pool.Utf8ValueExtractor.extract

class Utf8ExtractorTest extends Assertions {
    val info: Array[ConstantInfo] = Array(
        new Utf8Info("utf8"), new NumberInfo(ConstantInfo.INTEGER, 0), new NumberInfo(ConstantInfo.FLOAT, 0.0f),
        new NumberInfo(ConstantInfo.LONG, 0L), new NumberInfo(ConstantInfo.DOUBLE, 0.0), new StringInfo(1),
        new HandleInfo(1, 1), new InvokeDynamicInfo(1, 1), new ConstantInfoAdapter(),
        new Utf8Info("java/lang/Object"), new ClassInfo(10), new MemberInfo(ConstantInfo.FIELD, 11, 1),
        new Utf8Info("([[Ljava/util/List;Ljava/lang/System;)V"), new NameAndTypeInfo(1, 13), new TypeInfo(13)
    )

    @Test
    def extractTest(): Unit = {
        assert(extract(info(0), info) === "utf8")
        assert(extract(info(1), info) === "0")
        assert(extract(info(2), info) === "0.0")
        assert(extract(info(3), info) === "0")
        assert(extract(info(4), info) === "0.0")
        assert(extract(info(5), info) === "utf8")
        assert(extract(info(6), info) === "utf8")
        assert(extract(info(7), info) === "utf8")
        intercept[IllegalArgumentException] {
            extract(info(8), info) === ""
        }
        assert(extract(info(10), info) === "Object")
        assert(extract(info(11), info) === "Object.utf8")
        assert(extract(info(13), info) === "utf8|(java.util.List[][],System)void")
        assert(extract(info(14), info) === "(java.util.List[][],System)void")
    }
} 
开发者ID:g1144146,项目名称:sds_for_scala,代码行数:35,代码来源:Utf8ExtractorTest.scala


示例3: AttributeInfoTest

//设置package包名称以及导入依赖的类
package sds.classfile.attribute

import org.junit.Test
import org.scalatest.Assertions
import sds.classfile.constant_pool._

class AttributeInfoTest extends Assertions {
    val info: Array[ConstantInfo] = Array(
        new Utf8Info("utf8"), new NumberInfo(ConstantInfo.INTEGER, 0), new NumberInfo(ConstantInfo.FLOAT, 0.0f),
        new NumberInfo(ConstantInfo.LONG, 0L), new NumberInfo(ConstantInfo.DOUBLE, 0.0), new StringInfo(1),
        new HandleInfo(1, 1), new InvokeDynamicInfo(1, 1), new ConstantInfoAdapter(),
        new Utf8Info("java/lang/Object"), new ClassInfo(10), new MemberInfo(ConstantInfo.FIELD, 11, 1),
        new Utf8Info("([[Ljava/util/List;Ljava/lang/System;)V"), new NameAndTypeInfo(1, 13), new TypeInfo(13)
    )

    @Test
    def constantValueTest(): Unit = {
        val const: ConstantValue = new ConstantValue("Hoge")
        assert(const.toString() === "ConstantValue: Hoge")
    }

    @Test
    def enclosingMethodTest(): Unit = {
        val enc: EnclosingMethod = new EnclosingMethod(11, 13, info)
        val enc2: EnclosingMethod = new EnclosingMethod(11, 0, info)
        assert(enc.toString() === "EnclosingMethod: Object ([[Ljava/util/List;Ljava/lang/System;)V")
        assert(enc2.toString() === "EnclosingMethod: Object ")
    }

    @Test
    def signatureTest(): Unit = {
        val sig: Signature = new Signature("hoge")
        assert(sig.toString() === "Signature: hoge")
    }

    @Test
    def sourceFileTest(): Unit = {
        val source: SourceFile = new SourceFile("Hoge.java")
        assert(source.toString() === "SourceFile: Hoge.java")
    }

    @Test
    def deprecatedTest(): Unit = {
        val dep: Deprecated = new Deprecated();
        assert(dep.toString() === "Deprecated")
    }

    @Test
    def syntheticTest(): Unit = {
        val syn: Synthetic = new Synthetic();
        assert(syn.toString() === "Synthetic")
    }
} 
开发者ID:g1144146,项目名称:sds_for_scala,代码行数:54,代码来源:AttributeInfoTest.scala


示例4: DescriptorParserTest

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

import org.junit.Test
import org.scalatest.Assertions
import sds.util.{DescriptorParser => DP}

class DescriptorParserTest extends Assertions {
    @Test
    def parseTest() {
        assert(DP.parse("B") === "byte")
        assert(DP.parse("C") === "char")
        assert(DP.parse("D") === "double")
        assert(DP.parse("F") === "float")
        assert(DP.parse("I") === "int")
        assert(DP.parse("J") === "long")
        assert(DP.parse("S") === "short")
        assert(DP.parse("Z") === "boolean")
        assert(DP.parse("V") === "void")
        assert(DP.parse("[I") === "int[]")
        assert(DP.parse("Ljava/lang/String;") === "String")
        assert(DP.parse("[[[Ljava/lang/Object;") === "Object[][][]")
        assert(DP.parse("Lorg/scalatest/Assertions;") === "org.scalatest.Assertions")
        assert(DP.parse("[[[Lorg/scalatest/Assertions;") === "org.scalatest.Assertions[][][]")
        assert(DP.parse("(IIIR)B") === "(int,int,int)byte")
        assert(DP.parse("(IILjava/io/File;IR)Ljava/net/URL") === "(int,int,java.io.File,int)java.net.URL")
        assert(DP.parse("Ljava/util/List<TK;>;") === "java.util.List<K>")
        assert(DP.parse("Ljava/lang/Class<*>") === "Class< ? >")

        val case1: String = DP.parse("<K:Ljava/lang/Object;>Ljava/lang/Object;Ljava/lang/Runnable;", true)
        val case2: String = DP.parse("""<U:Ljava/lang/Object;T::Ljava/lang/Runnable;A:Ljava/lang/String;
                                     R::Ljava/lang/Runnable;:Ljava/lang/Appendable;S:Ljava/lang/Thread;>()V""", true)
        val case3: String = DP.parse("<+Ljava/lang/Object;>Ljava/util/List;")
        assert(case1 === "<K extends Object>Object,Runnable")
        assert(case2 === "<U extends Object,T extends Runnable," + 
                         "A extends String,R extends Runnable & Appendable,S extends Thread>()void")
        assert(case3 === "<? extends Object>java.util.List")
    }

    @Test
    def removeLangPrefixTest() {
        assert(DP.removeLangPrefix("java.lang.String") === "String")
        assert(DP.removeLangPrefix("java.lang.Math.sqrt") === "Math.sqrt")

        val case1: String = "java.lang.annotation.Annotation"
        val case2: String = "java.lang.instrument.Instrumentation"
        val case3: String = "java.lang.invoke.MethodHandle"
        val case4: String = "java.lang.management.MemoryUsage"
        val case5: String = "java.lang.ref.Reference"
        val case6: String = "java.lang.reflect.Method"
        assert(DP.removeLangPrefix(case1) === case1)
        assert(DP.removeLangPrefix(case2) === case2)
        assert(DP.removeLangPrefix(case3) === case3)
        assert(DP.removeLangPrefix(case4) === case4)
        assert(DP.removeLangPrefix(case5) === case5)
        assert(DP.removeLangPrefix(case6) === case6)
    }
} 
开发者ID:g1144146,项目名称:sds_for_scala,代码行数:58,代码来源:DescriptorParserTest.scala


示例5: MultiArgsStringBuilderTest

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

import org.junit.Test
import org.scalatest.Assertions
import sds.util.{MultiArgsStringBuilder => Builder}

class MultiArgsStringBuilderTest extends Assertions {
    @Test
    def toStringTest() {
        val b: Builder = new Builder()
        assert(b.toString.equals(""))
        b.append("test")
        assert(b.toString.equals("test"))
        b.append(1)
        assert(b.toString.equals("test1"))
        b.append(1.0)
        assert(b.toString.equals("test11.0"))
        b.append(", ", 1.2, 0.10)
        assert(b.toString.equals("test11.0, 1.20.1"))
    }

    @Test
    def toStringTest2() {
        val b: Builder = new Builder("init")
        assert(b.toString.equals("init"))
    }
} 
开发者ID:g1144146,项目名称:sds_for_scala,代码行数:28,代码来源:MultiArgsStringBuilderTest.scala


示例6: SDSTest

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

import org.junit.Test
import org.scalatest.Assertions

class SDSTest extends Assertions {
    @Test
    def jarFileIOExceptionTest(): Unit = {
        new SDS(Array("xxx.jar"))
    }

//    @Test
//    def classfileRunTest(): Unit = {
//        new SDS(Array("Hello.class")).run()
//    }
} 
开发者ID:g1144146,项目名称:sds_for_scala,代码行数:17,代码来源:SDSTest.scala


示例7: assertEmpty

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

import org.scalatest.Assertions

import org.wartremover.test.WartTestTraverser

trait ResultAssertions extends Assertions {

  def assertEmpty(result: WartTestTraverser.Result) = {
    assertResult(List.empty, "result.errors")(result.errors)
    assertResult(List.empty, "result.warnings")(result.warnings)
  }

  def assertError(result: WartTestTraverser.Result)(message: String) = assertErrors(result)(message, 1)

  def assertErrors(result: WartTestTraverser.Result)(message: String, times: Int) = {
    assertResult(List.fill(times)(message), "result.errors")(result.errors.map(skipTraverserPrefix))
    assertResult(List.empty, "result.warnings")(result.warnings.map(skipTraverserPrefix))
  }

  def assertWarnings(result: WartTestTraverser.Result)(message: String, times: Int) = {
    assertResult(List.empty, "result.errors")(result.errors.map(skipTraverserPrefix))
    assertResult(List.fill(times)(message), "result.warnings")(result.warnings.map(skipTraverserPrefix))
  }

  private val messageFormat = """^\[wartremover:\S+\] (.+)$""".r

  private def skipTraverserPrefix(msg: String) = msg match {
    case messageFormat(rest) => rest
    case s => s
  }
} 
开发者ID:wartremover,项目名称:wartremover-contrib,代码行数:34,代码来源:ResultAssertions.scala


示例8: lazyAssert

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

import org.scalatest.Assertions

trait LazyAssert {
  self: Assertions =>

  def lazyAssert(predicate: Boolean, msg: => String): Unit = {
    assert(predicate, LazyMessage(msg))
  }
}

class LazyMessage(msg: => String) {
  override def toString: String = msg
}

object LazyMessage {
  def apply(msg: => String): LazyMessage = new LazyMessage(msg)
} 
开发者ID:hammerlab,项目名称:test-utils,代码行数:20,代码来源:LazyAssert.scala


示例9: ProposicoesServiceTest

//设置package包名称以及导入依赖的类
package com.nakamura.camara.proposicoes

import com.nakamura.camara.proposicoes.proposicao.ListarProposicoesRequest
import org.apache.spark.sql.{SaveMode, SparkSession}
import org.junit.Test
import org.scalatest.Assertions

class ProposicoesServiceTest extends Assertions {
  private val spark = SparkSession
    .builder()
    .appName("ProposicoesServiceTest")
    .master("local[*]")
    .getOrCreate()
  private val service = new ProposicoesService(spark)

  @Test
  def testListarProposicoes(): Unit = {
    val request = ListarProposicoesRequest(ano = 2017, sigla = "PEC")
    val proposicoesTry = service.listarProposicoes(request)
    assert(proposicoesTry.isSuccess)
    assert(proposicoesTry.get.nonEmpty)
  }

  @Test
  def testListarProposicoesFailure(): Unit = {
    val invalidRequest = ListarProposicoesRequest()
    val proposicoesTry = service.listarProposicoes(invalidRequest)
    assert(proposicoesTry.isFailure)
  }

  @Test
  def testListarSiglasProposicoes(): Unit = {
    val siglasTry = service.listSiglasTipoProposioes()
    assert(siglasTry.isSuccess)
    assert(siglasTry.get.nonEmpty)
  }

  @Test
  def runFetchAndStoreHistoricalData(): Unit = {
    service.fetchAndStoreHistoricalData(2010 to 2017 by 1, SaveMode.Ignore)
  }
} 
开发者ID:akionakamura,项目名称:camara,代码行数:43,代码来源:ProposicoesServiceTest.scala


示例10: DeputadosServiceTest

//设置package包名称以及导入依赖的类
package com.nakamura.camara.deputados

import org.apache.spark.sql.{SaveMode, SparkSession}
import org.junit.Test
import org.scalatest.Assertions

class DeputadosServiceTest extends Assertions {
  private val spark = SparkSession
    .builder()
    .appName("DeputadosServiceTest")
    .master("local[*]")
    .getOrCreate()
  private val service = new DeputadosService(spark)

  @Test
  def testListarSiglasProposicoes(): Unit = {
    val deputadosTry = service.getDeputados()
    assert(deputadosTry.isSuccess)
    assert(deputadosTry.get.nonEmpty)
  }
  @Test
  def testFetchAndStoreDeputadosData(): Unit = {
    val deputadosTry = service.fetchAndStoreDeputadosData(SaveMode.Ignore)
  }
} 
开发者ID:akionakamura,项目名称:camara,代码行数:26,代码来源:DeputadosServiceTest.scala


示例11: TransactionsOrderingSpecification

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

import com.wavesplatform.state2.ByteStr
import org.scalatest.{Assertions, Matchers, PropSpec}
import scorex.account.{Address, PrivateKeyAccount}
import scorex.consensus.TransactionsOrdering
import scorex.transaction.PaymentTransaction
import scorex.transaction.assets.TransferTransaction

import scala.util.Random

class TransactionsOrderingSpecification extends PropSpec with Assertions with Matchers {

  property("TransactionsOrdering.InBlock should sort correctly") {
    val txsDifferentById = (0 to 3).map(i =>
      TransferTransaction.create(None, PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 5, None, 125L, Array(i.toByte)).right.get).sortBy(t => t.id.base58)

    val correctSeq = txsDifferentById ++ Seq(
      TransferTransaction.create(None, PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 1, None, 125L, Array.empty).right.get,
      TransferTransaction.create(None, PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 2, None, 124L, Array.empty).right.get,
      TransferTransaction.create(None, PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 1, None, 124L, Array.empty).right.get,
      TransferTransaction.create(None, PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 2, Some(ByteStr.empty), 124L, Array.empty).right.get,
      TransferTransaction.create(None, PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 1, Some(ByteStr.empty), 124L, Array.empty).right.get)

    val sorted = Random.shuffle(correctSeq).sorted(TransactionsOrdering.InBlock)

    sorted shouldBe correctSeq
  }

  property("TransactionsOrdering.InUTXPool should sort correctly") {
    val txsDifferentById = (0 to 3).map(i =>
      TransferTransaction.create(None, PrivateKeyAccount(Array.fill(32)(0)),Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 5, None, 125L, Array(i.toByte)).right.get).sortBy(t => t.id.base58)

    val correctSeq = txsDifferentById ++ Seq(
      TransferTransaction.create(None, PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 1, None, 124L, Array.empty).right.get,
      TransferTransaction.create(None, PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 1, None, 123L, Array.empty).right.get,
      TransferTransaction.create(None, PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 2, None, 123L, Array.empty).right.get,
      TransferTransaction.create(None, PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 1, Some(ByteStr.empty), 124L, Array.empty).right.get,
      TransferTransaction.create(None, PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 2, Some(ByteStr.empty), 124L, Array.empty).right.get)

    val sorted = Random.shuffle(correctSeq).sorted(TransactionsOrdering.InUTXPool)

    sorted shouldBe correctSeq
  }

  property("TransactionsOrdering.InBlock should sort txs by decreasing block timestamp") {
    val correctSeq = Seq(
      PaymentTransaction.create(PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 1, 124L).right.get,
      PaymentTransaction.create(PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 1, 123L).right.get)

    Random.shuffle(correctSeq).sorted(TransactionsOrdering.InBlock) shouldBe correctSeq
  }

  property("TransactionsOrdering.InUTXPool should sort txs by ascending block timestamp") {
    val correctSeq = Seq(
      PaymentTransaction.create(PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 1, 123L).right.get,
      PaymentTransaction.create(PrivateKeyAccount(Array.fill(32)(0)), Address.fromString("3MydsP4UeQdGwBq7yDbMvf9MzfB2pxFoUKU").right.get, 100000, 1, 124L).right.get)
    Random.shuffle(correctSeq).sorted(TransactionsOrdering.InUTXPool) shouldBe correctSeq
  }
} 
开发者ID:wavesplatform,项目名称:Waves,代码行数:61,代码来源:TransactionsOrderingSpecification.scala


示例12: assertStructurallyEqual

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

import org.scalatest.{Assertion, Assertions}

import scala.meta.Tree
import scala.meta.testkit.StructurallyEqual

package object macros {

  def assertStructurallyEqual(actual: Tree, expected: Tree): Assertion = {
    StructurallyEqual(actual, expected) match {
      case Left(diff) =>
        Assertions.fail(
          s"""Not Structurally equal:
             |$diff
             |Details:
             |${diff.detailed}""".stripMargin)
      case _ => Assertions.succeed
    }
  }
} 
开发者ID:LMnet,项目名称:scala-js-preact,代码行数:22,代码来源:package.scala


示例13: goOn

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

import java.awt.Robot

import org.openqa.selenium.support.ui.{ExpectedCondition, ExpectedConditions, WebDriverWait}
import org.openqa.selenium.{By, WebDriver, WebElement}
import org.scalatest.concurrent.{Eventually, IntegrationPatience}
import org.scalatest.selenium.WebBrowser
import org.scalatest.{Assertions, Matchers}
import uk.gov.hmrc.softdrinksindustrylevyfrontend.generic.WebPage


trait NavigationSugar extends WebBrowser with Eventually with Assertions with Matchers with IntegrationPatience {

  val robot = new Robot()

  def goOn(page: WebPage)(implicit webDriver: WebDriver) = {
    goTo(page)
    on(page)
  }

  def on(page: WebPage)(implicit webDriver: WebDriver) = {
    val wait = new WebDriverWait(webDriver, 5)
    wait.until(ExpectedConditions.presenceOfElementLocated(By.tagName("body")))
    assert(page.isCurrentPage, s"Page was not loaded: ${page.currentUrl}")
  }

  def notOn(page: WebPage)(implicit webDriver: WebDriver) = {
    eventually {
      webDriver.findElement(By.tagName("body"))
    }
    assertResult(false, s"\nDid not expect ${page.currentUrl} to be loaded") {
      page.isCurrentPage
    }
  }

  def loadPage()(implicit webDriver: WebDriver) = {
    val wait = new WebDriverWait(webDriver, 15)
    wait.until(
      new ExpectedCondition[WebElement] {
        override def apply(d: WebDriver) = d.findElement(By.tagName("body"))
      }
    )
  }

  def anotherTabIsOpened()(implicit webDriver: WebDriver) = {
    webDriver.getWindowHandles.size() should be(2)
  }

  def browserGoBack()(implicit webDriver: WebDriver) = {
    webDriver.navigate().back()
  }

  def switchToTabWith(marker: => Boolean)(implicit webDriver: WebDriver): Any = {
    windowHandles.foreach { newTab: String =>
      switch to window(newTab)
      if (marker) return
    }
    fail(s"Marker evaluation resolves false for current page")
  }
} 
开发者ID:hmrc,项目名称:soft-drinks-industry-levy-frontend,代码行数:62,代码来源:NavigationSugar.scala


示例14: MowerFactoryImplTest

//设置package包名称以及导入依赖的类
package com.xebia.mowitnow.model.factory

import com.xebia.mowitnow.model.Entity.{Orientation, Mower, Position}
import com.xebia.mowitnow.model.Factory.MowerFactoryImpl
import org.junit.Assert._
import org.junit.{Test, Before}
import org.scalatest.Assertions


class MowerFactoryImplTest  extends Assertions {

var mowerFactory: MowerFactoryImpl = null

@Before def initialize() {
  mowerFactory = new MowerFactoryImpl
}

@Test def testCreateMower() {
// Create mower with position 1,5 & orientation N
  assertEquals(Some(Mower(Position(1,5, Orientation.N))), mowerFactory.createMower("1 5 N"))
 //Try to create mower with unsupported orientation
  assertEquals(None, mowerFactory.createMower("1 5 A"))
}
} 
开发者ID:MOKEDDEM,项目名称:mow-itnow,代码行数:25,代码来源:MowerFactoryImplTest.scala


示例15: GroundFactoryImplTest

//设置package包名称以及导入依赖的类
package com.xebia.mowitnow.model.factory

import com.xebia.mowitnow.model.Entity.{Dimension, Ground}
import com.xebia.mowitnow.model.Factory.GroundFactoryImpl
import org.junit.Assert._
import org.junit.{Test, Before}
import org.scalatest.Assertions


class GroundFactoryImplTest extends Assertions {

  var groundFactory: GroundFactoryImpl = null

  @Before def initialize() {
    groundFactory = new GroundFactoryImpl
  }

  @Test def testCreateGround() {

    assertEquals(Some(Ground(Dimension(5, 5))), groundFactory.createGround("5 5"))
    assertEquals(Some(Ground(Dimension(5, 5))), groundFactory.createGround("  5   5  "))
    // Handling of unsupported format of ground
    assertEquals(None, groundFactory.createGround("A 5"))
    assertEquals(None, groundFactory.createGround(""))
    assertEquals(None, groundFactory.createGround("5.5 5"))
    assertEquals(None, groundFactory.createGround("-1 5"))
  }
} 
开发者ID:MOKEDDEM,项目名称:mow-itnow,代码行数:29,代码来源:GroundFactoryImplTest.scala


示例16: InstructionFactoryImplTest

//设置package包名称以及导入依赖的类
package com.xebia.mowitnow.model.factory

import com.xebia.mowitnow.model.Entity.{Instruction, Dimension, Ground}
import com.xebia.mowitnow.model.Factory.InstructionFactoryImpl
import org.junit.Assert._
import org.junit.{Test, Before}
import org.scalatest.Assertions


class InstructionFactoryImplTest extends Assertions {

  var instructionFactory: InstructionFactoryImpl = null

  @Before def initialize() {
    instructionFactory = new InstructionFactoryImpl
  }

  @Test def testCreateInstruction() {
    // Create a list of instruction with some unsupported instructions
    assertEquals(Some(List(Instruction.A, Instruction.A, Instruction.G, Instruction.A, Instruction.A, Instruction.D, Instruction.G, Instruction.A, Instruction.A)), instructionFactory.createInstruction("AAGEAADGAA"))
    // Create list of instruction from only unsupported instructions
    assertEquals(None, instructionFactory.createInstruction("IEH"))
  }
} 
开发者ID:MOKEDDEM,项目名称:mow-itnow,代码行数:25,代码来源:InstructionFactoryImplTest.scala


示例17: GroundServiceImplTest

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

import com.xebia.mowitnow.model.Entity.{Orientation, Position, Dimension, Ground}
import com.xebia.mowitnow.model.Factory.GroundFactoryImpl
import org.junit.Assert._
import org.junit.{Test, Before}
import org.scalatest.Assertions


class GroundServiceImplTest extends Assertions {
  implicit var groundFactory: GroundFactoryImpl = null
  var groundService: GroundServiceImpl = null

  @Before def initialize() {
    groundFactory = new GroundFactoryImpl
    groundService = new GroundServiceImpl
  }

  @Test def testIsInsideGround() {
    val ground = Ground(Dimension(5,5))
    assertEquals(true, groundService.isInsideGround(ground,Position(1,5,Orientation.N)))
    assertEquals(false, groundService.isInsideGround(ground,Position(-1,5,Orientation.N)))
    assertEquals(false, groundService.isInsideGround(ground,Position(5,6,Orientation.N)))
    assertEquals(false, groundService.isInsideGround(ground,Position(6,5,Orientation.N)))
  }
} 
开发者ID:MOKEDDEM,项目名称:mow-itnow,代码行数:27,代码来源:GroundServiceImplTest.scala


示例18: McCullochPittNeuronSuite

//设置package包名称以及导入依赖的类
package ch.santosalves.neurosimulator.impl

import org.scalatest.Assertions
import org.junit.Test
import java.util.Observer
import ch.santosalves.neurosimulator.api.NerveCell


class McCullochPittNeuronSuite extends Assertions {
  val neuron = new McCullochPittsNeuron("N1", 2.0)
  
  @Test def testIfNeuronShouldHaveN1ForName() {    
    assert(neuron.name === "N1")
  }

  @Test def testIfNeuronShouldHaveTheRightThreshold() {
//    val neuron = new McCullochPittNeuron("N1", 2.0)
    assert(neuron.threshold === 2.0)
  }

  @Test def testIfNeuronShouldTriggerOutputIfInputWeightIsHighterThanThreshold() {
  //  val neuron = new McCullochPittNeuron("N1", 2.0)

    neuron.triggerInput(3.0)

    var outputTriggered = 0
    
    neuron.addObserver(new Observer() {
      def update(arg0: java.util.Observable, arg1: java.lang.Object) = {
        assert(arg0.asInstanceOf[McCullochPittsNeuron].triggerFunction() === 1.0)
      }
    })

    assert(neuron.triggerFunction() === 1.0)
    assert(neuron.mustTriggerOutput === true)
  }
} 
开发者ID:sergio-alves,项目名称:NeuroSimulator,代码行数:38,代码来源:McCullochPittNeuronSuite.scala


示例19: SimpleSynapticLinkSuite

//设置package包名称以及导入依赖的类
package ch.santosalves.neurosimulator.impl

import org.junit.Test
import org.scalatest.Assertions
import ch.santosalves.neurosimulator.api.SynapticLink

class SimpleSynapticLinkSuite extends Assertions{
  val narray = Array[McCullochPittsNeuron](
    NerveCellFactory.createNerveCell(NerveCellTypes.McCullochAndPitts, "N1", 2).asInstanceOf[McCullochPittsNeuron],
    NerveCellFactory.createNerveCell(NerveCellTypes.McCullochAndPitts, "N2", 3).asInstanceOf[McCullochPittsNeuron])
  val synlnk = Array[SynapticLink](new SynapticLinkImpl("L1", narray(0), narray(1), 3.2))

  @Test def testInitialization() {
    assert(synlnk.size === 1)      
    narray(0).triggerInput(4)
    
    assert(narray(0).mustTriggerOutput === true)
    assert(synlnk(0).source.mustTriggerOutput === true)
    assert(synlnk(0).target.dendrites.head._1.mustTriggerOutput === true)   
    assert(synlnk(0).name.equals("L1") === true)    
    assert(synlnk(0).source.axoneTerminals.head._1.mustTriggerOutput === true)
  }
} 
开发者ID:sergio-alves,项目名称:NeuroSimulator,代码行数:24,代码来源:SimpleSynapticLinkSuite.scala


示例20: tearDownDynamo

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

import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType._
import com.gu.scanamo._
import com.gu.scanamo.syntax._
import com.ovoenergy.event.gateway.manager.dynamo.{GatewayIdentifier, Persistence}
import com.ovoenergy.event.gateway.manager.kafka.Retry
import com.ovoenergy.event.gateway.manager.util.LocalDynamoDB
import org.scalatest.Assertions
import com.ovoenergy.event.gateway.manager.dynamo.DynamoFormats

trait DynamoTesting extends Assertions {
  import DynamoFormats._

  val dynamoUrl    = "http://localhost:8000"
  val dynamoClient = LocalDynamoDB.client(dynamoUrl)

  val tableName   = "gatewayIdentifiers"
  val table       = Table[GatewayIdentifier](tableName)
  val retryConfig = Retry.RetryConfig(1, Retry.Backoff.retryImmediately)

  val servicePersistence = new Persistence(Persistence.Context(dynamoClient, tableName, retryConfig))

  def tearDownDynamo(): Unit = {
    dynamoClient.deleteTable(tableName)
  }

  def setupDynamo(): Unit = {
    val result = LocalDynamoDB.createTable(dynamoClient)(tableName)('id -> S)
    println(s"Created dynamo table. Table status is ${result.getTableDescription.getTableStatus}")
    // TODO I think we need to poll here until the table status is ACTIVE, or we might get occasional flakiness
  }
} 
开发者ID:ovotech,项目名称:comms-gateway-event-manager,代码行数:34,代码来源:DynamoTesting.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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