public async Task <IActionResult> ShowList([FromQuery(Name = "s")] string statuses, [FromQuery(Name = "a")] string analogs) { List <TmStatus> tmStatuses; List <TmAnalog> tmAnalogs; try { tmStatuses = statuses?.Split(',') .Select(tmAddrString => new TmStatus(TmAddr.Parse(tmAddrString, TmType.Status))) .ToList(); tmAnalogs = analogs?.Split(',') .Select(tmAddrString => new TmAnalog(TmAddr.Parse(tmAddrString, TmType.Analog))) .ToList(); } catch (Exception ex) { return(BadRequest(ex.Message)); } await Task.WhenAll(_api.UpdateTagsPropertiesAndClassData(tmAnalogs), _api.UpdateAnalogs(tmAnalogs), _api.UpdateTagsPropertiesAndClassData(tmStatuses), _api.UpdateStatuses(tmStatuses)); return(Ok(new { s = _mapper.Map <IEnumerable <TmStatusDto> >(tmStatuses), a = _mapper.Map <IEnumerable <TmAnalogDto> >(tmAnalogs), })); }
public void ThrowsFromInvalidString(string s) { Action act = () => TmAddr.Parse(s); act.Should().Throw <ArgumentException>(); }
public void ReturnsCorrectTmAddrFromValidString(string s, TmType type) { var tmAddr = TmAddr.Parse(s); tmAddr.Should().Be(new TmAddr(type, 16, 33, 257)); }