public async void ShouldGetDataCollectionValues() { using (var authDelegatingHandler = new AuthDelegatingHandler() { InnerHandler = _handler }) using (var httpClient = new HttpClient(authDelegatingHandler)) using (var memoryCache = new MemoryCache(new MemoryCacheOptions())) { var fakeClock = new FakeClock(Instant.FromUtc(2019, 05, 07, 2, 3)); var testTokenRepository = new TestTokenSetRepository(); var testTokenSet = GetTestTokenSet(); await testTokenRepository.AddOrUpdateTokenSet(testTokenSet); var options = new ActionstepServiceConfigurationOptions("clientId", "clientSecret"); var actionstepService = new ActionstepService(new NullLogger <ActionstepService>(), httpClient, options, testTokenRepository, fakeClock, memoryCache); var dataCollectionRecordValuesRequest = new ListDataCollectionRecordValuesRequest(); dataCollectionRecordValuesRequest.ActionstepId = 7; dataCollectionRecordValuesRequest.TokenSetQuery = new TokenSetQuery(testTokenSet.UserId, testTokenSet.OrgKey); dataCollectionRecordValuesRequest.DataCollectionRecordNames.AddRange(new[] { "property", "convdet", "keydates" }); dataCollectionRecordValuesRequest.DataCollectionFieldNames.AddRange(new[] { "titleref", "lotno", "planno", "plantype", "smtdateonly", "smttime", "purprice" }); var response = await actionstepService.Handle <ListDataCollectionRecordValuesResponse>(dataCollectionRecordValuesRequest); Assert.Equal(6, response.DataCollectionRecordValues.Count); Assert.Equal("test-title-ref", response["property", "titleref"]); } }
public async Task <StampDutyCalculatorInfo> Handle(StampDutyCalculatorInfoQuery message, CancellationToken token) { if (message is null) { throw new ArgumentNullException(nameof(message)); } ValidationResult result = _validator.Validate(message); if (!result.IsValid) { throw new ValidationException("Invalid input.", result.Errors); } var request = new ListDataCollectionRecordValuesRequest() { TokenSetQuery = new TokenSetQuery(message.AuthenticatedUser?.Id, message.OrgKey), ActionstepId = message.MatterId }; request.DataCollectionRecordNames.Add("convdet"); request.DataCollectionFieldNames.AddRange(new[] { "purprice", "ConveySubType" }); var actionstepResponse = await _actionstepService.Handle <ListDataCollectionRecordValuesResponse>(request); if (actionstepResponse == null) { return(new StampDutyCalculatorInfo(0, string.Empty)); } #pragma warning disable CA1806 // Do not ignore method results decimal.TryParse(actionstepResponse["convdet", "purprice"], out decimal purchasePrice); #pragma warning restore CA1806 // Do not ignore method results return(new StampDutyCalculatorInfo(purchasePrice, actionstepResponse["convdet", "ConveySubType"])); }