/// <summary> /// Initializes a new instance of the <see cref="StationService"/> class. /// </summary> /// <param name="stationRepository">The station repository.</param> public StationService(Core.Repositories.IStationRepository stationRepository, Crosscutting.ILogger logger) { this._stationRepository = stationRepository; this._logger = logger; }
public async void WhenInput(string p0) { // mocking the repository var mockedRepo = new Mock<Core.Repositories.IStationRepository>(MockBehavior.Strict); mockedRepo.Setup(p => p.GetStationsStartingWithAsync(p0)) .Returns((string input) => Task.FromResult(dataSource.Where(s => s.Name.StartsWith(input)))); this.stationRepository = mockedRepo.Object; // mocking the logger var mockedLogger = new Mock<Crosscutting.ILogger>(MockBehavior.Strict); mockedLogger.Setup(p => p.LogErrorAsync(It.IsAny<string>())) .Returns(Task.FromResult(true)); mockedLogger.Setup(p => p.LogInfoAsync(It.IsAny<string>())) .Returns(Task.FromResult(true)); mockedLogger.Setup(p => p.LogExceptionAsync(It.IsAny<Exception>())) .Returns(Task.FromResult(true)); this.logger = mockedLogger.Object; this.stationService = new Application.Station.StationService(this.stationRepository, this.logger); //searching this.searchResult = await this.stationService.SearchStationsStartingWithAsync(new Station.Dto.SearchStationsStartingWithInput() { StartingWith = p0 }); }