public void TryStep_WallGold(int countOfAttempt, int coinCount, bool wallWasBroken) { // Data Preparation Mock <Maze> mazeMock = new Mock <Maze>(); Maze maze = mazeMock.Object; Mock <Hero> heroMock = new Mock <Hero>(); heroMock.SetupAllProperties(); Hero hero = heroMock.Object; hero.Money = 0; mazeMock.Setup(x => x.Hero).Returns(hero); var wallGold = new WallGold(1, 1, maze); //Action bool answer = false; for (int i = 0; i < countOfAttempt; i++) { answer = wallGold.TryStep(); } // Checks Assert.AreEqual(coinCount, hero.Money); if (wallWasBroken) { mazeMock.Verify(x => x.ReplaceToGround(wallGold), Times.Once); Assert.AreEqual(true, answer); } else { Assert.AreEqual(false, answer); } }
public void TryStep_WallGold(int countOfAttempt, int coinCount, bool wallWasBroken, bool canStep) { //Подготовка данных var mazeMock = new Mock <Maze>(); var maze = mazeMock.Object; var heroMock = new Mock <Hero>(); heroMock.SetupAllProperties(); var hero = heroMock.Object; hero.Money = 0; mazeMock.Setup(x => x.Hero).Returns(hero); var wallGold = new WallGold(1, 1, maze); //Действие var answer = false; for (int i = 0; i < countOfAttempt; i++) { answer = wallGold.TryStep(); } //Проверки Assert.AreEqual(coinCount, hero.Money); if (wallWasBroken) { mazeMock.Verify(x => x.ReplaceToGround(wallGold), Times.Once); } Assert.AreEqual(canStep, answer); }