public async Task Insert_WorksAndIGetTheEntityBack() { string url = "/weatherforecast/"; // Arrange var client = _factory.CreateClient(); // Act var newWeather = new WeatherAddDto() { Day = DateTime.Now, TemperatureCelsius = 25 }; var response = await client.PostAsync(url, new StringContent(JsonConvert.SerializeObject(newWeather), Encoding.UTF8) { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } }); // Assert response.EnsureSuccessStatusCode(); // Status Code 200-299 Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString()); //var text = await response.Content.ReadAsStringAsync(); //var forecasts = JsonConvert.DeserializeObject<WeatherForecast[]>(text); //Assert.Equal(5, forecasts.Length); //Assert.Equal("cold", forecasts[0].Summary); }
public async Task <WeatherDto> Add([FromBody] WeatherAddDto weatherAddDto) { //_logger.LogInformation("here i want to log - just because"); //_logger.LogCritical("something CRTITICAL HAPPEND"); var createdWeather = await _weatherService.Insert(weatherAddDto.Day, weatherAddDto.TemperatureCelsius); var returnEntity = _mapper.Map <WeatherDto>(createdWeather); return(returnEntity); }