Esempio n. 1
0
        public void ListEntity_ThrowsWhenLengthChangedOnFixedSizeList()
        {
            TestListEntity <int> entity = new TestListEntity <int>
            {
                MinimumStartingLength = 2,
                MaximumStartingLength = 2,
                IsFixedSize           = true
            };

            entity.Initialize(new MockGeneticAlgorithm());

            Assert.Equal(2, entity.Length);

            Assert.Throws <ArgumentException>(() => entity.Length = 4);
        }
Esempio n. 2
0
        public void ListEntity_SetLengthToExpand()
        {
            TestListEntity <int> entity = new TestListEntity <int>
            {
                MinimumStartingLength = 2,
                MaximumStartingLength = 2,
            };

            entity.Initialize(new MockGeneticAlgorithm());

            Assert.Equal(2, entity.Length);

            entity.Length = 4;
            Assert.Equal(4, entity.Length);

            Assert.Equal(0, entity[2]);
            Assert.Equal(0, entity[3]);
        }
Esempio n. 3
0
        public void ListEntity_SetLengthToContract()
        {
            TestListEntity <int> entity = new TestListEntity <int>
            {
                MinimumStartingLength = 4,
                MaximumStartingLength = 4,
            };

            entity.Initialize(new MockGeneticAlgorithm());
            Assert.Equal(4, entity.Length);

            entity[0] = 999;
            Assert.Equal(999, entity[0]);

            entity.Length = 1;
            Assert.Equal(1, entity.Length);

            Assert.Equal(999, entity[0]);
        }