feat: introduced caching in the server + Added serilog

This commit is contained in:
Mikhail Shabanov committed 2021-06-04 23:04:03 +02:00
1 parent 8c9770f8a0
commit 638489a842
25 files changed
+365 -33

No files matched your search

@@ -9,6 +9,7 @@ using WotBlitzStatisticsPro.Common.Model;
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline;
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations;
using WotBlitzStatisticsPro.Logic.Model;
namespace WotBlitzStatisticsPro.Tests.OperationStepsTests
{
@@ -17,16 +18,19 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests
{
private GetAccountInfoOperation _operation;
private AccountInformationPipelineContextData _contextData;
private StatisticsCache _cache;
[SetUp]
public void Init()
{
InitAutoMapper();
InitWgApiClient();
_cache = new StatisticsCache();
_operation = new GetAccountInfoOperation(
WargamingApiClient,
Mapper,
(new Mock<ILogger<GetAccountInfoOperation>>()).Object);
(new Mock<ILogger<GetAccountInfoOperation>>()).Object,
_cache);
_contextData = new AccountInformationPipelineContextData();
}
@@ -51,6 +55,21 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests
var expectedAccountInfoHistory =
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");
}
[Test]
public async Task ShouldReadDataFromCacheIfItIsNotEmpty()
{
Assert.Fail("Implement test");
}
}
}
@@ -8,6 +8,7 @@ using NUnit.Framework;
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline;
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations;
using WotBlitzStatisticsPro.Logic.Model;
namespace WotBlitzStatisticsPro.Tests.OperationStepsTests
{
@@ -16,16 +17,21 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests
{
private GetTanksInfoOperation _operation;
private AccountInformationPipelineContextData _contextData;
private StatisticsCache _cache;
[SetUp]
public void Init()
{
InitAutoMapper();
InitWgApiClient();
_cache = new StatisticsCache();
_operation = new GetTanksInfoOperation(
WargamingTanksApiClient,
Mapper,
(new Mock<ILogger<GetTanksInfoOperation>>()).Object);
(new Mock<ILogger<GetTanksInfoOperation>>()).Object,
_cache);
_contextData = new AccountInformationPipelineContextData();
}
@@ -50,6 +56,21 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests
var expectedTanksHistory =
await File.ReadAllTextAsync(GetFixturePath("MappedTanksHistory.json"));
tanksHistorySerialized.Should().Be(expectedTanksHistory);
// ToDo: Check cache
Assert.Fail("Implement test");
}
[Test]
public async Task ShouldGetAndSaveTankInfoInformationIfCacheExpired()
{
Assert.Fail("Implement test");
}
[Test]
public async Task ShouldReadDataFromCacheIfItIsNotEmpty()
{
Assert.Fail("Implement test");
}
}
@@ -7,6 +7,7 @@ using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using Microsoft.Extensions.Logging;
using Moq;
using Moq.Protected;
using Newtonsoft.Json;
@@ -97,7 +98,10 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests
ItExpr.IsAny<CancellationToken>())
.ReturnsAsync(tanksInfoResponse);
var client = new WargamingApiClient(new HttpClient(handlerMock.Object), settingsMock.Object);
var client = new WargamingApiClient(
new HttpClient(handlerMock.Object),
settingsMock.Object,
(new Mock<ILogger<WagramingApiClientBase>>()).Object);
WargamingApiClient = client;
WargamingTanksApiClient = client;
}