Skip to content

Commit

Permalink
tests: fix tests not working on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeFwd committed Oct 12, 2024
1 parent 2b80a12 commit 63657d9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ namespace Bannerlord.ExpandedTemplate.Infrastructure.Tests.EquipmentPool.List.Pr
public class CivilianEquipmentPoolProviderShould
{
private const string CachedObjectId = "irrelevant_cached_object_id";

private const string ValidSiegeEquipmentDataFolderPath = "Data\\CivilianEquipmentPoolProvider\\ValidSymbols";
private const string InvalidSiegeEquipmentDataFolderPath = "Data\\CivilianEquipmentPoolProvider\\InvalidSymbols";

private const string MultipleEquipmentRepositoriesDataFolderPath =
"Data\\CivilianEquipmentPoolProvider\\MultipleRepos";
private readonly string _validSiegeEquipmentDataFolderPath =
Path.Combine("Data", "CivilianEquipmentPoolProvider", "ValidSymbols");

private const string FirstEquipmentRepositoryDataFolderPath =
"Data\\CivilianEquipmentPoolProvider\\MultipleRepos\\FirstRepo";
private readonly string _invalidSiegeEquipmentDataFolderPath =
Path.Combine("Data", "CivilianEquipmentPoolProvider", "InvalidSymbols");

private const string SecondEquipmentRepositoryDataFolderPath =
"Data\\CivilianEquipmentPoolProvider\\MultipleRepos\\SecondRepo";
private readonly string _multipleEquipmentRepositoriesDataFolderPath =
Path.Combine("Data", "CivilianEquipmentPoolProvider", "MultipleRepos");

private readonly string _firstEquipmentRepositoryDataFolderPath =
Path.Combine("Data", "CivilianEquipmentPoolProvider", "MultipleRepos", "FirstRepo");

private readonly string _secondEquipmentRepositoryDataFolderPath =
Path.Combine("Data", "CivilianEquipmentPoolProvider", "MultipleRepos", "SecondRepo");

private Mock<ICacheProvider> _cacheProvider;
private Mock<ILogger> _logger;
Expand All @@ -42,29 +45,29 @@ public void SetUp()
public void GetEquipmentPoolsFromSingleRepository()
{
var firstEquipmentRepository =
CreateEquipmentRepository(InputFolder(ValidSiegeEquipmentDataFolderPath));
CreateEquipmentRepository(InputFolder(_validSiegeEquipmentDataFolderPath));
var troopEquipmentReader =
new CivilianEquipmentPoolProvider(_loggerFactory.Object, _cacheProvider.Object, firstEquipmentRepository);

var allTroopEquipmentPools = troopEquipmentReader.GetCivilianEquipmentByCharacterAndPool();

AssertCharacterEquipmentPools(ExpectedFolder(ValidSiegeEquipmentDataFolderPath), allTroopEquipmentPools);
AssertCharacterEquipmentPools(ExpectedFolder(_validSiegeEquipmentDataFolderPath), allTroopEquipmentPools);
}

[Test]
public void GetEquipmentPoolsFromMultipleRepositories()
{
var firstEquipmentRepository =
CreateEquipmentRepository(InputFolder(FirstEquipmentRepositoryDataFolderPath));
CreateEquipmentRepository(InputFolder(_firstEquipmentRepositoryDataFolderPath));
var secondEquipmentRepository =
CreateEquipmentRepository(InputFolder(SecondEquipmentRepositoryDataFolderPath));
CreateEquipmentRepository(InputFolder(_secondEquipmentRepositoryDataFolderPath));
var troopEquipmentReader =
new CivilianEquipmentPoolProvider(_loggerFactory.Object, _cacheProvider.Object, firstEquipmentRepository,
secondEquipmentRepository);

var allTroopEquipmentPools = troopEquipmentReader.GetCivilianEquipmentByCharacterAndPool();

AssertCharacterEquipmentPools(ExpectedFolder(MultipleEquipmentRepositoriesDataFolderPath),
AssertCharacterEquipmentPools(ExpectedFolder(_multipleEquipmentRepositoriesDataFolderPath),
allTroopEquipmentPools);
_logger.Verify(
logger => logger.Warn(
Expand All @@ -78,7 +81,7 @@ public void NotReturnEquipmentPools_WhenInvalidSymbolsAreUsedInCondition()
{
var recruitId = "vlandian_recruit";
var characterEquipmentRepository =
CreateEquipmentRepository(InputFolder(InvalidSiegeEquipmentDataFolderPath));
CreateEquipmentRepository(InputFolder(_invalidSiegeEquipmentDataFolderPath));
var troopEquipmentReader =
new CivilianEquipmentPoolProvider(_loggerFactory.Object, _cacheProvider.Object,
characterEquipmentRepository);
Expand All @@ -94,7 +97,7 @@ public void NotReturnEquipmentPools_WhenInvalidSymbolsAreUsedInCondition()
public void GetCachedEquipmentPools()
{
var characterEquipmentRepository =
CreateEquipmentRepository(InputFolder(InvalidSiegeEquipmentDataFolderPath));
CreateEquipmentRepository(InputFolder(_invalidSiegeEquipmentDataFolderPath));
var troopEquipmentReader =
new CivilianEquipmentPoolProvider(_loggerFactory.Object, _cacheProvider.Object,
characterEquipmentRepository);
Expand All @@ -116,7 +119,7 @@ public void GetCachedEquipmentPools()
_cacheProvider.VerifyAll();
Assert.That(cachedAllTroopEquipmentPools, Is.EqualTo(allTroopEquipmentPools));
}

private IEquipmentPoolsRepository CreateEquipmentRepository(string inputFolderPath)
{
var characterEquipmentRepository = new Mock<IEquipmentPoolsRepository>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ namespace Bannerlord.ExpandedTemplate.Infrastructure.Tests.EquipmentPool.List.Pr
public class SiegeEquipmentPoolProviderShould
{
private const string CachedObjectId = "irrelevant_cached_object_id";

private const string ValidSiegeEquipmentDataFolderPath = "Data\\SiegeEquipmentPoolProvider\\ValidSymbols";
private const string InvalidSiegeEquipmentDataFolderPath = "Data\\SiegeEquipmentPoolProvider\\InvalidSymbols";

private const string MultipleEquipmentRepositoriesDataFolderPath =
"Data\\SiegeEquipmentPoolProvider\\MultipleRepos";
private readonly string _validSiegeEquipmentDataFolderPath =
Path.Combine("Data", "SiegeEquipmentPoolProvider", "ValidSymbols");

private const string FirstEquipmentRepositoryDataFolderPath =
"Data\\SiegeEquipmentPoolProvider\\MultipleRepos\\FirstRepo";
private readonly string _invalidSiegeEquipmentDataFolderPath =
Path.Combine("Data", "SiegeEquipmentPoolProvider", "InvalidSymbols");

private const string SecondEquipmentRepositoryDataFolderPath =
"Data\\SiegeEquipmentPoolProvider\\MultipleRepos\\SecondRepo";
private readonly string _multipleEquipmentRepositoriesDataFolderPath =
Path.Combine("Data", "SiegeEquipmentPoolProvider", "MultipleRepos");

private readonly string _firstEquipmentRepositoryDataFolderPath =
Path.Combine("Data", "SiegeEquipmentPoolProvider", "MultipleRepos", "FirstRepo");

private readonly string _secondEquipmentRepositoryDataFolderPath =
Path.Combine("Data", "SiegeEquipmentPoolProvider", "MultipleRepos", "SecondRepo");

private Mock<ICacheProvider> _cacheProvider;
private Mock<ILogger> _logger;
Expand All @@ -42,23 +45,23 @@ public void SetUp()
public void GetEquipmentPoolsFromSingleRepository()
{
var characterEquipmentRepository =
CreateEquipmentRepository(InputFolder(ValidSiegeEquipmentDataFolderPath));
CreateEquipmentRepository(InputFolder(_validSiegeEquipmentDataFolderPath));
var troopEquipmentReader =
new SiegeEquipmentPoolProvider(_loggerFactory.Object, _cacheProvider.Object, characterEquipmentRepository);

var allTroopEquipmentPools = troopEquipmentReader.GetSiegeEquipmentByCharacterAndPool();

AssertCharacterEquipmentPools(ExpectedFolder(ValidSiegeEquipmentDataFolderPath),
AssertCharacterEquipmentPools(ExpectedFolder(_validSiegeEquipmentDataFolderPath),
allTroopEquipmentPools);
}

[Test]
public void GetEquipmentPoolsFromMultipleRepositories()
{
var firstEquipmentRepository =
CreateEquipmentRepository(InputFolder(FirstEquipmentRepositoryDataFolderPath));
CreateEquipmentRepository(InputFolder(_firstEquipmentRepositoryDataFolderPath));
var secondEquipmentRepository =
CreateEquipmentRepository(InputFolder(SecondEquipmentRepositoryDataFolderPath));
CreateEquipmentRepository(InputFolder(_secondEquipmentRepositoryDataFolderPath));
var troopEquipmentReader =
new SiegeEquipmentPoolProvider(_loggerFactory.Object, _cacheProvider.Object, firstEquipmentRepository,
secondEquipmentRepository);
Expand All @@ -70,7 +73,7 @@ public void GetEquipmentPoolsFromMultipleRepositories()

var allTroopEquipmentPools = troopEquipmentReader.GetSiegeEquipmentByCharacterAndPool();

AssertCharacterEquipmentPools(ExpectedFolder(MultipleEquipmentRepositoriesDataFolderPath),
AssertCharacterEquipmentPools(ExpectedFolder(_multipleEquipmentRepositoriesDataFolderPath),
allTroopEquipmentPools);
_logger.Verify(
logger => logger.Warn(
Expand All @@ -84,7 +87,7 @@ public void GettingSiegeEquipmentPools_WithInvalidSiegeFlags_DoesNotAddEquipment
{
var recruitId = "vlandian_recruit";
var characterEquipmentRepository =
CreateEquipmentRepository(InputFolder(InvalidSiegeEquipmentDataFolderPath));
CreateEquipmentRepository(InputFolder(_invalidSiegeEquipmentDataFolderPath));
var troopEquipmentReader =
new SiegeEquipmentPoolProvider(_loggerFactory.Object, _cacheProvider.Object, characterEquipmentRepository);

Expand All @@ -99,7 +102,7 @@ public void GettingSiegeEquipmentPools_WithInvalidSiegeFlags_DoesNotAddEquipment
public void GetCachedEquipmentPools()
{
var characterEquipmentRepository =
CreateEquipmentRepository(InputFolder(InvalidSiegeEquipmentDataFolderPath));
CreateEquipmentRepository(InputFolder(_invalidSiegeEquipmentDataFolderPath));
var troopEquipmentReader =
new SiegeEquipmentPoolProvider(_loggerFactory.Object, _cacheProvider.Object, characterEquipmentRepository);

Expand Down

0 comments on commit 63657d9

Please sign in to comment.