Пример #1
0
        public void AddSystem(ISystem system)
        {
            _systems.Add(system);

            if (system is ISetupSystem)
            {
                SetupSystemHandler.Setup(system as ISetupSystem);
            }

            if (system is IReactToGroupSystem)
            {
                var subscription = ReactToGroupSystemHandler.Setup(system as IReactToGroupSystem);
                _systemSubscriptions.Add(system, new List <SubscriptionToken> {
                    subscription
                });
            }

            if (system is IReactToEntitySystem)
            {
                var subscriptions = ReactToEntitySystemHandler.Setup(system as IReactToEntitySystem);
                _systemSubscriptions.Add(system, new List <SubscriptionToken>(subscriptions));
            }

            if (system.IsReactiveDataSystem())
            {
                var subscriptions = ReactToDataSystemHandler.SetupWithoutType(system);
                _systemSubscriptions.Add(system, new List <SubscriptionToken>(subscriptions));
            }
        }
Пример #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);
     }
 }
Пример #3
0
        public void AddSystem(ISystem system)
        {
            _systems.Add(system);
            var subscriptionList = new List <SubscriptionToken>();

            if (system is ISetupSystem)
            {
                var subscriptions = SetupSystemHandler.Setup(system as ISetupSystem);
                subscriptionList.AddRange(subscriptions);
            }

            if (system is IReactToGroupSystem)
            {
                var subscription = ReactToGroupSystemHandler.Setup(system as IReactToGroupSystem);
                subscriptionList.Add(subscription);
            }

            if (system is IReactToEntitySystem)
            {
                var subscriptions = ReactToEntitySystemHandler.Setup(system as IReactToEntitySystem);
                subscriptionList.AddRange(subscriptions);
            }

            if (system is IManualSystem)
            {
                ManualSystemHandler.Start(system as IManualSystem);
            }

            _systemSubscriptions.Add(system, subscriptionList);
        }
Пример #4
0
        public void should_return_valid_subscription_token_when_processing()
        {
            var mockEnity       = Substitute.For <IEntity>();
            var mockPoolManager = Substitute.For <IPoolManager>();

            mockPoolManager.GetEntitiesFor(Arg.Any <IGroup>()).Returns(new[] { mockEnity });
            var mockSystem = Substitute.For <ISetupSystem>();

            var handler = new SetupSystemHandler(mockPoolManager);

            handler.Setup(mockSystem);

            mockSystem.Received().Setup(mockEnity);
        }
Пример #5
0
        public void should_return_valid_subscription_token_when_processing()
        {
            var mockEnity         = Substitute.For <IEntity>();
            var mockPoolManager   = Substitute.For <IPoolManager>();
            var fakeGroupAccessor = new GroupAccessor(null, new [] { mockEnity });

            mockPoolManager.CreateGroupAccessor(Arg.Any <IGroup>()).Returns(fakeGroupAccessor);
            var mockSystem = Substitute.For <ISetupSystem>();

            mockSystem.TargetGroup.TargettedEntities.Returns(x => null);

            var handler = new SetupSystemHandler(mockPoolManager);

            handler.Setup(mockSystem);

            mockSystem.Received().Setup(mockEnity);
        }