Пример #1
0
        public async Task Modify_Atributo_Not_Exist(int id)
        {
            //Arrange
            Atributo    FakeAtributo   = Build.CrearAtributo(id);
            AtributoDto FakeDto        = Build.CrearAtributoDto(id);
            AtributoDto FakeRequestDto = Build.CrearAtributoDto(id);

            _mapper.Setup(map => map.Map <AtributoDto, Atributo>(It.IsAny <AtributoDto>())).Returns(FakeAtributo);
            _mapper.Setup(map => map.Map <Atributo, AtributoDto>(It.IsAny <Atributo>())).Returns(FakeDto);

            //Act
            var atributosController = new AtributosController(_logger.Object, _specification.Object, _repo.Object, _mapper.Object);
            var actionResult        = (NotFoundResult)await atributosController.ModificarAtributo(FakeRequestDto);

            //Assert
            Assert.Equal(actionResult.StatusCode, (int)System.Net.HttpStatusCode.NotFound);
        }
Пример #2
0
        public async Task Modify_Atributo(int id)
        {
            //Arrange
            Atributo    FakeAtributo   = Build.CrearAtributo(id);
            AtributoDto FakeDto        = Build.CrearAtributoDto(id);
            AtributoDto FakeRequestDto = Build.CrearAtributoDto(id);

            _repo.Setup(repor => repor.GetElement(It.IsAny <ISpecification <Atributo> >()))
            .Returns(FakeAtributo);
            _mapper.Setup(map => map.Map <AtributoDto, Atributo>(It.IsAny <AtributoDto>())).Returns(FakeAtributo);
            _mapper.Setup(map => map.Map <Atributo, AtributoDto>(It.IsAny <Atributo>())).Returns(FakeDto);

            //Act
            var atributosController = new AtributosController(_logger.Object, _specification.Object, _repo.Object, _mapper.Object);
            var actionResult        = (OkObjectResult)await atributosController.ModificarAtributo(FakeRequestDto);

            AtributoDto resultado = (AtributoDto)actionResult.Value;

            //Assert
            Assert.Equal(resultado, FakeDto);
        }
        public async Task Modify_request_success()
        {
            AtributoDto fakeAtributo = new AtributoDto();

            fakeAtributo.idAtributo  = 120;
            fakeAtributo.vchAtributo = "hey";

            AtributosRequest fakeRequest = new AtributosRequest();

            fakeRequest.AtributoId  = 120;
            fakeRequest.Descripcion = "hey";

            //Arrange
            _mediatorMock.Setup(x => x.Send(It.IsAny <AtributosModifyCommand>(), default(CancellationToken)))
            .Returns(Task.FromResult(fakeAtributo));

            //Act
            var atributosController = new AtributosController(_mediatorMock.Object);
            var actionResult        = (OkObjectResult)await atributosController.ModificarAtributo(fakeRequest);

            //Assert
            Assert.Equal(actionResult.StatusCode, (int)System.Net.HttpStatusCode.OK);
            Assert.Equal(actionResult.Value, fakeAtributo);
        }