Beispiel #1
0
        public void CanSafelyOverflow()
        {
            var selector = new BasicLoadBasedSelector(Int32.MaxValue - 10);

            var elements = CreateSelectors(5, 4, 3, 2, 1);

            for (var i = 0; i < 20; i++)
            {
                var selected = selector.Select(elements);
            }
        }
Beispiel #2
0
        public void CanSelectMinimum()
        {
            var selector = new BasicLoadBasedSelector();

            var elements = CreateSelectors(5, 4, 3, 2, 1);

            var selected = selector.Select(elements);

            Assert.AreEqual(1, selected.CurrentLoad);
            Assert.AreEqual(4, selected.Id);
        }
Beispiel #3
0
        public void CanRotateSelectionOnZeroLoads()
        {
            var selector = new BasicLoadBasedSelector();

            var elements = CreateSelectors(0, 0, 0, 0, 0);

            Assert.AreEqual(0, selector.Select(elements).Id);
            Assert.AreEqual(1, selector.Select(elements).Id);
            Assert.AreEqual(2, selector.Select(elements).Id);
            Assert.AreEqual(3, selector.Select(elements).Id);
            Assert.AreEqual(4, selector.Select(elements).Id);
            Assert.AreEqual(0, selector.Select(elements).Id);
        }
Beispiel #4
0
        public void ChoosesFirstWithZeroLoad()
        {
            var selector = new BasicLoadBasedSelector();

            var elements = CreateSelectors(5, 0, 1, 2, 4);

            var selected = selector.Select(elements);

            Assert.AreEqual(1, selected.Id);
            Assert.IsTrue(elements[0].HasBeenChecked);
            Assert.IsTrue(elements[1].HasBeenChecked);
            Assert.IsFalse(elements[2].HasBeenChecked);
            Assert.IsFalse(elements[3].HasBeenChecked);
            Assert.IsFalse(elements[4].HasBeenChecked);
        }