public async void GetAllActiveAuditTypesReturnsTwoTest() { //Arrange List <AuditType> list = new List <AuditType>(); AuditTypeOutput atO1 = new AuditTypeOutput() { Id = 1, Code = "Codigo 1", Name = "Nombre 1", Active = true }; AuditTypeOutput atO2 = new AuditTypeOutput() { Id = 2, Code = "Codigo 2", Name = "Nombre 2", Active = true }; List <AuditTypeOutput> listO = new List <AuditTypeOutput>() { atO1, atO2 }; var mockAuditTypeRepository = new Mock <IAuditTypeRepository>(); var mockMapper = new Mock <IMapper>(); mockAuditTypeRepository.Setup(e => e.GetAllActives()).ReturnsAsync(list); mockMapper.Setup(e => e.Map <List <AuditType>, List <AuditTypeOutput> >(It.IsAny <List <AuditType> >())).Returns(listO); var useCase = new GetAllAuditTypesUseCase(mockAuditTypeRepository.Object, mockMapper.Object); //Act var res = await useCase.Execute(); //Assert Assert.Equal(2, res.Count); }
public void GetOneAuditTypeReturnsSuccessfullyTest() { //Arrange AuditType at = new AuditType("Codigo", "Nombre", true, 1); AuditTypeOutput atO = new AuditTypeOutput() { Id = 1, Code = "Codigo", Name = "Nombre", Active = true }; var mockAuditTypeRepository = new Mock <IAuditTypeRepository>(); var mockMapper = new Mock <IMapper>(); mockAuditTypeRepository.Setup(e => e.Get(It.IsAny <int>())).Returns(at); mockMapper.Setup(e => e.Map <AuditType, AuditTypeOutput>(It.IsAny <AuditType>())).Returns(atO); var useCase = new GetOneAuditTypeUseCase(mockAuditTypeRepository.Object, mockMapper.Object); //Act var res = useCase.Execute(1); //Assert Assert.IsType <AuditTypeOutput>(res); }