Format Style Fixes
This commit is contained in:
@@ -9,12 +9,7 @@ namespace UnitTests.Mock;
|
||||
[Injectable(TypeOverride = typeof(SptLogger<>))]
|
||||
public class MockLogger<T> : ISptLogger<T>
|
||||
{
|
||||
public void LogWithColor(
|
||||
string data,
|
||||
LogTextColor? textColor = null,
|
||||
LogBackgroundColor? backgroundColor = null,
|
||||
Exception? ex = null
|
||||
)
|
||||
public void LogWithColor(string data, LogTextColor? textColor = null, LogBackgroundColor? backgroundColor = null, Exception? ex = null)
|
||||
{
|
||||
Console.WriteLine(data);
|
||||
}
|
||||
@@ -75,12 +70,7 @@ public class MockLogger<T> : ISptLogger<T>
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void LogWithColor(
|
||||
string data,
|
||||
Exception? ex = null,
|
||||
LogTextColor? textColor = null,
|
||||
LogBackgroundColor? backgroundColor = null
|
||||
)
|
||||
public void LogWithColor(string data, Exception? ex = null, LogTextColor? textColor = null, LogBackgroundColor? backgroundColor = null)
|
||||
{
|
||||
Console.WriteLine(data);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ using SPTarkov.Server.Core.Utils.Cloners;
|
||||
namespace UnitTests.Mock;
|
||||
|
||||
[Injectable(TypeOverride = typeof(RandomUtil))]
|
||||
public class MockRandomUtil(ISptLogger<RandomUtil> _logger, ICloner _cloner)
|
||||
: RandomUtil(_logger, _cloner)
|
||||
public class MockRandomUtil(ISptLogger<RandomUtil> _logger, ICloner _cloner) : RandomUtil(_logger, _cloner)
|
||||
{
|
||||
public override int GetInt(int min, int max = Int32.MaxValue, bool exclusive = false)
|
||||
{
|
||||
@@ -67,11 +66,7 @@ public class MockRandomUtil(ISptLogger<RandomUtil> _logger, ICloner _cloner)
|
||||
return GetRandomElement(dictionary.Values);
|
||||
}
|
||||
|
||||
public override double GetNormallyDistributedRandomNumber(
|
||||
double mean,
|
||||
double sigma,
|
||||
int attempt = 0
|
||||
)
|
||||
public override double GetNormallyDistributedRandomNumber(double mean, double sigma, int attempt = 0)
|
||||
{
|
||||
// TODO: No idea what to do with this
|
||||
return base.GetNormallyDistributedRandomNumber(mean, sigma, attempt);
|
||||
@@ -87,20 +82,12 @@ public class MockRandomUtil(ISptLogger<RandomUtil> _logger, ICloner _cloner)
|
||||
return val1;
|
||||
}
|
||||
|
||||
public override List<T> DrawRandomFromList<T>(
|
||||
List<T> originalList,
|
||||
int count = 1,
|
||||
bool replacement = true
|
||||
)
|
||||
public override List<T> DrawRandomFromList<T>(List<T> originalList, int count = 1, bool replacement = true)
|
||||
{
|
||||
return originalList.Slice(0, count);
|
||||
}
|
||||
|
||||
public override List<TKey> DrawRandomFromDict<TKey, TVal>(
|
||||
Dictionary<TKey, TVal> dict,
|
||||
int count = 1,
|
||||
bool replacement = true
|
||||
)
|
||||
public override List<TKey> DrawRandomFromDict<TKey, TVal>(Dictionary<TKey, TVal> dict, int count = 1, bool replacement = true)
|
||||
{
|
||||
// TODO: derandomize
|
||||
return base.DrawRandomFromDict(dict, count, replacement);
|
||||
|
||||
@@ -18,12 +18,7 @@ public partial class ContainerExtensionsTests
|
||||
var itemWidth = 1;
|
||||
var itemHeight = 1;
|
||||
|
||||
var result = container.CanItemBePlacedInContainerAtPosition(
|
||||
itemStartXPos,
|
||||
itemStartYPos,
|
||||
itemWidth,
|
||||
itemHeight
|
||||
);
|
||||
var result = container.CanItemBePlacedInContainerAtPosition(itemStartXPos, itemStartYPos, itemWidth, itemHeight);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
@@ -38,12 +33,7 @@ public partial class ContainerExtensionsTests
|
||||
var itemWidth = 1;
|
||||
var itemHeight = 1;
|
||||
|
||||
var result = container.CanItemBePlacedInContainerAtPosition(
|
||||
itemStartXPos,
|
||||
itemStartYPos,
|
||||
itemWidth,
|
||||
itemHeight
|
||||
);
|
||||
var result = container.CanItemBePlacedInContainerAtPosition(itemStartXPos, itemStartYPos, itemWidth, itemHeight);
|
||||
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
@@ -57,12 +47,7 @@ public partial class ContainerExtensionsTests
|
||||
var itemWidth = 1;
|
||||
var itemHeight = 2;
|
||||
|
||||
var result = container.CanItemBePlacedInContainerAtPosition(
|
||||
itemStartXPos,
|
||||
itemStartYPos,
|
||||
itemWidth,
|
||||
itemHeight
|
||||
);
|
||||
var result = container.CanItemBePlacedInContainerAtPosition(itemStartXPos, itemStartYPos, itemWidth, itemHeight);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
@@ -77,12 +62,7 @@ public partial class ContainerExtensionsTests
|
||||
var itemWidth = 1;
|
||||
var itemHeight = 2;
|
||||
|
||||
var result = container.CanItemBePlacedInContainerAtPosition(
|
||||
itemStartXPos,
|
||||
itemStartYPos,
|
||||
itemWidth,
|
||||
itemHeight
|
||||
);
|
||||
var result = container.CanItemBePlacedInContainerAtPosition(itemStartXPos, itemStartYPos, itemWidth, itemHeight);
|
||||
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
@@ -96,12 +76,7 @@ public partial class ContainerExtensionsTests
|
||||
var itemWidth = 2;
|
||||
var itemHeight = 2;
|
||||
|
||||
var result = container.CanItemBePlacedInContainerAtPosition(
|
||||
itemStartXPos,
|
||||
itemStartYPos,
|
||||
itemWidth,
|
||||
itemHeight
|
||||
);
|
||||
var result = container.CanItemBePlacedInContainerAtPosition(itemStartXPos, itemStartYPos, itemWidth, itemHeight);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
@@ -115,12 +90,7 @@ public partial class ContainerExtensionsTests
|
||||
var itemWidth = 1;
|
||||
var itemHeight = 2;
|
||||
|
||||
var result = container.CanItemBePlacedInContainerAtPosition(
|
||||
itemStartXPos,
|
||||
itemStartYPos,
|
||||
itemWidth,
|
||||
itemHeight
|
||||
);
|
||||
var result = container.CanItemBePlacedInContainerAtPosition(itemStartXPos, itemStartYPos, itemWidth, itemHeight);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
@@ -256,13 +226,7 @@ public partial class ContainerExtensionsTests
|
||||
var destinationPosY = 0;
|
||||
var isRotated = false;
|
||||
|
||||
container.FillContainerMapWithItem(
|
||||
destinationPosX,
|
||||
destinationPosY,
|
||||
itemWidth,
|
||||
itemHeight,
|
||||
isRotated
|
||||
);
|
||||
container.FillContainerMapWithItem(destinationPosX, destinationPosY, itemWidth, itemHeight, isRotated);
|
||||
|
||||
Assert.AreEqual(container[0, 0], 1);
|
||||
}
|
||||
@@ -279,13 +243,7 @@ public partial class ContainerExtensionsTests
|
||||
var destinationPosY = 0;
|
||||
var isRotated = false;
|
||||
|
||||
container.FillContainerMapWithItem(
|
||||
destinationPosX,
|
||||
destinationPosY,
|
||||
itemWidth,
|
||||
itemHeight,
|
||||
isRotated
|
||||
);
|
||||
container.FillContainerMapWithItem(destinationPosX, destinationPosY, itemWidth, itemHeight, isRotated);
|
||||
|
||||
Assert.AreEqual(container[0, 0], 1);
|
||||
Assert.AreEqual(container[1, 0], 1);
|
||||
@@ -303,13 +261,7 @@ public partial class ContainerExtensionsTests
|
||||
var destinationPosY = 0;
|
||||
var isRotated = false;
|
||||
|
||||
container.FillContainerMapWithItem(
|
||||
destinationPosX,
|
||||
destinationPosY,
|
||||
itemWidth,
|
||||
itemHeight,
|
||||
isRotated
|
||||
);
|
||||
container.FillContainerMapWithItem(destinationPosX, destinationPosY, itemWidth, itemHeight, isRotated);
|
||||
|
||||
Assert.AreEqual(container[0, 0], 1);
|
||||
Assert.AreEqual(container[1, 1], 1);
|
||||
@@ -327,13 +279,7 @@ public partial class ContainerExtensionsTests
|
||||
var destinationPosY = 0;
|
||||
var isRotated = true;
|
||||
|
||||
container.FillContainerMapWithItem(
|
||||
destinationPosX,
|
||||
destinationPosY,
|
||||
itemWidth,
|
||||
itemHeight,
|
||||
isRotated
|
||||
);
|
||||
container.FillContainerMapWithItem(destinationPosX, destinationPosY, itemWidth, itemHeight, isRotated);
|
||||
|
||||
Assert.AreEqual(container[0, 0], 1);
|
||||
Assert.AreEqual(container[0, 1], 1);
|
||||
@@ -352,13 +298,7 @@ public partial class ContainerExtensionsTests
|
||||
var destinationPosY = 1;
|
||||
var isRotated = true;
|
||||
|
||||
container.FillContainerMapWithItem(
|
||||
destinationPosX,
|
||||
destinationPosY,
|
||||
itemWidth,
|
||||
itemHeight,
|
||||
isRotated
|
||||
);
|
||||
container.FillContainerMapWithItem(destinationPosX, destinationPosY, itemWidth, itemHeight, isRotated);
|
||||
|
||||
Assert.AreEqual(container[1, 0], 1);
|
||||
Assert.AreEqual(container[1, 1], 1);
|
||||
|
||||
@@ -15,11 +15,7 @@ public class ItemTests
|
||||
public void GetItemWithChildren_one_child_mods_only()
|
||||
{
|
||||
var testData = new List<Item>();
|
||||
var rootItem = new Item
|
||||
{
|
||||
Id = new MongoId(),
|
||||
Template = ItemTpl.AMMOBOX_127X33_COPPER_20RND,
|
||||
};
|
||||
var rootItem = new Item { Id = new MongoId(), Template = ItemTpl.AMMOBOX_127X33_COPPER_20RND };
|
||||
var childItem = new Item
|
||||
{
|
||||
Id = new MongoId(),
|
||||
@@ -38,11 +34,7 @@ public class ItemTests
|
||||
public void GetItemWithChildren_mods_only_one_inventory_item()
|
||||
{
|
||||
var testData = new List<Item>();
|
||||
var rootItem = new Item
|
||||
{
|
||||
Id = new MongoId(),
|
||||
Template = ItemTpl.AMMOBOX_127X33_COPPER_20RND,
|
||||
};
|
||||
var rootItem = new Item { Id = new MongoId(), Template = ItemTpl.AMMOBOX_127X33_COPPER_20RND };
|
||||
var childItem = new Item
|
||||
{
|
||||
Id = new MongoId(),
|
||||
@@ -70,11 +62,7 @@ public class ItemTests
|
||||
public void GetItemWithChildren_mods_and_inventory_item()
|
||||
{
|
||||
var testData = new List<Item>();
|
||||
var rootItem = new Item
|
||||
{
|
||||
Id = new MongoId(),
|
||||
Template = ItemTpl.AMMOBOX_127X33_COPPER_20RND,
|
||||
};
|
||||
var rootItem = new Item { Id = new MongoId(), Template = ItemTpl.AMMOBOX_127X33_COPPER_20RND };
|
||||
var childItem = new Item
|
||||
{
|
||||
Id = new MongoId(),
|
||||
@@ -102,11 +90,7 @@ public class ItemTests
|
||||
public void GetItemWithChildren_mod_with_child()
|
||||
{
|
||||
var testData = new List<Item>();
|
||||
var rootItem = new Item
|
||||
{
|
||||
Id = new MongoId(),
|
||||
Template = ItemTpl.AMMOBOX_127X33_COPPER_20RND,
|
||||
};
|
||||
var rootItem = new Item { Id = new MongoId(), Template = ItemTpl.AMMOBOX_127X33_COPPER_20RND };
|
||||
var childItem = new Item
|
||||
{
|
||||
Id = new MongoId(),
|
||||
@@ -133,11 +117,7 @@ public class ItemTests
|
||||
public void GetItemWithChildren_no_matching_children()
|
||||
{
|
||||
var testData = new List<Item>();
|
||||
var rootItem = new Item
|
||||
{
|
||||
Id = new MongoId(),
|
||||
Template = ItemTpl.AMMOBOX_127X33_COPPER_20RND,
|
||||
};
|
||||
var rootItem = new Item { Id = new MongoId(), Template = ItemTpl.AMMOBOX_127X33_COPPER_20RND };
|
||||
var childItem = new Item
|
||||
{
|
||||
Id = new MongoId(),
|
||||
|
||||
@@ -60,11 +60,7 @@ public class BotWeaponGeneratorTests
|
||||
69
|
||||
);
|
||||
|
||||
var itemSize = _inventoryHelper.GetItemSize(
|
||||
weaponTpl,
|
||||
result.Weapon[0].Id,
|
||||
result.Weapon
|
||||
);
|
||||
var itemSize = _inventoryHelper.GetItemSize(weaponTpl, result.Weapon[0].Id, result.Weapon);
|
||||
|
||||
Assert.AreEqual(weaponTpl, result.WeaponTemplate.Id);
|
||||
|
||||
|
||||
@@ -68,11 +68,7 @@ public class BotGeneratorHelperTests
|
||||
private static List<Item> CreateMp18(MongoId rootWeaponId)
|
||||
{
|
||||
var weaponWithChildren = new List<Item>();
|
||||
var weaponRoot = new Item
|
||||
{
|
||||
Id = rootWeaponId,
|
||||
Template = ItemTpl.SHOTGUN_MP18_762X54R_SINGLESHOT_RIFLE,
|
||||
};
|
||||
var weaponRoot = new Item { Id = rootWeaponId, Template = ItemTpl.SHOTGUN_MP18_762X54R_SINGLESHOT_RIFLE };
|
||||
weaponWithChildren.Add(weaponRoot);
|
||||
var weaponStock = new Item
|
||||
{
|
||||
@@ -134,14 +130,7 @@ public class BotGeneratorHelperTests
|
||||
{ ItemTpl.BARTER_GOLD_SKULL_RING, 1 },
|
||||
{ ItemTpl.BARTER_PACK_OF_NAILS, 1 },
|
||||
};
|
||||
_botLootGenerator.AddLootFromPool(
|
||||
tplsToAdd,
|
||||
[EquipmentSlots.Backpack],
|
||||
4,
|
||||
botInventory,
|
||||
"assault",
|
||||
null
|
||||
);
|
||||
_botLootGenerator.AddLootFromPool(tplsToAdd, [EquipmentSlots.Backpack], 4, botInventory, "assault", null);
|
||||
|
||||
Assert.AreEqual(ItemAddedResult.SUCCESS, result);
|
||||
|
||||
@@ -152,15 +141,8 @@ public class BotGeneratorHelperTests
|
||||
foreach (var item in botInventory.Items.Where(i => tplsToAdd.ContainsKey(i.Template)))
|
||||
{
|
||||
var location = item.Location as ItemLocation;
|
||||
Assert.True(
|
||||
location.X >= 0 && location.X <= 3,
|
||||
"Error! An item was misplaced on the X axis inside the item grid!"
|
||||
);
|
||||
Assert.AreEqual(
|
||||
1,
|
||||
location.Y,
|
||||
"Error! An item was misplaced on the Y axis inside the item grid!"
|
||||
);
|
||||
Assert.True(location.X >= 0 && location.X <= 3, "Error! An item was misplaced on the X axis inside the item grid!");
|
||||
Assert.AreEqual(1, location.Y, "Error! An item was misplaced on the Y axis inside the item grid!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,11 +427,7 @@ public class BotGeneratorHelperTests
|
||||
|
||||
var rootWeaponId = new MongoId();
|
||||
var weaponWithChildren = new List<Item>();
|
||||
var root = new Item
|
||||
{
|
||||
Id = rootWeaponId,
|
||||
Template = ItemTpl.ASSAULTRIFLE_MOLOT_ARMS_VPO136_VEPRKM_762X39_CARBINE,
|
||||
};
|
||||
var root = new Item { Id = rootWeaponId, Template = ItemTpl.ASSAULTRIFLE_MOLOT_ARMS_VPO136_VEPRKM_762X39_CARBINE };
|
||||
weaponWithChildren.Add(root);
|
||||
|
||||
var stock = new Item
|
||||
|
||||
@@ -45,9 +45,7 @@ public class InRaidHelperTests
|
||||
Assert.LessOrEqual(pmcData.Inventory.Items.Count, initialItemCount);
|
||||
|
||||
// Verify that the method completed without throwing collection modification exception
|
||||
Assert.Pass(
|
||||
"DeleteInventory completed successfully without collection modification exception"
|
||||
);
|
||||
Assert.Pass("DeleteInventory completed successfully without collection modification exception");
|
||||
}
|
||||
|
||||
private static PmcData CreateTestPmcData()
|
||||
|
||||
@@ -21,9 +21,7 @@ public class InventoryHelperTests
|
||||
[Test]
|
||||
public void GetItemSize_vss_val()
|
||||
{
|
||||
var vssValPreset = _presetHelper.GetDefaultPreset(
|
||||
ItemTpl.MARKSMANRIFLE_VSS_VINTOREZ_9X39_SPECIAL_SNIPER_RIFLE
|
||||
);
|
||||
var vssValPreset = _presetHelper.GetDefaultPreset(ItemTpl.MARKSMANRIFLE_VSS_VINTOREZ_9X39_SPECIAL_SNIPER_RIFLE);
|
||||
|
||||
var result = _helper.GetItemSize(
|
||||
ItemTpl.MARKSMANRIFLE_VSS_VINTOREZ_9X39_SPECIAL_SNIPER_RIFLE,
|
||||
@@ -38,15 +36,9 @@ public class InventoryHelperTests
|
||||
[Test]
|
||||
public void GetItemSize_m4a1()
|
||||
{
|
||||
var vssValPreset = _presetHelper.GetDefaultPreset(
|
||||
ItemTpl.ASSAULTRIFLE_COLT_M4A1_556X45_ASSAULT_RIFLE
|
||||
);
|
||||
var vssValPreset = _presetHelper.GetDefaultPreset(ItemTpl.ASSAULTRIFLE_COLT_M4A1_556X45_ASSAULT_RIFLE);
|
||||
|
||||
var result = _helper.GetItemSize(
|
||||
ItemTpl.ASSAULTRIFLE_COLT_M4A1_556X45_ASSAULT_RIFLE,
|
||||
vssValPreset.Parent,
|
||||
vssValPreset.Items
|
||||
);
|
||||
var result = _helper.GetItemSize(ItemTpl.ASSAULTRIFLE_COLT_M4A1_556X45_ASSAULT_RIFLE, vssValPreset.Parent, vssValPreset.Items);
|
||||
|
||||
Assert.AreEqual(5, result.Item1);
|
||||
Assert.AreEqual(2, result.Item2);
|
||||
@@ -57,11 +49,7 @@ public class InventoryHelperTests
|
||||
{
|
||||
var vssValPreset = _presetHelper.GetDefaultPreset(ItemTpl.PISTOL_GLOCK_17_9X19);
|
||||
|
||||
var result = _helper.GetItemSize(
|
||||
ItemTpl.PISTOL_GLOCK_17_9X19,
|
||||
vssValPreset.Parent,
|
||||
vssValPreset.Items
|
||||
);
|
||||
var result = _helper.GetItemSize(ItemTpl.PISTOL_GLOCK_17_9X19, vssValPreset.Parent, vssValPreset.Items);
|
||||
|
||||
Assert.AreEqual(2, result.Item1);
|
||||
Assert.AreEqual(1, result.Item2);
|
||||
@@ -73,11 +61,7 @@ public class InventoryHelperTests
|
||||
var rootWeaponId = new MongoId();
|
||||
|
||||
var weaponWithChildren = new List<Item>();
|
||||
var root = new Item
|
||||
{
|
||||
Id = rootWeaponId,
|
||||
Template = ItemTpl.ASSAULTRIFLE_MOLOT_ARMS_VPO136_VEPRKM_762X39_CARBINE,
|
||||
};
|
||||
var root = new Item { Id = rootWeaponId, Template = ItemTpl.ASSAULTRIFLE_MOLOT_ARMS_VPO136_VEPRKM_762X39_CARBINE };
|
||||
weaponWithChildren.Add(root);
|
||||
|
||||
var stock = new Item
|
||||
@@ -119,11 +103,7 @@ public class InventoryHelperTests
|
||||
var rootWeaponId = new MongoId();
|
||||
|
||||
var weaponWithChildren = new List<Item>();
|
||||
var root = new Item
|
||||
{
|
||||
Id = rootWeaponId,
|
||||
Template = ItemTpl.SMG_IWI_UZI_9X19_SUBMACHINE_GUN,
|
||||
};
|
||||
var root = new Item { Id = rootWeaponId, Template = ItemTpl.SMG_IWI_UZI_9X19_SUBMACHINE_GUN };
|
||||
weaponWithChildren.Add(root);
|
||||
|
||||
var stock = new Item
|
||||
@@ -144,11 +124,7 @@ public class InventoryHelperTests
|
||||
};
|
||||
weaponWithChildren.Add(magazine);
|
||||
|
||||
var result = _helper.GetItemSize(
|
||||
ItemTpl.SMG_IWI_UZI_9X19_SUBMACHINE_GUN,
|
||||
rootWeaponId,
|
||||
weaponWithChildren
|
||||
);
|
||||
var result = _helper.GetItemSize(ItemTpl.SMG_IWI_UZI_9X19_SUBMACHINE_GUN, rootWeaponId, weaponWithChildren);
|
||||
|
||||
Assert.AreEqual(3, result.Item1);
|
||||
Assert.AreEqual(2, result.Item2);
|
||||
@@ -160,11 +136,7 @@ public class InventoryHelperTests
|
||||
var rootWeaponId = new MongoId();
|
||||
|
||||
var weaponWithChildren = new List<Item>();
|
||||
var root = new Item
|
||||
{
|
||||
Id = rootWeaponId,
|
||||
Template = ItemTpl.SMG_IWI_UZI_9X19_SUBMACHINE_GUN,
|
||||
};
|
||||
var root = new Item { Id = rootWeaponId, Template = ItemTpl.SMG_IWI_UZI_9X19_SUBMACHINE_GUN };
|
||||
weaponWithChildren.Add(root);
|
||||
|
||||
var stock = new Item
|
||||
@@ -186,11 +158,7 @@ public class InventoryHelperTests
|
||||
};
|
||||
weaponWithChildren.Add(magazine);
|
||||
|
||||
var result = _helper.GetItemSize(
|
||||
ItemTpl.SMG_IWI_UZI_9X19_SUBMACHINE_GUN,
|
||||
rootWeaponId,
|
||||
weaponWithChildren
|
||||
);
|
||||
var result = _helper.GetItemSize(ItemTpl.SMG_IWI_UZI_9X19_SUBMACHINE_GUN, rootWeaponId, weaponWithChildren);
|
||||
|
||||
Assert.AreEqual(2, result.Item1);
|
||||
Assert.AreEqual(2, result.Item2);
|
||||
|
||||
@@ -28,21 +28,9 @@ public class MongoIDTests
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase(
|
||||
"677ddb67406e9918a0264bbz",
|
||||
false,
|
||||
"677ddb67406e9918a0264bbz contains invalid char `z`, but result was true"
|
||||
)]
|
||||
[TestCase(
|
||||
"677ddb67406e9918a0264bbcc",
|
||||
false,
|
||||
"677ddb67406e9918a0264bbcc is 25 characters, but result was true"
|
||||
)]
|
||||
[TestCase(
|
||||
"677ddb67406e9918a0264bbc",
|
||||
true,
|
||||
"IsValidMongoId() `677ddb67406e9918a0264bbc` is a valid mongoId, but result was false"
|
||||
)]
|
||||
[TestCase("677ddb67406e9918a0264bbz", false, "677ddb67406e9918a0264bbz contains invalid char `z`, but result was true")]
|
||||
[TestCase("677ddb67406e9918a0264bbcc", false, "677ddb67406e9918a0264bbcc is 25 characters, but result was true")]
|
||||
[TestCase("677ddb67406e9918a0264bbc", true, "IsValidMongoId() `677ddb67406e9918a0264bbc` is a valid mongoId, but result was false")]
|
||||
public void IsValidMongoIdTest(string mongoId, bool passes, string failMessage)
|
||||
{
|
||||
var result = new MongoId(mongoId);
|
||||
|
||||
@@ -18,13 +18,8 @@ public class JsonUtilTests
|
||||
[Test]
|
||||
public void SerializeAndDeserialize_WithDictionaryOfETFEnum_ExpectCorrectParsing()
|
||||
{
|
||||
var value = new Dictionary<QuestStatusEnum, int>
|
||||
{
|
||||
{ QuestStatusEnum.AvailableForStart, 1 },
|
||||
};
|
||||
var result = _jsonUtil.Deserialize<Dictionary<QuestStatusEnum, int>>(
|
||||
_jsonUtil.Serialize(value)
|
||||
);
|
||||
var value = new Dictionary<QuestStatusEnum, int> { { QuestStatusEnum.AvailableForStart, 1 } };
|
||||
var result = _jsonUtil.Deserialize<Dictionary<QuestStatusEnum, int>>(_jsonUtil.Serialize(value));
|
||||
Assert.AreEqual(value.Count, result?.Count);
|
||||
Assert.AreEqual(value.First().Key, result?.First().Key);
|
||||
Assert.AreEqual(value.First().Value, result?.First().Value);
|
||||
|
||||
@@ -38,9 +38,7 @@ public class MathUtilTests
|
||||
{
|
||||
if (Math.Abs(expected[i] - actual[i]) > 0.00001f)
|
||||
{
|
||||
Assert.Fail(
|
||||
$"ListCumSum() Expected: {string.Join(", ", expected)}, Actual: {string.Join(", ", actual)}"
|
||||
);
|
||||
Assert.Fail($"ListCumSum() Expected: {string.Join(", ", expected)}, Actual: {string.Join(", ", actual)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,9 +55,7 @@ public class MathUtilTests
|
||||
{
|
||||
if (Math.Abs(expected[i] - actual[i]) > 0.00001f)
|
||||
{
|
||||
Assert.Fail(
|
||||
$"ListProduct() Expected: {string.Join(", ", expected)}, Actual: {string.Join(", ", actual)}"
|
||||
);
|
||||
Assert.Fail($"ListProduct() Expected: {string.Join(", ", expected)}, Actual: {string.Join(", ", actual)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,9 +72,7 @@ public class MathUtilTests
|
||||
{
|
||||
if (Math.Abs(expected[i] - actual[i]) > 0.00001f)
|
||||
{
|
||||
Assert.Fail(
|
||||
$"ListProduct() Expected: {string.Join(", ", expected)}, Actual: {string.Join(", ", actual)}"
|
||||
);
|
||||
Assert.Fail($"ListProduct() Expected: {string.Join(", ", expected)}, Actual: {string.Join(", ", actual)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,19 +87,9 @@ public class MathUtilTests
|
||||
Assert.AreEqual(expected, actual, $"MapToRange() Expected: {expected}, Actual: {actual}");
|
||||
}
|
||||
|
||||
[TestCase(
|
||||
15d,
|
||||
new double[] { 1, 10, 20, 30, 40, 50, 60 },
|
||||
new double[] { 11000, 20000, 32000, 45000, 58000, 70000, 82000 },
|
||||
26000d
|
||||
)]
|
||||
[TestCase(15d, new double[] { 1, 10, 20, 30, 40, 50, 60 }, new double[] { 11000, 20000, 32000, 45000, 58000, 70000, 82000 }, 26000d)]
|
||||
[TestCase(5d, new double[] { 1, 10 }, new double[] { 0, 1000 }, 444.44444444444446d)]
|
||||
[TestCase(
|
||||
12d,
|
||||
new double[] { 1, 10, 500, 510 },
|
||||
new double[] { 0, 10, 20, 30 },
|
||||
10.040816326530612d
|
||||
)]
|
||||
[TestCase(12d, new double[] { 1, 10, 500, 510 }, new double[] { 0, 10, 20, 30 }, 10.040816326530612d)]
|
||||
[TestCase(1d, new double[] { 1, 10, 500, 510 }, new double[] { 2, 10, 20, 30 }, 2d)]
|
||||
[TestCase(11d, new double[] { 1, 10 }, new double[] { 2, 10 }, 10d)]
|
||||
public void InterpTest(double input, double[] x, double[] y, double expected)
|
||||
|
||||
@@ -30,10 +30,6 @@ public class MongoIdTests
|
||||
}
|
||||
}
|
||||
|
||||
Assert.AreEqual(
|
||||
0,
|
||||
invalidIds.Count,
|
||||
$"Invalid MongoIds found: {string.Join(", ", invalidIds)}"
|
||||
);
|
||||
Assert.AreEqual(0, invalidIds.Count, $"Invalid MongoIds found: {string.Join(", ", invalidIds)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,7 @@ public sealed class RandomUtilTests
|
||||
|
||||
if (result < 0 || result > 10)
|
||||
{
|
||||
Assert.Fail(
|
||||
$"GetInt(0, 10) out of range. Expected range [0, 10] but was {result}."
|
||||
);
|
||||
Assert.Fail($"GetInt(0, 10) out of range. Expected range [0, 10] but was {result}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,9 +55,7 @@ public sealed class RandomUtilTests
|
||||
|
||||
if (result is < 0d or >= 10d)
|
||||
{
|
||||
Assert.Fail(
|
||||
$"GetDouble(0d, 10d) out of range. Expected range [0.0d, 9.999d] but was {result}."
|
||||
);
|
||||
Assert.Fail($"GetDouble(0d, 10d) out of range. Expected range [0.0d, 9.999d] but was {result}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,12 +66,7 @@ public sealed class RandomUtilTests
|
||||
const float expected = 45.5f;
|
||||
var result = _randomUtil.GetPercentOfValue(45.5f, 100f);
|
||||
|
||||
Assert.AreEqual(
|
||||
expected,
|
||||
result,
|
||||
0.0001f,
|
||||
$"GetPercentOfValue(45.5f, 100f) out of range. Expected: {expected}. Actual: {result}."
|
||||
);
|
||||
Assert.AreEqual(expected, result, 0.0001f, $"GetPercentOfValue(45.5f, 100f) out of range. Expected: {expected}. Actual: {result}.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -100,11 +91,7 @@ public sealed class RandomUtilTests
|
||||
const bool expectedTrue = true;
|
||||
var resultTrue = _randomUtil.GetChance100(100f);
|
||||
|
||||
Assert.AreEqual(
|
||||
expectedTrue,
|
||||
resultTrue,
|
||||
$"GetChance100(100f) out of range. Expected: {expectedTrue}. Actual: {resultTrue}."
|
||||
);
|
||||
Assert.AreEqual(expectedTrue, resultTrue, $"GetChance100(100f) out of range. Expected: {expectedTrue}. Actual: {resultTrue}.");
|
||||
}
|
||||
|
||||
for (var i = 0; i < 100; i++)
|
||||
@@ -131,9 +118,7 @@ public sealed class RandomUtilTests
|
||||
|
||||
if (result < 0 || result > 9)
|
||||
{
|
||||
Assert.Fail(
|
||||
$"RandInt(0, 10) out of range. Expected range [0, 9] but was {result}."
|
||||
);
|
||||
Assert.Fail($"RandInt(0, 10) out of range. Expected range [0, 9] but was {result}.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,9 +128,7 @@ public sealed class RandomUtilTests
|
||||
|
||||
if (result < 0 || result > 9)
|
||||
{
|
||||
Assert.Fail(
|
||||
$"RandInt(10, null) out of range. Expected range [0, 9] but was {result}."
|
||||
);
|
||||
Assert.Fail($"RandInt(10, null) out of range. Expected range [0, 9] but was {result}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,9 +142,7 @@ public sealed class RandomUtilTests
|
||||
|
||||
if (result < 0 || result >= 10)
|
||||
{
|
||||
Assert.Fail(
|
||||
$"RandNum(0, 10) out of range. Expected range [0, 9.999d] but was {result}."
|
||||
);
|
||||
Assert.Fail($"RandNum(0, 10) out of range. Expected range [0, 9.999d] but was {result}.");
|
||||
}
|
||||
|
||||
if (_randomUtil.GetNumberPrecision(result) > RandomUtil.MaxSignificantDigits)
|
||||
@@ -178,9 +159,7 @@ public sealed class RandomUtilTests
|
||||
|
||||
if (result < 0 || result >= 10)
|
||||
{
|
||||
Assert.Fail(
|
||||
$"RandNum(10) out of range. Expected range [0, 9.999d] but was {result}."
|
||||
);
|
||||
Assert.Fail($"RandNum(10) out of range. Expected range [0, 9.999d] but was {result}.");
|
||||
}
|
||||
|
||||
if (_randomUtil.GetNumberPrecision(result) > RandomUtil.MaxSignificantDigits)
|
||||
|
||||
Reference in New Issue
Block a user