Exemple #1
0
        public async Task Verificar_GetServicio()
        {
            //ARRANGE
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper     = mockMapper.CreateMapper();
            var repository = new Mock <IServicioRepository>();

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

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

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

            //ASSERT
            Assert.NotNull(result);
            Assert.IsType <ServicioDTO>(dto);
            Assert.Equal(1, dto.Id);
        }
Exemple #2
0
        public async Task Verificar_GetListServicios()
        {
            //ARRANGE
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper     = mockMapper.CreateMapper();
            var repository = new Mock <IServicioRepository>();

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

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

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

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