Exemplo n.º 1
0
        public void ApiGetBadgeById()
        {
            long             id         = 7;
            var              acc        = Mock.Of <IBadgeService>(a => a.GetBadge(id) == _sampleBadge1);
            var              uow        = Mock.Of <IUnitOfWork>(u => u.BadgeService == acc);
            BadgesController controller = new BadgesController(uow);
            var              response   = controller.GetBadge(id);
            var              result     = response as OkNegotiatedContentResult <BadgeDto>;
            var              badge      = result.Content;

            Assert.IsTrue(badge.EqualValues(_sampleBadge1));
        }
        public void Badges_GetBadge_Should_Return_ListBadgesWithSameLenght()
        {
            //Arrange
            moqRepository.Setup(g => g.GetAll(null)).Returns(listBadge).Verifiable();
            moqUnitOfWork.Setup(x => x.Repository <Badge>()).Returns(moqRepository.Object);

            var controller = new BadgesController(moqUnitOfWork.Object);

            // Act
            var contentResult = controller.GetBadge() as OkNegotiatedContentResult <List <Badge> >;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(3, contentResult.Content.Count());
        }