Example #1
0
        public async Task TestDoExchangeAsync()
        {
            // Arrange
            Cache cacheThatWasSet = null;

            mockCacheService.Setup(_ => _.SetCache(It.IsAny <Cache>()))
            .Callback <Cache>((cache) => cacheThatWasSet = cache);

            SetupHttpClientForExchangePost();
            SetupHttpClientFactory();

            SetupHttpRequestService();

            httpRequestService = new HttpRequestService(mockHttpClientFactory.Object,
                                                        mockCacheService.Object, trueLayerCredentialsOptions);

            // Act
            await httpRequestService.DoExchangeAsync(dummyCode);

            // Assert
            Assert.NotNull(cacheThatWasSet.ExchangeResponseDTO);
            Assert.Equal(cacheThatWasSet.ExchangeResponseDTO.AccessToken, dummyAccessToken);
        }