Example #1
0
        public void ShouldReceiveModifiedEntity()
        {
            Filter testFilter = new Filter().AnyOf(typeof(FirstTestComponent));

            testSystem.filter = testFilter;
            SystemObserver.Subscribe(testSystem);

            testEntity.AddComponent(new FirstTestComponent());
            Assert.AreSame(testEntity, testSystem.receivedEntity);
        }
Example #2
0
        public void ShouldTriggerSystemIfComponentIsAddedAndMatches()
        {
            Filter testFilter = new Filter().AllOf(typeof(FirstTestComponent), typeof(SecondTestComponent));

            testSystem.filter = testFilter;
            SystemObserver.Subscribe(testSystem);

            testEntity.AddComponent(new FirstTestComponent());
            Assert.IsFalse(testSystem.isTriggered);

            testEntity.AddComponent(new SecondTestComponent());
            Assert.IsTrue(testSystem.isTriggered);
        }
Example #3
0
 public void ShouldRemoveSystemWhenUnSubscribed()
 {
     SystemObserver.Subscribe(testSystem);
     SystemObserver.Unsubscribe(testSystem);
     Assert.AreEqual(0, SystemObserver.reactiveSystems.Count);
 }
Example #4
0
 public void ShouldIgnoreDuplicateSystems()
 {
     SystemObserver.Subscribe(testSystem);
     SystemObserver.Subscribe(testSystem);
     Assert.AreEqual(1, SystemObserver.reactiveSystems.Count);
 }
Example #5
0
 public void ThrowExceptionWhenSubscribeNullSystem()
 {
     SystemObserver.Subscribe(null);
 }
Example #6
0
 public void ShouldAddSystemWhenSubscribed()
 {
     SystemObserver.Subscribe(testSystem);
     Assert.AreEqual(1, SystemObserver.reactiveSystems.Count);
 }