Skip to content

Commit

Permalink
Items - SkipCustomActionForItemThatHasNoActions
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbymcr committed Dec 12, 2018
1 parent 9d5429b commit 8aee0a1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/Item.cs
Expand Up @@ -19,7 +19,7 @@ public bool Do(MessageBus bus, Word verb, Word noun)

protected virtual bool DoCore(MessageBus bus, Word verb, Word noun)
{
return true;
return false;
}
}
}
21 changes: 21 additions & 0 deletions core/test/ItemsTest.cs
Expand Up @@ -142,6 +142,27 @@ public void SkipCustomActionForItemThatCannotHandleIt()
messages.Should().ContainSingle().Which.Should().Be("Don't CONSUME the BALL");
}

[Fact]
public void SkipCustomActionForItemThatHasNoActions()
{
MessageBus bus = new MessageBus();
List<string> messages = new List<string>();
bus.Subscribe<OutputMessage>(m => messages.Add(m.Text));
Items items = new Items(bus);
items.Drop("ball", new TestItemNoActions());

items.Activate();
bus.Subscribe<SentenceMessage>(m => messages.Add($"Don't {m.Verb} the {m.Noun}"));
bus.Send(new SentenceMessage(new Word("eat", "CONSUME"), new Word("ball", "BALL")));

messages.Should().ContainSingle().Which.Should().Be("Don't CONSUME the BALL");
}

private sealed class TestItemNoActions : Item
{
public override string ShortDescription => "a dull item";
}

private sealed class TestItem : Item
{
public override string ShortDescription => "a test item";
Expand Down

0 comments on commit 8aee0a1

Please sign in to comment.