public async Task TestGetAccounts() { // Arrange mockCacheService.Setup(_ => _.GetCache()).Returns(dummyCacheWithCodeAndAccessToken); Cache cacheThatWasSet = null; mockCacheService.Setup(_ => _.SetCache(It.IsAny <Cache>())) .Callback <Cache>((cache) => cacheThatWasSet = cache); SetupHttpClientForGetAccounts(); SetupHttpClientFactory(); SetupHttpRequestService(); // Act List <Account> accounts = await httpRequestService.GetAccountsAsync(); // Assert Assert.Equal(accounts[0].AccountId, dummyAccountsResponseDTO.Accounts[0].AccountId); Assert.Equal(accounts[1].AccountId, dummyAccountsResponseDTO.Accounts[1].AccountId); Assert.Equal(cacheThatWasSet.AccountsResponseDTO.Accounts[0].AccountId, dummyAccountsResponseDTO.Accounts[0].AccountId); Assert.Equal(cacheThatWasSet.AccountsResponseDTO.Accounts[1].AccountId, dummyAccountsResponseDTO.Accounts[1].AccountId); }