/razpubs/test_src/com/razie/pub/test/TestAssetMgrTrait.scala

http://razpub.googlecode.com/ · Scala · 43 lines · 26 code · 11 blank · 6 comment · 0 complexity · c279ff22877f68ac9ec88bcf8256277e MD5 · raw file

  1. package com.razie.pub.test
  2. import com.razie.pub.assets._
  3. import com.razie.pub.base._
  4. import org.scalatest.junit._
  5. import razie.assets._
  6. import razie.base._
  7. // just to instantiate a trait
  8. class SampleAssetMgrTrait extends AssetMgrInjector {
  9. }
  10. // injected sample - has 1 type and 2 actions
  11. class SampleAJ extends AssetCmdInjection {
  12. val entityTypes = Array("Movie")
  13. val actions = Array(new ActionItem("organize"), new ActionItem("moveto"))
  14. def doAction (entityKey:AssetKey, entity:Referenceable, action:String, ctx:ScriptContext) : AnyRef = {
  15. println(action)
  16. "Ok."
  17. }
  18. }
  19. class TestAssetMgrTrait extends JUnit3Suite {
  20. type fun = (AssetKey, Referenceable, String, ScriptContext) => AnyRef
  21. private[this] implicit def str2ActionI (s:String) : ActionItem = new ActionItem (s)
  22. def testActionItem = {
  23. val am = new SampleAssetMgrTrait
  24. am.inject(new SampleAJ)
  25. // am.inject("Movie","organize",111)
  26. //am.inject("Movie","moveto",println ("moveto" + _ + _ + _ )))
  27. val aa = am.injections("Movie")
  28. println ("A: " + (aa mkString ","))
  29. // Assert.assertTrue(idx.get1k("Movie")==List("organize", "moveto"))
  30. //Assert.assertTrue(idx.get2("Movie","organize") == Some(111))
  31. }
  32. }