Example #1
0
        public void can_create()
        {
            ILootEntry entry = new ValueLootEntry <string>("test");

            Assert.IsNotNull(entry);
            Assert.IsInstanceOf <ValueLootEntry <string> >(entry);
        }
Example #2
0
        public void value_is_set()
        {
            const string VALUE = "test";

            IValueLootEntry <string> entry = new ValueLootEntry <string>(VALUE);

            Assert.AreEqual(VALUE, entry.Value);
        }
Example #3
0
        public void prob_default_is_one()
        {
            const string VALUE = "test";
            const double PROB  = 1;

            ILootEntry entry = new ValueLootEntry <string>(VALUE);

            Assert.AreEqual(PROB, entry.Probability);
        }
Example #4
0
        public void prob_is_set()
        {
            const string VALUE = "test";
            const double PROB  = 1.2345;

            ILootEntry entry = new ValueLootEntry <string>(VALUE, PROB);

            Assert.AreEqual(PROB, entry.Probability);
        }
Example #5
0
        public void unique_default_is_false()
        {
            const string VALUE  = "test";
            const double PROB   = 1.2345;
            const bool   UNIQUE = false;

            ILootEntry entry = new ValueLootEntry <string>(VALUE, PROB);

            Assert.AreEqual(UNIQUE, entry.Unique);
        }
Example #6
0
        public void unique_is_set()
        {
            const string VALUE  = "test";
            const double PROB   = 1.2345;
            const bool   UNIQUE = true;

            ILootEntry entry = new ValueLootEntry <string>(VALUE, PROB, UNIQUE);

            Assert.AreEqual(UNIQUE, entry.Unique);
        }
Example #7
0
        public void guaranteed_default_is_false()
        {
            const string VALUE      = "test";
            const double PROB       = 1.2345;
            const bool   UNIQUE     = true;
            const bool   GUARANTEED = false;

            ILootEntry entry = new ValueLootEntry <string>(VALUE, PROB, UNIQUE);

            Assert.AreEqual(GUARANTEED, entry.Guaranteed);
        }
Example #8
0
        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));
        }