Example #1
0
        public void PullsAnOptionOutBasedOnWeightedValue()
        {
            var table = new WeightedOptionTable<string>();
            table.AddEntry("Foo", 30);
            table.AddEntry("Bar", 20);
            table.AddEntry("Woo", 3);

            Assert.AreEqual("Foo", table.GetOption(23));
            Assert.AreEqual("Bar", table.GetOption(31));
            Assert.AreEqual("Woo", table.GetOption(53));
        }
Example #2
0
 public void ThrowsAnExceptionIfValueDoesNotMeetExpectations()
 {
     var table = new WeightedOptionTable<string>();
     table.AddEntry("Foo", 30);
     table.AddEntry("Bar", 20);
     table.GetOption(160);
 }
Example #3
0
        public void ThrowsAnExceptionIfValueDoesNotMeetExpectations()
        {
            var table = new WeightedOptionTable <string>();

            table.AddEntry("Foo", 30);
            table.AddEntry("Bar", 20);
            Assert.Throws(typeof(IndexOutOfRangeException), () => table.GetOption(160));
        }