public async void ShouldListActionstepParticipants() { 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 request = new ListParticipantsRequest { TokenSetQuery = new TokenSetQuery(testTokenSet.UserId, testTokenSet.OrgKey) }; var response = await actionstepService.Handle <ListParticipantsResponse>(request); var admin = response.Participants.SingleOrDefault(p => p.Id == 1); Assert.NotNull(admin); var expectedBirthTimestamp = new LocalDate(2000, 1, 1); var expectedDeathTimestamp = new LocalDate(2001, 1, 1); Assert.Equal(expectedBirthTimestamp, admin.BirthTimestamp); Assert.Equal(expectedDeathTimestamp, admin.DeathTimestamp); } }
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 ShouldRetryRefreshingInvalidToken() { using (var authDelegatingHandler = new AuthDelegatingHandler() { InnerHandler = _handler }) using (var httpClient = new HttpClient(authDelegatingHandler)) using (var memoryCache = new MemoryCache(new MemoryCacheOptions())) { var tokenHandler = new TestTokenSetRepository(); var fakeClock = new FakeClock(Instant.FromUtc(2019, 05, 07, 2, 3)); var testTokenRepository = new TestTokenSetRepository(); var testTokenSet = GetTestTokenSet(isInvalid: true); await testTokenRepository.AddOrUpdateTokenSet(testTokenSet); var options = new ActionstepServiceConfigurationOptions("clientId", "clientSecret"); var actionstepService = new ActionstepService(new NullLogger <ActionstepService>(), httpClient, options, testTokenRepository, fakeClock, memoryCache); var response = await actionstepService.Handle <GetActionResponse>(new GetActionRequest { ActionId = 1, TokenSetQuery = new TokenSetQuery(testTokenSet.UserId, testTokenSet.OrgKey) }); // Should be called 3 times. First from this test method to arrange this test token, second from the handler to set the lock, and third time to unlock/update with refreshed data. Assert.Equal(3, testTokenRepository.AddOrUpdateTokenSetCount); } }
public async Task ShouldGetActionWithMultipleMatterIds() { 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 listActionsRequest = new ListActionsRequest(); listActionsRequest.ActionstepIds.AddRange(new[] { 1, 7 }); listActionsRequest.TokenSetQuery = new TokenSetQuery(testTokenSet.UserId, testTokenSet.OrgKey); var response = await actionstepService.Handle <ListActionsResponse>(listActionsRequest); Assert.Equal(2, response.Actions.Count); Assert.True(response.Actions.Exists(a => a.Id == 1)); Assert.True(response.Actions.Exists(a => a.Id == 7)); } }
public async void ShouldGetActionWithMatterId() { 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 options = new ActionstepServiceConfigurationOptions("clientId", "clientSecret"); var tokenSetRepository = new TestTokenSetRepository(); var testTokenSet = GetTestTokenSet(); await tokenSetRepository.AddOrUpdateTokenSet(testTokenSet); var actionstepService = new ActionstepService(new NullLogger <ActionstepService>(), httpClient, options, tokenSetRepository, fakeClock, memoryCache); var response = await actionstepService.Handle <GetActionResponse>(new GetActionRequest { ActionId = 1, TokenSetQuery = new TokenSetQuery(testTokenSet.UserId, testTokenSet.OrgKey) }); Assert.Equal(1, response.Action.Id); Assert.Null(response.Action.IsBillableOverride); Assert.False(response.Action.IsDeleted); Assert.True(response.Action.IsFavorite); } }