src/GenFx.Components.Tests/IntegerListEntityTest.cs
/// <summary>
/// Tests that the indexer works correctly.
///</summary>
Tests that the indexer works correctly.
Tests that the indexer works correctly .
[Fact]
        public void IntegerListEntity_Indexer()
        {
            GeneticAlgorithm algorithm = GetAlgorithm(3);
            IntegerListEntity entity = new TestIntegerListEntity { MinimumStartingLength = 3, MaximumStartingLength = 3 };
            entity.Initialize(algorithm);
            PrivateObject accessor = new PrivateObject(entity, new PrivateType(typeof(ListEntity<int>)));
            List<int> genes = (List<int>)accessor.GetField("genes");
            for (int i = 0; i < genes.Count; i++)
            {
                genes[i] = 0;
            }
            entity[0] = 1;
            Assert.Equal(1, genes[0]);
            Assert.Equal(0, genes[1]);
            Assert.Equal(0, genes[2]);
            Assert.Equal(1, entity[0]);
            entity[1] = 2;
            Assert.Equal(1, genes[0]);
            Assert.Equal(2, genes[1]);
            Assert.Equal(0, genes[2]);
            Assert.Equal(2, entity[1]);
            entity[2] = 3;
            Assert.Equal(1, genes[0]);
            Assert.Equal(2, genes[1]);
            Assert.Equal(3, genes[2]);
            Assert.Equal(3, entity[2]);
        }
[ Fact ] public void IntegerListEntity_Indexer ( ) { GeneticAlgorithm algorithm = GetAlgorithm ( 3 ) ; IntegerListEntity entity = new TestIntegerListEntity { MinimumStartingLength = 3 , MaximumStartingLength = 3 } ; entity . Initialize ( algorithm ) ; PrivateObject accessor = new PrivateObject ( entity , new PrivateType ( typeof ( ListEntity < int > ) ) ) ; List < int > genes = ( List < int > ) accessor . GetField ( " " ) ; for ( int i = 0 ; i < genes . Count ; i ++ ) { genes [ i ] = 0 ; } entity [ 0 ] = 1 ; Assert . Equal ( 1 , genes [ 0 ] ) ; Assert . Equal ( 0 , genes [ 1 ] ) ; Assert . Equal ( 0 , genes [ 2 ] ) ; Assert . Equal ( 1 , entity [ 0 ] ) ; entity [ 1 ] = 2 ; Assert . Equal ( 1 , genes [ 0 ] ) ; Assert . Equal ( 2 , genes [ 1 ] ) ; Assert . Equal ( 0 , genes [ 2 ] ) ; Assert . Equal ( 2 , entity [ 1 ] ) ; entity [ 2 ] = 3 ; Assert . Equal ( 1 , genes [ 0 ] ) ; Assert . Equal ( 2 , genes [ 1 ] ) ; Assert . Equal ( 3 , genes [ 2 ] ) ; Assert . Equal ( 3 , entity [ 2 ] ) ; }
Tests that the indexer works correctly.
Tests that the indexer works correctly .