Esempio n. 1
0
        public void TestForceAndResetForced()
        {
            var itemSelector = new RouletteWheel();
            var allState     = new AllocationState(10, 15, new Single[] { 1.5F, 2.5F, 3.5F, 4.5F, 5.5F }, itemSelector);

            allState.Reset();
            allState.Force(2);
            //Overwrites currentaptitudes
            for (int i = 0; i < allState.InitialAptitudes.Length; i++)
            {
                allState.CurrentAptitudes[i] = 0;
            }

            allState.Reset();
            Assert.That(allState.Processed, Is.False);
            Assert.That(allState.Forced, Is.False);
            Assert.That(allState.ChosenItem, Is.Null);
        }
Esempio n. 2
0
        public void ShouldResetCorrectlyInitializeState()
        {
            var itemSelector = new RouletteWheel();
            var allState     = new AllocationState(10, 15, new Single[] { 1.5F, 2.5F, 3.5F, 4.5F, 5.5F }, itemSelector);

            allState.Reset();
            Assert.That(allState.Processed, Is.False);
            Assert.That(allState.Forced, Is.False);
            Assert.That(allState.ChosenItem, Is.Null);
            Assert.That(allState.InitialAptitudes, Is.EquivalentTo(allState.CurrentAptitudes));
        }
Esempio n. 3
0
        public void TestForce()
        {
            var itemSelector = new RouletteWheel();
            var allState     = new AllocationState(10, 15, new Single[] { 1.5F, 2.5F, 3.5F, 4.5F, 5.5F }, itemSelector);

            allState.Reset();
            allState.Force(2);
            Assert.That(allState.Processed, Is.True);
            Assert.That(allState.Forced, Is.True);
            Assert.That(allState.ChosenItem, Is.EqualTo(2));
        }
Esempio n. 4
0
        public void TestProcessNull()
        {
            int?expResult = null;
            var array     = new Single[] { 1.5F, 2.5F, 3.5F, 4.5F, 5.5F };
            var rndValue  = .3F;

            var itemSelectorMock = new Mock <IItemSelector>();

            itemSelectorMock.Setup(x => x.SelectItem(array, rndValue)).Returns(expResult);
            var itemSelector = itemSelectorMock.Object;

            var allState = new AllocationState(10, 15, array, itemSelector);

            allState.Reset();

            allState.Process(rndValue);

            Assert.That(allState.Processed, Is.True);
            Assert.That(allState.Forced, Is.False);
            Assert.That(allState.ChosenItem, Is.Null);
            itemSelectorMock.Verify(x => x.SelectItem(array, rndValue), Times.Once);
        }