public void ExecuteUpdateCorrectiveActionStateTest() { //Arrange var state = new CorrectiveActionState() { CorrectiveActionStateID = 1, Code = "PRB", Name = "Prueba", Color = "eaeaea", Active = true }; var mockCorrectiveActionStateRepository = new Mock <ICorrectiveActionStateRepository>(); mockCorrectiveActionStateRepository.Setup(e => e.Update(It.IsAny <CorrectiveActionState>())).Returns(state); var mockMapper = new Mock <IMapper>(); mockMapper.Setup(e => e.Map <CorrectiveActionState, CorrectiveActionStateOutput>(It.IsAny <CorrectiveActionState>())).Returns(new CorrectiveActionStateOutput()); var useCase = new UpdateCorrectiveActionStateUseCase(mockCorrectiveActionStateRepository.Object, mockMapper.Object); //Act var res = useCase.Execute(state); //Assert Assert.IsType <CorrectiveActionStateOutput>(res); }
public CorrectiveActionStateOutput Execute(CorrectiveActionState newCorrectiveActionState) { if (_correctiveActionStateRepository.CheckDuplicates(newCorrectiveActionState) == null) { var correctiveActionState = _correctiveActionStateRepository.Add(newCorrectiveActionState); return(_mapper.Map <CorrectiveActionState, CorrectiveActionStateOutput>(correctiveActionState)); } throw new DuplicateEntityException(newCorrectiveActionState.Name, "Ya existe un estado de acción correctiva con este nombre, código o color"); }