public async Task Get_Valid_Diff() { double difference = await _sensorService.GetDifferenceAsync("000D6F0003141E14"); var expectedResult = new DiffResponse("Success", difference); var client = _webApplicationFactory.CreateClient(); var response = await client.GetAsync(@"https://localhost:44338/api/diff/000D6F0003141E14"); response.EnsureSuccessStatusCode(); Expect.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString()); var responseString = await response.Content.ReadAsStringAsync(); Expect.DeepEqualLowerCaseFields(expectedResult, responseString); }
public async Task <IActionResult> GetDifference(string id) { try{ var difference = await _sensorService.GetDifferenceAsync(id); DiffResponse response = new DiffResponse("Success", difference); return(Ok(response)); } catch (InvalidOperationException) { // TODO log exception return(NotFound(new DiffResponse(id))); } catch (Exception) { //TODO log exception return(StatusCode(500, new DiffResponse("Internal server error"))); } }