コード例 #1
0
        public void Detail_ThrowException_InvalidId()
        {
            var mocqRepo = new Mock <IRepository <MonsterTO> >();
            var author   = new AuthorUseCase(mocqRepo.Object);

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => author.GetMonster(-1));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        // GET: MonsterController/Edit/5
        public ActionResult Edit(int id)
        {
            var monster = author.GetMonster(id);

            return(View(monster));
        }
コード例 #5
0
 // GET: MarketController/Details/5
 public ActionResult Details(int id)
 {
     return(View(author.GetMonster(id)));
 }