From 7f713e53574e16549a376d9e82c0673c96dce716 Mon Sep 17 00:00:00 2001 From: Mikhail Shabanov Date: Fri, 12 Mar 2021 17:56:13 +0100 Subject: [PATCH] chore: Linux path for fixture fixed --- .../GetAccountInfoOperationTest.cs | 4 ++-- .../GetTanksInfoOperationTest.cs | 4 ++-- .../OperationsStepsTestBase.cs | 22 +++++++++++-------- .../ReadAccountInfoFromDbOperationTest.cs | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/WotBlitzStatisticsPro.Tests/OperationStepsTests/GetAccountInfoOperationTest.cs b/WotBlitzStatisticsPro.Tests/OperationStepsTests/GetAccountInfoOperationTest.cs index e2db9c0..ba9f1a6 100644 --- a/WotBlitzStatisticsPro.Tests/OperationStepsTests/GetAccountInfoOperationTest.cs +++ b/WotBlitzStatisticsPro.Tests/OperationStepsTests/GetAccountInfoOperationTest.cs @@ -46,10 +46,10 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests var accountInfoHistorySerialized = JsonConvert.SerializeObject(_contextData.AccountInfoHistory); var expectedAccountInfo = - await File.ReadAllTextAsync($"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\MappedAccountInfo.json"); + await File.ReadAllTextAsync(GetFixturePath("MappedAccountInfo.json")); accountInfoSerialized.Should().Be(expectedAccountInfo); var expectedAccountInfoHistory = - await File.ReadAllTextAsync($"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\MappedAccountHistory.json"); + await File.ReadAllTextAsync(GetFixturePath("MappedAccountHistory.json")); accountInfoHistorySerialized.Should().Be(expectedAccountInfoHistory); } } diff --git a/WotBlitzStatisticsPro.Tests/OperationStepsTests/GetTanksInfoOperationTest.cs b/WotBlitzStatisticsPro.Tests/OperationStepsTests/GetTanksInfoOperationTest.cs index 893c343..3d6d7e1 100644 --- a/WotBlitzStatisticsPro.Tests/OperationStepsTests/GetTanksInfoOperationTest.cs +++ b/WotBlitzStatisticsPro.Tests/OperationStepsTests/GetTanksInfoOperationTest.cs @@ -45,10 +45,10 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests var tanksHistorySerialized = JsonConvert.SerializeObject(_contextData.TanksHistory); var expectedTanksInfo = - await File.ReadAllTextAsync($"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\MappedTanks.json"); + await File.ReadAllTextAsync(GetFixturePath("MappedTanks.json")); tanksSerialized.Should().Be(expectedTanksInfo); var expectedTanksHistory = - await File.ReadAllTextAsync($"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\MappedTanksHistory.json"); + await File.ReadAllTextAsync(GetFixturePath("MappedTanksHistory.json")); tanksHistorySerialized.Should().Be(expectedTanksHistory); } diff --git a/WotBlitzStatisticsPro.Tests/OperationStepsTests/OperationsStepsTestBase.cs b/WotBlitzStatisticsPro.Tests/OperationStepsTests/OperationsStepsTestBase.cs index 6dfbbfa..8f89d06 100644 --- a/WotBlitzStatisticsPro.Tests/OperationStepsTests/OperationsStepsTestBase.cs +++ b/WotBlitzStatisticsPro.Tests/OperationStepsTests/OperationsStepsTestBase.cs @@ -63,10 +63,10 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests var settingsMock = new Mock(); settingsMock.SetupGet(s => s.ApplicationId).Returns(ApplicationId); - var playerInfoFilePath = $"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\PlayerInfo50.json"; - var tanksInfoFilePath = $"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\TanksInfo50.json"; - var playerAchievementsFilePath = $"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\PlayerAchievements50.json"; - var tanksAchievementsFilePath = $"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\TanksAchievemnts50.json"; + var playerInfoFilePath = GetFixturePath("PlayerInfo50.json"); + var tanksInfoFilePath = GetFixturePath("TanksInfo50.json"); + var playerAchievementsFilePath = GetFixturePath("PlayerAchievements50.json"); + var tanksAchievementsFilePath = GetFixturePath("TanksAchievemnts50.json"); var playerInfoRequestUrl = $"https://api.wotblitz.eu/wotb/account/info/?application_id={ApplicationId}&language=en&account_id={AccountId}"; var playerInfoResponse = new HttpResponseMessage @@ -105,7 +105,7 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests protected void InitDataAccessors() { - var tankopediaFile = File.ReadAllText($"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\Tankopedia.json"); + var tankopediaFile = File.ReadAllText(GetFixturePath("Tankopedia.json")); var vehicles = JsonConvert.DeserializeObject>(tankopediaFile); var tankTires = vehicles.Select(v => new {TankId = v.TankId, Tier = v.Tier}) @@ -122,9 +122,9 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests protected void FillAccountAndTanks(AccountInformationPipelineContextData contextData) { - var mappedAccountInfoHistory = File.ReadAllText($"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\MappedAccountHistory.json"); - var mappedTanks = File.ReadAllText($"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\MappedTanks.json"); - var mappedTanksHistory = File.ReadAllText($"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\MappedTanksHistory.json"); + var mappedAccountInfoHistory = File.ReadAllText(GetFixturePath("MappedAccountHistory.json")); + var mappedTanks = File.ReadAllText(GetFixturePath("MappedTanks.json")); + var mappedTanksHistory = File.ReadAllText(GetFixturePath("MappedTanksHistory.json")); contextData.AccountInfo = GetAccountInfoFromFixture(); contextData.AccountInfoHistory = @@ -137,9 +137,13 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests protected AccountInfo GetAccountInfoFromFixture() { - var mappedAccountInfo = File.ReadAllText($"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\MappedAccountInfo.json"); + var mappedAccountInfo = File.ReadAllText(GetFixturePath("MappedAccountInfo.json")); return JsonConvert.DeserializeObject(mappedAccountInfo); } + protected string GetFixturePath(string fixtureFileName) + { + return Path.Combine(TestContext.CurrentContext.TestDirectory, "Fixtures", fixtureFileName); + } } } \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Tests/OperationStepsTests/ReadAccountInfoFromDbOperationTest.cs b/WotBlitzStatisticsPro.Tests/OperationStepsTests/ReadAccountInfoFromDbOperationTest.cs index 179c5e4..9ed8a70 100644 --- a/WotBlitzStatisticsPro.Tests/OperationStepsTests/ReadAccountInfoFromDbOperationTest.cs +++ b/WotBlitzStatisticsPro.Tests/OperationStepsTests/ReadAccountInfoFromDbOperationTest.cs @@ -38,7 +38,7 @@ namespace WotBlitzStatisticsPro.Tests.OperationStepsTests var accountInfoSerialized = JsonConvert.SerializeObject(_contextData.DbAccountInfo); var expectedAccountInfo = - await File.ReadAllTextAsync($"{TestContext.CurrentContext.TestDirectory}\\Fixtures\\MappedAccountInfo.json"); + await File.ReadAllTextAsync(GetFixturePath("MappedAccountInfo.json")); accountInfoSerialized.Should().Be(expectedAccountInfo); }