public Treasure GenerateAtLevel(int level) { eventQueue.Enqueue("TreasureGen", $"Beginning level {level} treasure generation"); var treasure = innerGenerator.GenerateAtLevel(level); eventQueue.Enqueue("TreasureGen", $"Completed generation of level {level} treasure"); return(treasure); }
public void LogGenerationEvents() { var innerTreasure = new Treasure(); mockInnerGenerator.Setup(g => g.GenerateAtLevel(9266)).Returns(innerTreasure); var Treasure = decorator.GenerateAtLevel(9266); Assert.That(Treasure, Is.EqualTo(innerTreasure)); mockEventQueue.Verify(q => q.Enqueue(It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(2)); mockEventQueue.Verify(q => q.Enqueue("TreasureGen", "Beginning level 9266 treasure generation"), Times.Once); mockEventQueue.Verify(q => q.Enqueue("TreasureGen", "Completed generation of level 9266 treasure"), Times.Once); }
private void GenerateAndAssertTreasure() { var level = GetNewLevel(); var treasure = treasureGenerator.GenerateAtLevel(level); if (string.IsNullOrEmpty(treasure.Coin.Currency)) { Assert.That(treasure.Coin.Currency, Is.Empty); Assert.That(treasure.Coin.Quantity, Is.Zero); } else { Assert.That(treasure.Coin.Currency, Is.EqualTo(CoinConstants.Copper) .Or.EqualTo(CoinConstants.Gold) .Or.EqualTo(CoinConstants.Platinum) .Or.EqualTo(CoinConstants.Silver)); Assert.That(treasure.Coin.Quantity, Is.Positive); } Assert.That(treasure.Goods, Is.Not.Null, "goods"); foreach (var good in treasure.Goods) { Assert.That(good.Description, Is.Not.Empty); Assert.That(good.ValueInGold, Is.Positive); } Assert.That(treasure.Items, Is.Not.Null, "items"); if (level > 20) { Assert.That(treasure.Items, Is.Not.Empty, $"Level {level}"); } foreach (var item in treasure.Items) { itemVerifier.AssertItem(item); } }
public void Generate_ReturnTreasure() { var treasure = generator.GenerateAtLevel(1); Assert.That(treasure, Is.Not.Null); }