Skip to content
Permalink
Browse files

Inventory - RemoveOneItem

  • Loading branch information...
bobbymcr committed Dec 22, 2018
1 parent 96aa4f3 commit 3847bb4910d198e5da0ede62ecb2f6a3598114dd
Showing with 23 additions and 0 deletions.
  1. +2 −0 core/src/Inventory.cs
  2. +21 −0 core/test/InventoryTest.cs
@@ -41,6 +41,8 @@ public void Add(string key, Item item)
this.items.Add(key, item);
}

public Item Remove(string key) => this.items.Remove(key);

private void Show()
{
this.Output("You are carrying:");
@@ -262,6 +262,27 @@ public void TakeItemAfterDispose()
messages.Should().BeEmpty();
}

[Fact]
public void RemoveOneItem()
{
MessageBus bus = new MessageBus();
List<string> messages = new List<string>();
bus.Subscribe<OutputMessage>(m => messages.Add(m.Text));
Items items = new Items(bus);
using (Inventory inv = new Inventory(bus))
{
Item expected = new TestItem(bus);
inv.Add("key", expected);

Item removed = inv.Remove("key");
bus.Send(new ShowInventoryMessage());

messages.Should().Equal("You are carrying:", "(nothing)");
items.Look("{0}").Should().Be(0);
removed.Should().BeSameAs(expected);
}
}

private sealed class TestItem : Item
{
private readonly bool canDrop;

0 comments on commit 3847bb4

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