test: graphQL caching

This commit is contained in:
Mikhail Shabanov committed 2021-06-07 14:29:16 +02:00
1 parent 638489a842
commit 5d66c3641f
3 files changed
+79 -33

No files matched your search

@@ -1,8 +1,11 @@
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Extensions.Logging;
using Moq;
using Moq.Protected;
using Newtonsoft.Json;
using NUnit.Framework;
using WotBlitzStatisticsPro.Common.Model;
@@ -56,20 +59,32 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests
await File.ReadAllTextAsync(GetFixturePath("MappedAccountHistory.json"));
accountInfoHistorySerialized.Should().Be(expectedAccountInfoHistory);
// ToDo: Check cache
Assert.Fail("Implement test");
}
[Test]
public async Task ShouldGetAndSaveAccountInfoInformationIfCacheExpired()
{
Assert.Fail("Implement test");
var accountCache = _cache.GetAccountData(AccountId);
accountCache.Should().NotBeNull();
accountCache?.AccountInfo.Should().NotBeNull();
accountCache?.AccountInfoHistory.Should().NotBeNull();
}
[Test]
public async Task ShouldReadDataFromCacheIfItIsNotEmpty()
{
Assert.Fail("Implement test");
var accountInfo = GetAccountInfoFromFixture();
var accountInfoHistory = GetAccountInfoHistoryFromFixture();
_cache.SetAccountData(AccountId, new AccountDataCache(accountInfo, accountInfoHistory));
var context = new OperationContext(new AccountRequest(AccountId, Realm, Language));
context.AddOrReplace(_contextData);
await _operation.Invoke(context, null);
_contextData.AccountInfo.Should().NotBeNull();
_contextData.AccountInfoHistory.Should().NotBeNull();
HttpHandlerMock
.Protected()
.Verify<Task<HttpResponseMessage>>("SendAsync", Times.Never(),
ItExpr.IsAny<HttpRequestMessage>(),
ItExpr.IsAny<CancellationToken>());
}
}
}