public void guaranteed_entries_is_set() { const int COUNT = 15; ILootEntry[] LOOT_ENTRIES = new ILootEntry[] { new NullLootEntry(guaranteed: true), new ValueLootEntry <string>("test1"), new ValueLootEntry <string>("test2", guaranteed: true), }; ILootTable table = new LootTable(COUNT, LOOT_ENTRIES); foreach (ILootEntry expectedEntry in LOOT_ENTRIES) { if (expectedEntry.Guaranteed) { Assert.IsTrue(table.GuaranteedEntries.Contains(expectedEntry)); } else { Assert.IsFalse(table.GuaranteedEntries.Contains(expectedEntry)); } } }
public void entries_is_set() { const int COUNT = 15; ILootEntry[] LOOT_ENTRIES = new ILootEntry[] { new NullLootEntry(), new ValueLootEntry <string>("test"), }; ILootTable table = new LootTable(COUNT, LOOT_ENTRIES); foreach (ILootEntry expectedEntry in LOOT_ENTRIES) { Assert.IsTrue(table.Entries.Contains(expectedEntry)); } }
public void get_loot_returns_only_one_unique_entry() { const int COUNT = 15; ILootEntry UNIQUE_ENTRY = new ValueLootEntry <string>("test4", prob: 100, unique: true); ILootEntry[] LOOT_ENTRIES = new ILootEntry[] { new NullLootEntry(), new ValueLootEntry <string>("test1"), new ValueLootEntry <string>("test2"), new ValueLootEntry <string>("test3"), UNIQUE_ENTRY, }; LootTable table = new LootTable(COUNT, LOOT_ENTRIES); IReadOnlyCollection <ILootEntry> results = table.GetLoot(); Assert.LessOrEqual(1, results.Count(x => x == UNIQUE_ENTRY)); }
public void get_loot_returns_proper_count_when_no_guaranteed() { ILootEntry[] LOOT_ENTRIES = new ILootEntry[] { new NullLootEntry(), new ValueLootEntry <string>("test1"), new ValueLootEntry <string>("test2"), }; LootTable table = new LootTable(1, LOOT_ENTRIES); table.Count = 1; Assert.AreEqual(table.Count, table.GetLoot().Count); table.Count = 3; Assert.AreEqual(table.Count, table.GetLoot().Count); table.Count = 5; Assert.AreEqual(table.Count, table.GetLoot().Count); }
public void all_values_are_eventually_returned() { const int COUNT = 1000; ILootEntry[] LOOT_ENTRIES = new ILootEntry[] { new NullLootEntry(), new ValueLootEntry <string>("test1", prob: 1), new ValueLootEntry <string>("test2", prob: 10), new ValueLootEntry <string>("test3", prob: 5), new ValueLootEntry <string>("test4", prob: 20), }; LootTable table = new LootTable(COUNT, LOOT_ENTRIES); IReadOnlyCollection <ILootEntry> results = table.GetLoot(); bool containSameEntries = results.Distinct().ToHashSet().SetEquals(LOOT_ENTRIES); Assert.IsTrue(containSameEntries); }