Esempio n. 1
0
            public void ReturnsComponentForExistentType()
            {
                Entity target = EmptyEntity();
                var component = new FakeComponent1();
                target.AddComponent(component);

                Assert.Equal(component, target.GetComponent<FakeComponent1>());
            }
Esempio n. 2
0
            public void IsNotExecutedForOnlyOneOfTwoComponentsOfInterest()
            {
                var target = new FakeComponent1And2System();
                var world = new EntityWorld();
                world.AddSystem(target);
                var component1 = new FakeComponent1();
                Entity entity = world.CreateEntity();
                entity.AddComponent(component1);

                world.Update(TimeSpan.Zero);

                Assert.False(component1.Processed);
            }
Esempio n. 3
0
            public void IsExecutedForComponentOfInterest()
            {
                var target = new FakeComponent1System();
                var world = new EntityWorld();
                world.AddSystem(target);
                var component = new FakeComponent1();
                Entity entity = world.CreateEntity();
                entity.AddComponent(component);

                world.Update(TimeSpan.Zero);

                Assert.True(component.Processed);
            }
Esempio n. 4
0
            public void IsExecutedForThreeComponentsOfInterest()
            {
                var target = new FakeComponent1And2And3System();
                var world = new EntityWorld();
                world.AddSystem(target);
                var component1 = new FakeComponent1();
                var component2 = new FakeComponent2();
                var component3 = new FakeComponent3();
                Entity entity = world.CreateEntity();
                entity.AddComponent(component1);
                entity.AddComponent(component2);
                entity.AddComponent(component3);

                world.Update(TimeSpan.Zero);

                Assert.True(component1.Processed);
                Assert.True(component2.Processed);
                Assert.True(component3.Processed);
            }
Esempio n. 5
0
            public void IsExecutedForDrawGameLoopSystem()
            {
                var target = new FakeComponentDrawSystem();
                var world = new EntityWorld();
                world.AddSystem(target);
                var component = new FakeComponent1();
                Entity entity = world.CreateEntity();
                entity.AddComponent(component);

                world.Draw();

                Assert.True(component.Processed);
            }
Esempio n. 6
0
            public void IsNotExecutedForDisposedEntity()
            {
                var target = new FakeComponent1System();
                var world = new EntityWorld();
                world.AddSystem(target);
                var component = new FakeComponent1();
                Entity entity = world.CreateEntity();                
                entity.AddComponent(component);
                entity.Dispose();

                world.Update(TimeSpan.Zero);

                Assert.False(component.Processed);
            }
Esempio n. 7
0
            public void IsNotExecutedForDrawSystemInUpdateLoop()
            {
                var target = new FakeComponent1System();
                var world = new EntityWorld();
                world.AddSystem(target);
                var component = new FakeComponent1();
                Entity entity = world.CreateEntity();
                entity.AddComponent(component);

                world.Draw();

                Assert.False(component.Processed);
            }
Esempio n. 8
0
            public void RestoreStateToAPreviousStateWithinSameWorld()
            {
                EntityWorld target = EmptyWorld();
                Entity entity = target.CreateEntity();
                var component = new FakeComponent1();
                entity.AddComponent(component);

                var state = target.GetState();
                component.Processed = true;
                target.RestoreState(state);

                Assert.False(target.GetEntities().First().GetComponent<FakeComponent1>().Processed);
            }
Esempio n. 9
0
            public void TransferDeepCopyOfComponentFromOneWorldToAnother()
            {
                EntityWorld target1 = EmptyWorld();
                Entity entity = target1.CreateEntity();
                var component = new FakeComponent1();
                entity.AddComponent(component);
                EntityWorld target2 = EmptyWorld();

                target2.RestoreState(target1.GetState());
                component.Processed = true;

                Assert.False(target2.GetEntities().First().GetComponent<FakeComponent1>().Processed);
            }