public async Task WeatherForecastService_ShouldBeCalled_WhenHandlingGetForecastsQuery() { //Arrange var summary = _summariesService.GetSummary(Arg.Any <int>()); _weatherForecastService .GetMultipleAsync(Arg.Any <int>(), Arg.Any <CancellationToken>()) .Returns(new List <WeatherForecast> { new(DateTime.UtcNow, 23, summary) });
public WeatherForecastServiceTests() { _summariesService = Substitute.For <ISummariesService>(); _summariesService .GetCount() .Returns(5); _summariesService .GetSummary(Arg.Any <int>()) .Returns(SummaryText.From("Fake Summary")); }
public async Task <IEnumerable <WeatherForecast> > GetMultipleAsync(int requestNumberOfRecords, CancellationToken cancellationToken) { var summariesCount = _summariesService.GetCount(); var rng = new Random(); var result = Enumerable.Range(1, requestNumberOfRecords).Select(index => new WeatherForecast( DateTime.Now.AddDays(index), rng.Next(-20, 55), _summariesService.GetSummary(rng.Next(summariesCount) ))) .ToArray(); return(await Task.FromResult(result)); }