Пример #1
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);
        }
Пример #2
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));
            }
        }
        public void should_return_valid_subscription_token_when_processing()
        {
            var mockPoolManager  = Substitute.For <IPoolManager>();
            var mockSystem       = Substitute.For <IReactToGroupSystem>();
            var mockSubscription = Substitute.For <IObservable <GroupAccessor> >();

            mockSystem.ReactToGroup(Arg.Any <GroupAccessor>()).Returns(mockSubscription);

            var handler           = new ReactToGroupSystemHandler(mockPoolManager);
            var subscriptionToken = handler.Setup(mockSystem);

            Assert.That(subscriptionToken, Is.Not.Null);
            Assert.That(subscriptionToken.AssociatedObject, Is.Null);
            Assert.That(subscriptionToken.Disposable, Is.Not.Null);
        }