コード例 #1
0
  @Test
  public void user_text_starts_with_what_you_are_using() {
    Item original = makeMockItemWithIDAndName("originalItemID", "original item");
    Item target = makeMockItemWithIDAndName("targetItemID", "target item");
    UseWithSpecificItem action = new UseWithSpecificItem(original, target);

    action.trigger();

    assertThat(
        action.userText(), stringStartsWith("You use the original item with the target item. "));
  }
コード例 #2
0
  @Test
  public void user_text_starts_with_what_you_are_using_excluding_the_for_proper_nouns() {
    Item original = makeMockItemWithIDAndName("originalItemID", "Dave");
    when(original.properNoun()).thenReturn(true);
    Item target = makeMockItemWithIDAndName("targetItemID", "Ipswich");
    when(target.properNoun()).thenReturn(true);
    UseWithSpecificItem action = new UseWithSpecificItem(original, target);

    action.trigger();

    assertThat(action.userText(), stringStartsWith("You use Dave with Ipswich. "));
  }
コード例 #3
0
  @Test
  public void using_an_item_changes_the_user_text_to_the_use_with_message_of_the_target_item() {
    final Item original = mockery.mock(Item.class, "original");
    final Item target = mockery.mock(Item.class, "target");
    mockery.checking(
        new Expectations() {
          {
            ignoring(original);
            allowing(target).canBeUsedWith(original);
            will(returnValue(true));
            allowing(target).useWith(original);
            will(returnValue("use with text"));
            ignoring(target);
          }
        });
    UseWithSpecificItem action = new UseWithSpecificItem(original, target);

    action.trigger();

    assertThat(action.userText(), stringEndsWith("use with text"));
  }