Пример #1
0
        public void should_return_valid_subscription_collection()
        {
            var dummyGroup = new GroupBuilder().WithComponent <TestComponentOne>().Build();
            var mockEntity = Substitute.For <IEntity>();

            var mockPoolManager = Substitute.For <IPoolManager>();

            mockPoolManager.CreateGroupAccessor(dummyGroup).Returns(new GroupAccessor(null, new[] { mockEntity }));

            var mockSystem = Substitute.For <IEntityReactionSystem>();

            mockSystem.TargetGroup.Returns(dummyGroup);

            var mockSubscription = Substitute.For <IObservable <IEntity> >();

            mockSystem.Impact(mockEntity).Returns(mockSubscription);

            var handler = new EntityReactionSystemHandler(mockPoolManager);

            var subscriptionTokens = handler.Setup(mockSystem);

            Assert.That(subscriptionTokens.Count(), Is.EqualTo(1));
            //Assert.That(subscriptionTokens.ElementAt(0).AssociatedObject, Is.EqualTo(mockEntity));
            //Assert.That(subscriptionTokens.ElementAt(0).Disposable, Is.Not.Null);
        }
Пример #2
0
 public void AddSystem(ISystem system)
 {
     _systems.Add(system);
     if (system is ISetupSystem)
     {
         _entitySubscribtionsOnSystems.Add(system, SetupSystemHandler.Setup((ISetupSystem)system)
                                           .ToDictionary(x => x.AssociatedObject as IEntity));
     }
     else if (system is IGroupReactionSystem)
     {
         _nonEntitySubscriptions.Add(system, GroupReactionSystemHandler.Setup((IGroupReactionSystem)system));
     }
     else if (system is IEntityReactionSystem)
     {
         _entitySubscribtionsOnSystems.Add(system, EntityReactionSystemHandler.Setup((IEntityReactionSystem)system)
                                           .ToDictionary(x => x.AssociatedObject as IEntity));
     }
     else if (system is IInteractReactionSystem)
     {
         _entitySubscribtionsOnSystems.Add(system, InteractReactionSystemHandler.Setup((IInteractReactionSystem)system)
                                           .ToDictionary(x => x.AssociatedObject as IEntity));
     }
     else if (system is IManualSystem)
     {
         ManualSystemHandler.Start((IManualSystem)system);
     }
 }