public void ReturnCoinFromSelector() { var tableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXCoins, 1); generator.GenerateAtLevel(1); mockTypeAndAmountPercentileSelector.Verify(p => p.SelectFrom(tableName), Times.Once); }
public void LogGenerationEvents() { var innerCoin = new Coin(); innerCoin.Currency = "currency"; innerCoin.Quantity = 90210; mockInnerGenerator.Setup(g => g.GenerateAtLevel(9266)).Returns(innerCoin); var coin = decorator.GenerateAtLevel(9266); Assert.That(coin, Is.EqualTo(innerCoin)); mockEventQueue.Verify(q => q.Enqueue(It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(2)); mockEventQueue.Verify(q => q.Enqueue("TreasureGen", "Beginning level 9266 coin generation"), Times.Once); mockEventQueue.Verify(q => q.Enqueue("TreasureGen", "Completed generation of level 9266 coin: 90210 currency"), Times.Once); }
public Treasure GenerateAtLevel(int level) { if (level < LevelLimits.Minimum || level > LevelLimits.Maximum) { throw new ArgumentException($"Level {level} is not a valid level for treasure generation"); } var treasure = new Treasure(); treasure.Coin = coinFactory.GenerateAtLevel(level); treasure.Goods = goodsFactory.GenerateAtLevel(level); treasure.Items = itemsFactory.GenerateRandomAtLevel(level); return(treasure); }
public Coin GenerateAtLevel(int level) { eventQueue.Enqueue("TreasureGen", $"Beginning level {level} coin generation"); var coin = innerGenerator.GenerateAtLevel(level); eventQueue.Enqueue("TreasureGen", $"Completed generation of level {level} coin: {coin.Quantity} {coin.Currency}"); return(coin); }
public Treasure GenerateAtLevel(int level) { var treasure = new Treasure(); treasure.Coin = coinFactory.GenerateAtLevel(level); treasure.Goods = goodsFactory.GenerateAtLevel(level); treasure.Items = itemsFactory.GenerateAtLevel(level); return(treasure); }
private void GenerateAndAssertCoins() { var level = GetNewLevel(); var coin = coinGenerator.GenerateAtLevel(level); if (string.IsNullOrEmpty(coin.Currency)) { Assert.That(coin.Currency, Is.Empty); Assert.That(coin.Quantity, Is.Zero); } else { Assert.That(coin.Currency, Is.EqualTo(CoinConstants.Copper) .Or.EqualTo(CoinConstants.Gold) .Or.EqualTo(CoinConstants.Platinum) .Or.EqualTo(CoinConstants.Silver)); Assert.That(coin.Quantity, Is.Positive); } }
public void GenerateAtLevel_ThrowsException_LevelTooLow() { Assert.That(() => generator.GenerateAtLevel(LevelLimits.Minimum - 1), Throws.ArgumentException.With.Message.EqualTo($"Level 0 is not a valid level for treasure generation")); }