Exemple #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);
        }
Exemple #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);
        }
Exemple #3
0
 public void ShouldRemoveSystemWhenUnSubscribed()
 {
     SystemObserver.Subscribe(testSystem);
     SystemObserver.Unsubscribe(testSystem);
     Assert.AreEqual(0, SystemObserver.reactiveSystems.Count);
 }
Exemple #4
0
 public void ShouldIgnoreDuplicateSystems()
 {
     SystemObserver.Subscribe(testSystem);
     SystemObserver.Subscribe(testSystem);
     Assert.AreEqual(1, SystemObserver.reactiveSystems.Count);
 }
Exemple #5
0
 public void ThrowExceptionWhenSubscribeNullSystem()
 {
     SystemObserver.Subscribe(null);
 }
Exemple #6
0
 public void ShouldAddSystemWhenSubscribed()
 {
     SystemObserver.Subscribe(testSystem);
     Assert.AreEqual(1, SystemObserver.reactiveSystems.Count);
 }