public void CreateCmvSummaryResult_Should_return_null_object_When_TotalAreaCoveredSqMeters_is_null() { var summaryResult = new CMVSummaryResult(1, 2, true, 3, 4, 0, 6); var settings = new CMVSettings(1, 2, 3, 4, 5, true); var result = new CompactionCmvSummaryResult(summaryResult, settings); Assert.IsNotNull(result); Assert.IsNull(result.SummaryData); Assert.AreEqual(ContractExecutionResult.DefaultMessage, result.Message); }
public void CreateCmvSummaryResult_Should_return_full_object_When_TotalAreaCoveredSqMeters_is_not_null() { var summaryResult = new CMVSummaryResult(1, 2, true, 3, 4, 5, 6); var settings = new CMVSettings(1, 2, 3, 4, 5, true); var result = new CompactionCmvSummaryResult(summaryResult, settings); Assert.IsNotNull(result); Assert.AreEqual(ContractExecutionResult.DefaultMessage, result.Message); Assert.AreEqual(5, result.SummaryData.TotalAreaCoveredSqMeters); Assert.AreEqual(3, result.SummaryData.MaxCMVPercent); Assert.AreEqual(5, result.SummaryData.MinCMVPercent); Assert.AreEqual(1, result.SummaryData.PercentEqualsTarget); Assert.AreEqual(3, result.SummaryData.PercentGreaterThanTarget); Assert.AreEqual(6, result.SummaryData.PercentLessThanTarget); Assert.IsNotNull(result.SummaryData.CmvTarget); }
public async Task <ActionResult <CompactionCmvSummaryResult> > GetCmvSummary( [FromQuery] Guid projectUid, [FromQuery] Guid?filterUid) { Log.LogInformation($"{nameof(GetCmvSummary)}: " + Request.QueryString); var request = await GetCmvRequest(projectUid, filterUid); request.Validate(); var validationResult = await ValidateFilterAgainstProjectExtents(projectUid, filterUid); if (!validationResult.isValidFilterForProjectExtents) { return(Ok(new CompactionCmvSummaryResult())); } Log.LogDebug($"{nameof(GetCmvSummary)} request: " + JsonConvert.SerializeObject(request)); try { var result = await RequestExecutorContainerFactory.Build <SummaryCMVExecutor>(LoggerFactory, configStore : ConfigStore, trexCompactionDataProxy : TRexCompactionDataProxy, customHeaders : CustomHeaders, userId : GetUserId(), fileImportProxy : FileImportProxy) .ProcessAsync(request) as CMVSummaryResult; var cmvSummaryResult = new CompactionCmvSummaryResult(result, request.CmvSettings); Log.LogInformation($"{nameof(GetCmvSummary)} result: " + JsonConvert.SerializeObject(cmvSummaryResult)); await SetCacheControlPolicy(projectUid); return(Ok(cmvSummaryResult)); } catch (ServiceException exception) { Log.LogError($"{nameof(GetCmvSummary)}: {exception.GetResult.Message} ({exception.GetResult.Code})"); return(BadRequest(new ContractExecutionResult(exception.GetResult.Code, exception.GetResult.Message))); } finally { Log.LogInformation($"{nameof(GetCmvSummary)} returned: " + Response.StatusCode); } }