public void RetornaStatusOKGetId()
        {
            // Arrange
            int valorEsperado = 200;

            var tribo = new TriboDto
            {
                Id    = 1,
                Nome  = "Formacao",
                Ativo = true
            };

            var repoMock = new Mock <ITriboNegocio>();
            Expression <Func <ITriboNegocio, TriboDto> > call = x => x.SelecionarPorId(tribo.Id);

            repoMock.Setup(call).Returns(tribo).Verifiable("Metodo nao chamado");
            var _triboController = new TriboController(repoMock.Object);


            // Act
            var actionResult   = _triboController.GetId(tribo.Id);
            var okObjectResult = (OkObjectResult)actionResult;

            // Assert
            Assert.Equal(valorEsperado, okObjectResult.StatusCode);
            repoMock.Verify(call, Times.Once);
        }
示例#2
0
        public void TriboPorIdOk()
        {
            // Arrange
            var tribo = new TriboDto
            {
                Id         = 1,
                Nome       = "Formacao",
                NomeMentor = "Anderson",
                IdMentor   = 1,
                Ativo      = true
            };
            var repoMock = new Mock <ITriboRepositorio>();

            repoMock.Setup(m => m.SelecionarPorId(tribo.Id)).Returns(tribo);

            var _triboNegocio = new TriboNegocio(repoMock.Object);

            // Act
            var objRetornado = _triboNegocio.SelecionarPorId(tribo.Id);

            // Assert
            Assert.NotNull(objRetornado);
            Assert.Same(tribo, objRetornado);
        }