Skip to content
Permalink
Browse files

Room - ProcessQuit

  • Loading branch information...
bobbymcr committed Dec 22, 2018
1 parent 532bdac commit dca9d00700b5112201bb49e71dcc9dc448f77e50
Showing with 21 additions and 0 deletions.
  1. +5 −0 core/src/Room.cs
  2. +15 −0 core/test/RoomTest.cs
  3. +1 −0 core/test/TestRoom.cs
@@ -59,6 +59,11 @@ public void Add(string name, Item item)
this.items.Add(name, item);
}

public void End(string text)
{
this.bus.Send(new EndOfGameMessage(text));
}

protected virtual void EnterCore()
{
}
@@ -470,6 +470,21 @@ public void RequestInventory()
inv.Should().Be(1);
}

[Fact]
public void ProcessQuit()
{
MessageBus bus = new MessageBus();
string quitText = null;
Action<EndOfGameMessage> subscriber = m => quitText = m.Text;
bus.Subscribe(subscriber);
Room room = new TestRoom(bus);

room.Enter();
bus.Send(new SentenceMessage(new Word("quit", "QUIT"), new Word(string.Empty, string.Empty)));

quitText.Should().Be("You quit. Game over.");
}

private static void TestSend(Word verb, Word noun, string expectedOutput)
{
MessageBus bus = new MessageBus();
@@ -46,6 +46,7 @@ protected override void EnterCore()
this.Register("inventory", (_, __) => this.Inventory());
this.Register("drop", this.Drop);
this.Register("go", this.Go);
this.Register("quit", (_, __) => this.End("You quit. Game over."));
}

protected override bool LookAtCore(Word noun)

0 comments on commit dca9d00

Please sign in to comment.
You can’t perform that action at this time.