package eu.xeppaka.scalalearn

import org.scalamock.scalatest.MockFactory
import org.scalatest.{BeforeAndAfterEach, FlatSpec, OneInstancePerTest}

class TestStub extends FlatSpec with BeforeAndAfterEach with MockFactory with OneInstancePerTest {
  var testMirror: TestMirror = _

  override def beforeEach(): Unit = {
    testMirror = stub[TestMirror]
    (testMirror.print(_: String)).when(*).onCall { s: String => println(s"stub call: $s") }
  }

  "blah1" should "blah" in {
    testMirror.print("123")
    testMirror.print2("123")
    (testMirror.print(_: String)).verify(*).once()
    (testMirror.print2(_: String)).verify(*).once()
  }

  "blah2" should "blah" in {
    testMirror.print("456")
    testMirror.print("567")
    (testMirror.print(_: String)).verify(*).twice()
  }
}
