コード例 #1
0
        public async void GetOnePlantReturnNullTest()
        {
            //Arrange
            Plant p = new Plant();

            var mockPlantRepository = new Mock <IPlantRepository>();
            var mockMapper          = new Mock <IMapper>();

            mockPlantRepository.Setup(e => e.GetOne(It.IsAny <int>())).Returns <Plant>(null);
            mockMapper.Setup(e => e.Map <Plant, PlantOutput>(It.IsAny <Plant>())).Returns <PlantOutput>(null);

            var useCase = new GetOnePlantUseCase(mockPlantRepository.Object, mockMapper.Object);

            //Act
            var res = useCase.Execute(1);

            //Assert
            Assert.Null(res);
        }
コード例 #2
0
        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);
        }