Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/explicit assemblies #125

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nunit" Version="4.0.1" />
<PackageReference Include="nunit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DnDGen.Stress" Version="3.5.0" />
<PackageReference Include="nunit" Version="4.0.1" />
<PackageReference Include="DnDGen.Stress" Version="3.5.1" />
<PackageReference Include="nunit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public override void ReplacementStringsAreValid()
public void EpicCoinsPercentile(int level)
{
var tableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXCoins, level);
var levelTable = PercentileMapper.Map(tableName);
var levelTable = PercentileMapper.Map(Name, tableName);

Assert.That(levelTable.Keys, Is.EquivalentTo(Enumerable.Range(1, 100)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void LevelCoinsExistForAllLevels()
for (var level = LevelLimits.Minimum; level <= LevelLimits.Maximum; level++)
{
var levelTableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXCoins, level);
var table = percentileMapper.Map(levelTableName);
var table = percentileMapper.Map(Name, levelTableName);
Assert.That(table, Is.Not.Null);
Assert.That(table.Keys, Is.EqualTo(Enumerable.Range(1, 100)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class CollectionsTests : TableTests
public void CollectionsSetup()
{
CollectionMapper = GetNewInstanceOf<CollectionMapper>();
table = CollectionMapper.Map(tableName);
table = CollectionMapper.Map(Name, tableName);
}

protected IEnumerable<string> GetKeys()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DnDGen.Infrastructure" Version="4.4.2" />
<PackageReference Include="nunit" Version="4.0.1" />
<PackageReference Include="DnDGen.Infrastructure" Version="5.0.0" />
<PackageReference Include="nunit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public override void ReplacementStringsAreValid()
public void EpicGoodsPercentile(int level)
{
var tableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXGoods, level);
var levelTable = PercentileMapper.Map(tableName);
var levelTable = PercentileMapper.Map(Name, tableName);

Assert.That(levelTable.Keys, Is.EquivalentTo(Enumerable.Range(1, 100)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void LevelCoinsExistForAllLevels()
for (var level = LevelLimits.Minimum; level <= LevelLimits.Maximum; level++)
{
var levelTableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXGoods, level);
var table = percentileMapper.Map(levelTableName);
var table = percentileMapper.Map(Name, levelTableName);
Assert.That(table, Is.Not.Null);
Assert.That(table.Keys, Is.EqualTo(Enumerable.Range(1, 100)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void EpicItemsPercentile(int level)
var majorLower = Math.Max(1, 17 - level + 30);

var tableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXItems, level);
var levelTable = PercentileMapper.Map(tableName);
var levelTable = PercentileMapper.Map(Name, tableName);

var mediumEntry = table[1];
var majorEntry = table[50];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void LevelCoinsExistForAllLevels()
for (var level = LevelLimits.Minimum; level <= LevelLimits.Maximum; level++)
{
var levelTableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXItems, level);
var table = percentileMapper.Map(levelTableName);
var table = percentileMapper.Map(Name, levelTableName);
Assert.That(table, Is.Not.Null);
Assert.That(table.Keys, Is.EqualTo(Enumerable.Range(1, 100)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NUnit.Framework;
using DnDGen.TreasureGen.Items;
using DnDGen.TreasureGen.Tables;
using DnDGen.TreasureGen.Items;
using NUnit.Framework;

namespace DnDGen.TreasureGen.Tests.Integration.Tables.Items.Magical.Armor
{
Expand Down Expand Up @@ -61,7 +61,7 @@ public void SpecificArmorAttributes(string name, params string[] attributes)
[TestCase(ArmorConstants.ArmorOfArrowAttraction)]
public void SpecificCursedArmorMatchesAttributes(string item)
{
var specificCursedAttributes = CollectionMapper.Map(TableNameConstants.Collections.Set.SpecificCursedItemAttributes);
var specificCursedAttributes = CollectionMapper.Map(Name, TableNameConstants.Collections.Set.SpecificCursedItemAttributes);
var specificAttributes = GetCollection(item);

Assert.That(specificAttributes, Is.EquivalentTo(specificCursedAttributes[item]));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NUnit.Framework;
using DnDGen.TreasureGen.Items;
using DnDGen.TreasureGen.Items;
using DnDGen.TreasureGen.Items.Magical;
using DnDGen.TreasureGen.Tables;
using NUnit.Framework;

namespace DnDGen.TreasureGen.Tests.Integration.Tables.Items.Magical.Curses
{
Expand Down Expand Up @@ -93,7 +93,7 @@ public void AttributesMatchWeapon(string specificWeapon, string weapon)
var specificWeaponAttributes = table[specificWeapon];

var weaponAttributesTableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Weapon);
var weaponAttributesTable = CollectionMapper.Map(weaponAttributesTableName);
var weaponAttributesTable = CollectionMapper.Map(Name, weaponAttributesTableName);
var weaponAttributes = weaponAttributesTable[weapon];

Assert.That(specificWeaponAttributes, Is.SupersetOf(weaponAttributes));
Expand All @@ -108,7 +108,7 @@ public void SpecificCursedWeaponMatchesAttributes(string item)
{
var specificWeaponAttributesTable = string.Format(TableNameConstants.Collections.Formattable.SpecificITEMTYPEAttributes, ItemTypeConstants.Weapon);

var specificWeaponAttributes = CollectionMapper.Map(specificWeaponAttributesTable);
var specificWeaponAttributes = CollectionMapper.Map(Name, specificWeaponAttributesTable);
var specificCursedAttributes = GetCollection(item);

Assert.That(specificCursedAttributes, Is.EquivalentTo(specificWeaponAttributes[item]));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NUnit.Framework;
using DnDGen.TreasureGen.Items;
using DnDGen.TreasureGen.Items;
using DnDGen.TreasureGen.Items.Magical;
using DnDGen.TreasureGen.Tables;
using NUnit.Framework;

namespace DnDGen.TreasureGen.Tests.Integration.Tables.Items.Magical.Rods
{
Expand Down Expand Up @@ -107,7 +107,7 @@ public void AttributesMatchWeapon(string rod, string weapon)
var rodAttributes = table[rod];

var weaponAttributesTableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Weapon);
var weaponAttributesTable = CollectionMapper.Map(weaponAttributesTableName);
var weaponAttributesTable = CollectionMapper.Map(Name, weaponAttributesTableName);
var weaponAttributes = weaponAttributesTable[weapon];

Assert.That(rodAttributes, Is.SupersetOf(weaponAttributes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void SpecificWeaponAttributes(string name, params string[] attributes)
[TestCase(WeaponConstants.CursedMinus2Sword)]
public void SpecificCursedWeaponMatchesAttributes(string item)
{
var specificCursedAttributes = CollectionMapper.Map(TableNameConstants.Collections.Set.SpecificCursedItemAttributes);
var specificCursedAttributes = CollectionMapper.Map(Name, TableNameConstants.Collections.Set.SpecificCursedItemAttributes);
var specificAttributes = GetCollection(item);

Assert.That(specificAttributes, Is.EquivalentTo(specificCursedAttributes[item]));
Expand Down Expand Up @@ -344,7 +344,7 @@ public void AttributesMatchWeapon(string specificWeapon, string weapon)
var specificWeaponAttributes = table[specificWeapon];

var weaponAttributesTableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Weapon);
var weaponAttributesTable = CollectionMapper.Map(weaponAttributesTableName);
var weaponAttributesTable = CollectionMapper.Map(Name, weaponAttributesTableName);
var weaponAttributes = weaponAttributesTable[weapon];

Assert.That(specificWeaponAttributes, Is.SupersetOf(weaponAttributes));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NUnit.Framework;
using DnDGen.TreasureGen.Items;
using DnDGen.TreasureGen.Tables;
using DnDGen.TreasureGen.Items;
using NUnit.Framework;

namespace DnDGen.TreasureGen.Tests.Integration.Tables.Items.Mundane
{
Expand Down Expand Up @@ -36,7 +36,7 @@ public override void Collections(string name, params string[] attributes)
public void TableContainsAllSpecialMaterials()
{
var materials = TraitConstants.SpecialMaterials.All();
var table = CollectionMapper.Map(tableName);
var table = CollectionMapper.Map(Name, tableName);
Assert.That(table.Keys, Is.SupersetOf(materials));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void ArmorPowerGroupsMatch(string itemName)

var generalArmors = ArmorConstants.GetAllArmorsAndShields(false);
var shields = ArmorConstants.GetAllShields(true);
var cursed = percentileSelector.SelectAllFrom(TableNameConstants.Percentiles.Set.SpecificCursedItems);
var cursed = percentileSelector.SelectAllFrom(Name, TableNameConstants.Percentiles.Set.SpecificCursedItems);

if (!generalArmors.Contains(itemName))
{
Expand Down Expand Up @@ -115,7 +115,7 @@ public void PotionPowerGroupsMatch(string itemName)
{
var possiblePowers = new List<string>();
var powers = table[ItemTypeConstants.Potion];
var cursed = percentileSelector.SelectAllFrom(TableNameConstants.Percentiles.Set.SpecificCursedItems);
var cursed = percentileSelector.SelectAllFrom(Name, TableNameConstants.Percentiles.Set.SpecificCursedItems);

foreach (var power in powers)
{
Expand Down Expand Up @@ -147,7 +147,7 @@ public void RingPowerGroupsMatch(string itemName)
{
var possiblePowers = new List<string>();
var powers = table[ItemTypeConstants.Ring];
var cursed = percentileSelector.SelectAllFrom(TableNameConstants.Percentiles.Set.SpecificCursedItems);
var cursed = percentileSelector.SelectAllFrom(Name, TableNameConstants.Percentiles.Set.SpecificCursedItems);

foreach (var power in powers)
{
Expand All @@ -167,7 +167,7 @@ public void RodPowerGroupsMatch(string itemName)
{
var possiblePowers = new List<string>();
var powers = table[ItemTypeConstants.Rod];
var cursed = percentileSelector.SelectAllFrom(TableNameConstants.Percentiles.Set.SpecificCursedItems);
var cursed = percentileSelector.SelectAllFrom(Name, TableNameConstants.Percentiles.Set.SpecificCursedItems);

foreach (var power in powers)
{
Expand All @@ -186,7 +186,7 @@ public void StaffPowerGroupsMatch(string itemName)
{
var possiblePowers = new List<string>();
var powers = table[ItemTypeConstants.Staff];
var cursed = percentileSelector.SelectAllFrom(TableNameConstants.Percentiles.Set.SpecificCursedItems);
var cursed = percentileSelector.SelectAllFrom(Name, TableNameConstants.Percentiles.Set.SpecificCursedItems);

foreach (var power in powers)
{
Expand Down Expand Up @@ -215,7 +215,7 @@ public void WeaponPowerGroupsMatch(string itemName)
possiblePowers.AddRange(powers);

var generalWeapons = WeaponConstants.GetAllWeapons(false, true);
var cursed = percentileSelector.SelectAllFrom(TableNameConstants.Percentiles.Set.SpecificCursedItems);
var cursed = percentileSelector.SelectAllFrom(Name, TableNameConstants.Percentiles.Set.SpecificCursedItems);

if (!generalWeapons.Contains(itemName))
{
Expand All @@ -242,7 +242,7 @@ public void WondrousItemPowerGroupsMatch(string itemName)
{
var possiblePowers = new List<string>();
var powers = table[ItemTypeConstants.WondrousItem];
var cursed = percentileSelector.SelectAllFrom(TableNameConstants.Percentiles.Set.SpecificCursedItems);
var cursed = percentileSelector.SelectAllFrom(Name, TableNameConstants.Percentiles.Set.SpecificCursedItems);

foreach (var power in powers)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public PercentileTests()
public void PercentileSetup()
{
PercentileMapper = GetNewInstanceOf<PercentileMapper>();
table = PercentileMapper.Map(tableName);
table = PercentileMapper.Map(Name, tableName);
}

public abstract void TableIsComplete();
Expand Down
11 changes: 2 additions & 9 deletions DnDGen.TreasureGen.Tests.Integration.Tables/TableTests.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
using DnDGen.Infrastructure.IoC;
using NUnit.Framework;
using NUnit.Framework;

namespace DnDGen.TreasureGen.Tests.Integration.Tables
{
[TestFixture]
public abstract class TableTests : IntegrationTests
{
protected const string Name = "DnDGen.TreasureGen";
protected abstract string tableName { get; }

[OneTimeSetUp]
public void TableOneTimeSetup()
{
var coreLoader = new InfrastructureModuleLoader();
coreLoader.ReplaceAssemblyLoaderWith<TreasureGenAssemblyLoader>(kernel);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DnDGen.Infrastructure" Version="4.4.2" />
<PackageReference Include="DnDGen.RollGen" Version="15.5.4" />
<PackageReference Include="DnDGen.Infrastructure" Version="5.0.0" />
<PackageReference Include="DnDGen.RollGen" Version="15.5.7" />
<PackageReference Include="Ninject" Version="3.3.6" />
<PackageReference Include="nunit" Version="4.0.1" />
<PackageReference Include="nunit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 14 additions & 0 deletions DnDGen.TreasureGen.Tests.Unit/ConfigTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using NUnit.Framework;

namespace DnDGen.TreasureGen.Tests.Unit
{
internal class ConfigTests
{
[Test]
public void ConfigNameIsCorrect()
{
var configType = typeof(Config);
Assert.That(Config.Name, Is.EqualTo("DnDGen.TreasureGen").And.EqualTo(configType.Namespace));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

<ItemGroup>
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="nunit" Version="4.0.1" />
<PackageReference Include="nunit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void Setup()
var count = 0;
object testLock = new object();
mockCollectionsSelector
.Setup(p => p.SelectRandomFrom(tableName, It.IsAny<string>()))
.Setup(p => p.SelectRandomFrom(Config.Name, tableName, It.IsAny<string>()))
.Returns(() =>
{
lock (testLock)
Expand Down
3 changes: 2 additions & 1 deletion DnDGen.TreasureGen.Tests.Unit/Generators/Items/ArmorTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DnDGen.TreasureGen.Items;
using DnDGen.TreasureGen.Items.Magical;
using Newtonsoft.Json;
using NUnit.Framework;
using System;

Expand Down Expand Up @@ -156,7 +157,7 @@ public void CloneIsSuccessful()

var clone = template.Clone();
Assert.That(clone, Is.Not.SameAs(template));
Assert.That(clone, Is.EqualTo(template));
Assert.That(JsonConvert.SerializeObject(clone), Is.EqualTo(JsonConvert.SerializeObject(template)));
Assert.That(clone.Name, Is.EqualTo(template.Name));

Assert.That(clone.Attributes, Is.EquivalentTo(template.Attributes));
Expand Down
Loading