public void CallAimServiceGetById_IfIdIsNotNull(string id) { // Arrange var mockedAimService = new Mock <IAimService>(); var mockedCityService = new Mock <ICityService>(); var mockedCategoryService = new Mock <IAimCategoryService>(); var mockedCountryService = new Mock <ICountryService>(); var mockedMapper = new Mock <IMapperAdapter>(); mockedAimService.Setup(x => x.GetAimById(It.IsAny <int>())).Verifiable(); AimController controller = new AimController(mockedAimService.Object, mockedCountryService.Object, mockedCityService.Object, mockedCategoryService.Object, mockedMapper.Object); // Act controller.Details(id); // Assert mockedAimService.Verify(x => x.GetAimById(It.IsAny <int>()), Times.Once); }
public void MapAimToViewModel() { // Arrange var mockedAimService = new Mock <IAimService>(); var mockedCityService = new Mock <ICityService>(); var mockedCategoryService = new Mock <IAimCategoryService>(); var mockedCountryService = new Mock <ICountryService>(); var mockedMapper = new Mock <IMapperAdapter>(); var mockedAim = new Mock <Aim>(); mockedAimService.Setup(x => x.GetAimById(It.IsAny <int>())).Returns(mockedAim.Object); mockedMapper.Setup(x => x.Map <AimDetailsViewModel>(It.IsAny <Aim>())).Verifiable(); AimController controller = new AimController(mockedAimService.Object, mockedCountryService.Object, mockedCityService.Object, mockedCategoryService.Object, mockedMapper.Object); // Act controller.Details("1"); // Assert mockedMapper.Verify(x => x.Map <AimDetailsViewModel>(mockedAim.Object), Times.Once); }