Skip to content

Commit

Permalink
added test for private talk
Browse files Browse the repository at this point in the history
  • Loading branch information
rssh committed Dec 17, 2011
1 parent 86220d9 commit 0a0ae41
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions p4/src/test/scala/com/example/p4/PrivateTalkFeatureSpec.scala
@@ -0,0 +1,33 @@
package com.example.p4


import com.example.p4.engine._;
import com.example.p4.engine.agents._;

import org.scalatest._;
import org.scalatest.matchers.ShouldMatchers;

class PrivateTalkFeatureSpec extends FeatureSpec
with GivenWhenThen
with ShouldMatchers
{

feature("private talk") {
scenario(" user A and B try to talk with each other " ) {
given("2 users, registered in registry")
val user1 = new HumanAgent("u1");
val user2 = new HumanAgent("u2");
TalkEngine.registry.add( user1 );
TalkEngine.registry.add( user2 );
TalkEngine.chooseAgent("u1","u2");
TalkEngine.chooseAgent("u2","u1");
when("message is send to all from one of them")
val testMessage = "test-message-1"
TalkEngine.dispatch("u1",testMessage);
then("others must see one in incoming")
val u2m = user1.giveMessageFor(user2.name);
assert(u2m.isDefined);
}
}

}

0 comments on commit 0a0ae41

Please sign in to comment.