public async void GetAllPlantsReturnListWith3PlantsTest() { //Arrange List <Plant> list = new List <Plant>(); PlantOutput p1 = new PlantOutput { PlantID = 1, Name = "Nombre 1", Country = "País 1", Active = true }; PlantOutput p2 = new PlantOutput { PlantID = 2, Name = "Nombre 2", Country = "País 2", Active = true }; PlantOutput p3 = new PlantOutput { PlantID = 3, Name = "Nombre 3", Country = "País 3", Active = false }; var mockPlantRepository = new Mock <IPlantRepository>(); var mockMapper = new Mock <IMapper>(); mockPlantRepository.Setup(e => e.GetAll()).ReturnsAsync(list); mockMapper.Setup(e => e.Map <List <Plant>, List <PlantOutput> >(It.IsAny <List <Plant> >())).Returns(new List <PlantOutput> { p1, p2, p3 }); var useCase = new GetAllPlantsUseCase(mockPlantRepository.Object, mockMapper.Object); //Act var res = await useCase.Execute(); //Assert Assert.Equal(3, res.Count); }
public async void GetOnePlantReturn1PlantTest() { //Arrange Plant p = new Plant(1, "Nombre 1", "País 1", true); PlantOutput p1 = new PlantOutput { PlantID = 1, Name = "Nombre 1", Country = "País 1", Active = true }; var mockPlantRepository = new Mock <IPlantRepository>(); var mockMapper = new Mock <IMapper>(); mockPlantRepository.Setup(e => e.GetOne(It.IsAny <int>())).Returns(p); mockMapper.Setup(e => e.Map <Plant, PlantOutput>(It.IsAny <Plant>())).Returns(p1); var useCase = new GetOnePlantUseCase(mockPlantRepository.Object, mockMapper.Object); //Act var res = useCase.Execute(1); //Assert Assert.IsType <PlantOutput>(res); }