Ejemplo n.º 1
0
        public void should_correctly_expand_for_new_entities()
        {
            var startingSize       = 10;
            var expectedSize       = 20;
            var fakeComponentTypes = new Dictionary <Type, int>
            {
                { typeof(TestComponentOne), 0 },
                { typeof(TestComponentTwo), 1 },
                { typeof(TestComponentThree), 2 }
            };

            var mockComponentLookup = Substitute.For <IComponentTypeLookup>();

            mockComponentLookup.GetAllComponentTypes().Returns(fakeComponentTypes);

            var database = new ComponentDatabase(mockComponentLookup, startingSize);

            database.AccommodateMoreEntities(expectedSize);

            Assert.Equal(expectedSize, database.CurrentEntityBounds);
            Assert.Equal(fakeComponentTypes.Count, database.EntityComponents.Length);
            Assert.Equal(expectedSize, database.EntityComponents[0].Count);
            Assert.All(database.EntityComponents, x => x.All(y => y == null));
        }