Exemplo n.º 1
0
        public async Task Verificar_GetTipo()
        {
            //ARRANGE
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper     = mockMapper.CreateMapper();
            var repository = new Mock <ITipoRepository>();

            repository.Setup(x => x.Get(It.IsAny <int>())).ReturnsAsync(tipo);
            var controller = new TiposController(repository.Object, mapper);

            //ACT
            var actionResult = await controller.Get(1);

            var result = actionResult.Result as OkObjectResult;
            var dto    = result.Value as TipoDTO;

            //ASSERT
            Assert.NotNull(result);
            Assert.IsType <TipoDTO>(dto);
            Assert.Equal(1, dto.Id);
        }
Exemplo n.º 2
0
        public async Task Verificar_GetListTipos()
        {
            //ARRANGE
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper     = mockMapper.CreateMapper();
            var repository = new Mock <ITipoRepository>();

            repository.Setup(x => x.GetAll()).ReturnsAsync(lisTipos);
            var controller = new TiposController(repository.Object, mapper);

            //ACT
            var actionResult = await controller.Get();

            var result = actionResult.Result as OkObjectResult;
            var arr    = result.Value as List <TipoDTO>;

            //ASSERT
            Assert.NotNull(result);
            Assert.IsType <List <TipoDTO> >(arr);
            Assert.Equal(2, arr.Count);
        }