public async Task GetMultipleVersionsByCalculationId() { int[] versionIds = new[] { NewRandomInt(), NewRandomInt(), NewRandomInt(), }; string calculationId = NewRandomString(); CalculationVersionsCompareModel expectedRequest = new CalculationVersionsCompareModel { Versions = versionIds, CalculationId = calculationId }; IEnumerable <CalculationVersion> expectedResponse = Enumerable.Empty <CalculationVersion>(); GivenTheResponse("calculation-versions", expectedResponse, HttpMethod.Post); ApiResponse <IEnumerable <CalculationVersion> > apiResponse = await _client.GetMultipleVersionsByCalculationId(versionIds, calculationId); apiResponse?.StatusCode .Should() .Be(HttpStatusCode.OK); apiResponse .Content .Should() .BeEquivalentTo(expectedResponse); AndTheRequestContentsShouldHaveBeen(expectedRequest.AsJson()); }
public async Task <ApiResponse <IEnumerable <CalculationVersion> > > GetMultipleVersionsByCalculationId(IEnumerable <int> versionIds, string calculationId) { Guard.ArgumentNotNull(versionIds, nameof(versionIds)); Guard.IsNullOrWhiteSpace(calculationId, nameof(calculationId)); CalculationVersionsCompareModel calcsVersGetModel = new CalculationVersionsCompareModel() { Versions = versionIds, CalculationId = calculationId, }; string url = $"{UrlRoot}/calculation-versions"; return(await PostAsync <IEnumerable <CalculationVersion>, CalculationVersionsCompareModel>(url, calcsVersGetModel)); }
public Task <IActionResult> CalculationVersions([FromBody] CalculationVersionsCompareModel calculationVersionsCompareModel) => _calcsService.GetCalculationVersions(calculationVersionsCompareModel);