mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-23 19:30:06 +02:00
feat: operations unit tests
This commit is contained in:
1 parent
e1cc18a888
commit
a9eab26a6d
13 files changed
+672
-2
No files matched your search
@@ -0,0 +1,56 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline;
|
||||
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
|
||||
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Tests.OperationStepsTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class GetAccountInfoOperationTest: OperationsStepsTestBase
|
||||
{
|
||||
private GetAccountInfoOperation _operation;
|
||||
private AccountInformationPipelineContextData _contextData;
|
||||
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
InitAutoMapper();
|
||||
InitWgApiClient();
|
||||
_operation = new GetAccountInfoOperation(
|
||||
WargamingApiClient,
|
||||
Mapper,
|
||||
(new Mock<ILogger<GetAccountInfoOperation>>()).Object);
|
||||
|
||||
_contextData = new AccountInformationPipelineContextData();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ShouldGetAndSaveAccountInfoInformation()
|
||||
{
|
||||
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();
|
||||
|
||||
var accountInfoSerialized = JsonConvert.SerializeObject(_contextData.AccountInfo);
|
||||
var accountInfoHistorySerialized = JsonConvert.SerializeObject(_contextData.AccountInfoHistory);
|
||||
|
||||
var expectedAccountInfo =
|
||||
await File.ReadAllTextAsync($"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\MappedAccountInfo.json");
|
||||
accountInfoSerialized.Should().Be(expectedAccountInfo);
|
||||
var expectedAccountInfoHistory =
|
||||
await File.ReadAllTextAsync($"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\MappedAccountHistory.json");
|
||||
accountInfoHistorySerialized.Should().Be(expectedAccountInfoHistory);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user