public void Setup() { _weatherDataProviderMock = new Mock <IWeatherDataProvider>(); _backupServiceMock = new Mock <IBackupService>(); _request = GetCityRequest.Create(_fixture.Create <int>()); _subject = new WeatherService(_weatherDataProviderMock.Object, _backupServiceMock.Object); }
public void WhenIdIsZero_ShouldThrowInvalidOperationException() { // arrange // act TestDelegate act = () => GetCityRequest.Create(-100); // assert Assert.Throws <InvalidOperationException>(act); }
public void WhenCreated_ShouldProvideCorrectId() { // arrange var id = new Fixture().Create <int>(); // act var request = GetCityRequest.Create(id); // assert Assert.That(request.Id, Is.EqualTo(id)); }
public async Task <IActionResult> Get(string cities) { if (string.IsNullOrWhiteSpace(cities)) { return(BadRequest()); } var requests = cities.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(x => GetCityRequest.Create(int.Parse(x))); var result = await _weatherService.GetAsync(requests); return(Ok(result)); }