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

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

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

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

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

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

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

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

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