public void Detail_ThrowException_InvalidId() { var mocqRepo = new Mock <IRepository <MonsterTO> >(); var author = new AuthorUseCase(mocqRepo.Object); Assert.ThrowsException <ArgumentOutOfRangeException>(() => author.GetMonster(-1)); }
public void GetMonster_ThrowException_InexistentMonster() { //Arrange var mocqRepo = new Mock <IRepository <MonsterTO> >(); mocqRepo.Setup(x => x.GetById(It.IsAny <int>())).Throws(new MonsterNotExistingException()); var author = new AuthorUseCase(mocqRepo.Object); //Assert Assert.ThrowsException <MonsterNotExistingException>(() => author.GetMonster(546)); }
public void GetMonster_ReturnMonster_WhenValid() { //Arrange var id = 42; var mocqRepo = new Mock <IRepository <MonsterTO> >(); mocqRepo.Setup(x => x.GetById(It.IsAny <int>())).Returns(testHelper.testMonster(id)); var author = new AuthorUseCase(mocqRepo.Object); //Act var result = author.GetMonster(id); //Assert Assert.IsNotNull(result); Assert.AreEqual(id, result.Id); mocqRepo.Verify(m => m.GetById(id), Times.Once()); }
// GET: MonsterController/Edit/5 public ActionResult Edit(int id) { var monster = author.GetMonster(id); return(View(monster)); }
// GET: MarketController/Details/5 public ActionResult Details(int id) { return(View(author.GetMonster(id))); }