コード例 #1
0
        public void EngineUseTest()
        {
            IYodiiEngine engine = new YodiiEngine(new YodiiEngineHostMock());

            Assert.Throws <ArgumentNullException>(() => engine.SetDiscoveredInfo(null));

            DiscoveredInfo discoveredInfo = MockInfoFactory.CreateGraph003();

            IYodiiEngineResult result = engine.SetDiscoveredInfo(discoveredInfo);

            Assert.That(result.Success, Is.True);
            Assert.That(engine.DiscoveredInfo == discoveredInfo);

            PluginInfo  pluginA1 = discoveredInfo.FindPlugin("PluginA-1");
            PluginInfo  pluginA2 = discoveredInfo.FindPlugin("PluginA-2");
            ServiceInfo serviceA = discoveredInfo.FindService("ServiceA");



            result = engine.Start();
            Assert.That(result.Success, Is.True);
            Assert.That(engine.LiveInfo, Is.Not.Null);
            Assert.That(engine.LiveInfo.FindPlugin(pluginA1.PluginFullName).PluginInfo, Is.EqualTo(pluginA1));
            Assert.That(engine.LiveInfo.FindPlugin(pluginA2.PluginFullName).PluginInfo, Is.EqualTo(pluginA2));
            Assert.That(engine.LiveInfo.FindService(serviceA.ServiceFullName).ServiceInfo, Is.EqualTo(serviceA));

            Assert.That(engine.LiveInfo.FindPlugin(pluginA1.PluginFullName).IsRunning, Is.False);
            Assert.That(engine.LiveInfo.FindPlugin(pluginA2.PluginFullName).IsRunning, Is.False);
            Assert.That(engine.LiveInfo.FindService(serviceA.ServiceFullName).IsRunning, Is.False);

            Assert.That(engine.LiveInfo.FindPlugin(pluginA1.PluginFullName).RunningStatus, Is.EqualTo(RunningStatus.Stopped));
            Assert.That(engine.LiveInfo.FindPlugin(pluginA2.PluginFullName).RunningStatus, Is.EqualTo(RunningStatus.Stopped));
            Assert.That(engine.LiveInfo.FindService(serviceA.ServiceFullName).RunningStatus, Is.EqualTo(RunningStatus.Stopped));

            Assert.That(engine.LiveInfo.FindPlugin(pluginA1.PluginFullName).Service, Is.EqualTo(engine.LiveInfo.FindService(serviceA.ServiceFullName)));
            Assert.That(engine.LiveInfo.FindPlugin(pluginA2.PluginFullName).Service, Is.EqualTo(engine.LiveInfo.FindService(serviceA.ServiceFullName)));
            Assert.That(engine.LiveInfo.FindService(serviceA.ServiceFullName).Generalization, Is.Null);

            Assert.That(engine.LiveInfo.FindPlugin(pluginA1.PluginFullName).ConfigOriginalStatus, Is.EqualTo(ConfigurationStatus.Optional));
            Assert.That(engine.LiveInfo.FindPlugin(pluginA2.PluginFullName).ConfigOriginalStatus, Is.EqualTo(ConfigurationStatus.Optional));
            Assert.That(engine.LiveInfo.FindService(serviceA.ServiceFullName).ConfigOriginalStatus, Is.EqualTo(ConfigurationStatus.Optional));

            Assert.That(engine.LiveInfo.FindPlugin(pluginA1.PluginFullName).WantedConfigSolvedStatus, Is.EqualTo(SolvedConfigurationStatus.Runnable));
            Assert.That(engine.LiveInfo.FindPlugin(pluginA2.PluginFullName).WantedConfigSolvedStatus, Is.EqualTo(SolvedConfigurationStatus.Runnable));
            Assert.That(engine.LiveInfo.FindService(serviceA.ServiceFullName).WantedConfigSolvedStatus, Is.EqualTo(SolvedConfigurationStatus.Runnable));

            Assert.That(engine.LiveInfo.FindPlugin(pluginA1.PluginFullName).CurrentError, Is.Null);
            Assert.That(engine.LiveInfo.FindPlugin(pluginA2.PluginFullName).CurrentError, Is.Null);
            Assert.That(engine.LiveInfo.FindService(serviceA.ServiceFullName).DisabledReason, Is.Null);

            engine.Stop();
        }
コード例 #2
0
        public void EngineUseTest()
        {
            IYodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );

            Assert.Throws<ArgumentNullException>( () => engine.SetDiscoveredInfo( null ) );

            DiscoveredInfo discoveredInfo = MockInfoFactory.CreateGraph003();

            IYodiiEngineResult result = engine.SetDiscoveredInfo( discoveredInfo );
            Assert.That( result.Success, Is.True );
            Assert.That( engine.DiscoveredInfo == discoveredInfo );

            PluginInfo pluginA1 = discoveredInfo.FindPlugin( "PluginA-1" );
            PluginInfo pluginA2 = discoveredInfo.FindPlugin( "PluginA-2" );
            ServiceInfo serviceA = discoveredInfo.FindService( "ServiceA" );

            result = engine.Start();
            Assert.That( result.Success, Is.True );
            Assert.That( engine.LiveInfo, Is.Not.Null );
            Assert.That( engine.LiveInfo.FindPlugin( pluginA1.PluginFullName ).PluginInfo, Is.EqualTo( pluginA1 ) );
            Assert.That( engine.LiveInfo.FindPlugin( pluginA2.PluginFullName ).PluginInfo, Is.EqualTo( pluginA2 ) );
            Assert.That( engine.LiveInfo.FindService( serviceA.ServiceFullName ).ServiceInfo, Is.EqualTo( serviceA ) );

            Assert.That( engine.LiveInfo.FindPlugin( pluginA1.PluginFullName ).IsRunning, Is.False );
            Assert.That( engine.LiveInfo.FindPlugin( pluginA2.PluginFullName ).IsRunning, Is.False );
            Assert.That( engine.LiveInfo.FindService( serviceA.ServiceFullName ).IsRunning, Is.False );

            Assert.That( engine.LiveInfo.FindPlugin( pluginA1.PluginFullName ).RunningStatus, Is.EqualTo( RunningStatus.Stopped ) );
            Assert.That( engine.LiveInfo.FindPlugin( pluginA2.PluginFullName ).RunningStatus, Is.EqualTo( RunningStatus.Stopped ) );
            Assert.That( engine.LiveInfo.FindService( serviceA.ServiceFullName ).RunningStatus, Is.EqualTo( RunningStatus.Stopped ) );

            Assert.That( engine.LiveInfo.FindPlugin( pluginA1.PluginFullName ).Service, Is.EqualTo( engine.LiveInfo.FindService( serviceA.ServiceFullName ) ) );
            Assert.That( engine.LiveInfo.FindPlugin( pluginA2.PluginFullName ).Service, Is.EqualTo( engine.LiveInfo.FindService( serviceA.ServiceFullName ) ) );
            Assert.That( engine.LiveInfo.FindService( serviceA.ServiceFullName ).Generalization, Is.Null );

            Assert.That( engine.LiveInfo.FindPlugin( pluginA1.PluginFullName ).ConfigOriginalStatus, Is.EqualTo( ConfigurationStatus.Optional ) );
            Assert.That( engine.LiveInfo.FindPlugin( pluginA2.PluginFullName ).ConfigOriginalStatus, Is.EqualTo( ConfigurationStatus.Optional ) );
            Assert.That( engine.LiveInfo.FindService( serviceA.ServiceFullName ).ConfigOriginalStatus, Is.EqualTo( ConfigurationStatus.Optional ) );

            Assert.That( engine.LiveInfo.FindPlugin( pluginA1.PluginFullName ).WantedConfigSolvedStatus, Is.EqualTo( SolvedConfigurationStatus.Runnable ) );
            Assert.That( engine.LiveInfo.FindPlugin( pluginA2.PluginFullName ).WantedConfigSolvedStatus, Is.EqualTo( SolvedConfigurationStatus.Runnable ) );
            Assert.That( engine.LiveInfo.FindService( serviceA.ServiceFullName ).WantedConfigSolvedStatus, Is.EqualTo( SolvedConfigurationStatus.Runnable ) );

            Assert.That( engine.LiveInfo.FindPlugin( pluginA1.PluginFullName ).CurrentError, Is.Null );
            Assert.That( engine.LiveInfo.FindPlugin( pluginA2.PluginFullName ).CurrentError, Is.Null );
            Assert.That( engine.LiveInfo.FindService( serviceA.ServiceFullName ).DisabledReason, Is.Null );

            engine.Stop();
        }
コード例 #3
0
        public static YodiiEngine CreateEngineFromXml(XmlReader r)
        {
            YodiiEngine    e = new YodiiEngine(new YodiiEngineHostMock());
            DiscoveredInfo d = new DiscoveredInfo();

            // Used to index reference links between plugins and services.
            List <PendingGeneralization>   pendingGeneralizations   = new List <PendingGeneralization>();
            List <PendingPluginService>    pendingPluginServices    = new List <PendingPluginService>();
            List <PendingServiceReference> pendingServiceReferences = new List <PendingServiceReference>();

            CKSortedArrayKeyList <PluginInfo, string>  loadedPlugins;
            CKSortedArrayKeyList <ServiceInfo, string> loadedServices;

            loadedServices = new CKSortedArrayKeyList <ServiceInfo, string>(s => s.ServiceFullName, false);
            loadedPlugins  = new CKSortedArrayKeyList <PluginInfo, string>(p => p.PluginFullName, false);

            while (r.Read())
            {
                // Load services
                if (r.IsStartElement() && r.Name == "Services")
                {
                    ReadServices(r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingGeneralizations, pendingPluginServices, pendingServiceReferences);
                }

                // Load plugins
                if (r.IsStartElement() && r.Name == "Plugins")
                {
                    ReadPlugins(r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingPluginServices, pendingServiceReferences);
                }

                // Read configuration manager
                if (r.IsStartElement() && r.Name == "Configuration")
                {
                    ReadConfigurationManager(e.Configuration, r.ReadSubtree());
                }
            }

            e.SetDiscoveredInfo(d);

            return(e);
        }
コード例 #4
0
ファイル: MockXmlUtils.cs プロジェクト: julien-moreau/yodii
        public static YodiiEngine CreateEngineFromXml( XmlReader r )
        {
            YodiiEngine e = new YodiiEngine( new YodiiEngineHostMock() );
            DiscoveredInfo d = new DiscoveredInfo();

            // Used to index reference links between plugins and services.
            List<PendingGeneralization> pendingGeneralizations = new List<PendingGeneralization>();
            List<PendingPluginService> pendingPluginServices = new List<PendingPluginService>();
            List<PendingServiceReference> pendingServiceReferences = new List<PendingServiceReference>();

            CKSortedArrayKeyList<PluginInfo, string> loadedPlugins;
            CKSortedArrayKeyList<ServiceInfo, string> loadedServices;
            loadedServices = new CKSortedArrayKeyList<ServiceInfo, string>( s => s.ServiceFullName, false );
            loadedPlugins = new CKSortedArrayKeyList<PluginInfo, string>( p => p.PluginFullName, false );

            while( r.Read() )
            {
                // Load services
                if( r.IsStartElement() && r.Name == "Services" )
                {
                    ReadServices( r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingGeneralizations, pendingPluginServices, pendingServiceReferences );
                }

                // Load plugins
                if( r.IsStartElement() && r.Name == "Plugins" )
                {
                    ReadPlugins( r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingPluginServices, pendingServiceReferences );
                }

                // Read configuration manager
                if( r.IsStartElement() && r.Name == "Configuration" )
                {
                    ReadConfigurationManager( e.Configuration, r.ReadSubtree() );
                }
            }

            e.SetDiscoveredInfo( d );

            return e;
        }
コード例 #5
0
        public void Invalid001c()
        {
            #region graph
            /**
             *                  +--------+                              +--------+
             *      +---------->|ServiceA+-------+   *----------------->|ServiceB|
             *      |           |Optional|       |   | Need Running     |Disable |
             *      |           +---+----+       |   |                  +---+----+
             *      |               |            |   |                      |
             *      |               |            |   |                      |
             *      |               |            |   |                      |
             *  +---+-----+         |        +---+---*-+                    |
             *  |ServiceAx|     +---+-----+  |PluginA-2|                +---+-----+
             *  |Optional |     |PluginA-1|  |Running  |                |PluginB-1|
             *  +----+----+     |Optional |  +---------+                |Optional |
             *       |          +---------+                             +---------+
             *       |
             *  +----+-----+
             *  |PluginAx-1|
             *  |Optional  |
             *  +----------+
             */
            #endregion

            DiscoveredInfo info = MockInfoFactory.CreateGraph001();
            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            engine.SetDiscoveredInfo( info );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();
            cl.Items.Add( "ServiceB", ConfigurationStatus.Disabled );
            cl.Items.Add( "PluginA-2", ConfigurationStatus.Running );

            engine.FullStaticResolutionOnly( res =>
            {
                res.CheckAllBlockingPluginsAre( "PluginA-2" );
                res.CheckNoBlockingServices();
            } );
        }
コード例 #6
0
        public void ConfigChanged()
        {
            /**
             *  +--------+
             *  |ServiceA+ ------+
             *  |        |       |
             *  +---+----+       |
             *      |            |
             *      |            |
             *      |            |
             *      |        +---+---*-+
             *  +---+-----+  |PluginA-2|
             *  |PluginA-1|  |         |
             *  |         |  +---------+
             *  +---------+
             */
            DiscoveredInfo info = MockInfoFactory.CreateGraph003();
            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            engine.SetDiscoveredInfo( info );
            engine.Start();
            ILiveServiceInfo sA = engine.LiveInfo.FindService( "ServiceA" );
            ILivePluginInfo p1 = engine.LiveInfo.FindPlugin( "PluginA-1" );
            ILivePluginInfo p2 = engine.LiveInfo.FindPlugin( "PluginA-2" );

            Assert.That( sA != null && p1 != null && p2 != null );

            Assert.That( p1.Capability.CanStart && p2.Capability.CanStart && sA.Capability.CanStart, Is.True );
            Assert.That( p1.Capability.CanStartWithFullStart && p2.Capability.CanStartWithFullStart && sA.Capability.CanStartWithFullStart, Is.True );
            Assert.That( p1.Capability.CanStartWithStartRecommended && p2.Capability.CanStartWithStartRecommended && sA.Capability.CanStartWithStartRecommended, Is.True );
            Assert.That( p1.Capability.CanStartWithStopOptionalAndRunnable && p2.Capability.CanStartWithStopOptionalAndRunnable && sA.Capability.CanStartWithStopOptionalAndRunnable, Is.True );
            Assert.That( p1.Capability.CanStartWithFullStop && p2.Capability.CanStartWithFullStop && sA.Capability.CanStartWithFullStop, Is.True );

            HashSet<string> propertyChanged = new HashSet<string>();
            p1.PropertyChanged += ( s, e ) =>
                                    {
                                        Assert.That( s, Is.SameAs( p1 ) );
                                        Assert.That( propertyChanged.Add( "p1."+e.PropertyName ) );
                                    };
            p1.Capability.PropertyChanged += ( s, e ) =>
                                                {
                                                    Assert.That( s, Is.SameAs( p1.Capability ) );
                                                    Assert.That( propertyChanged.Add( "p1.Capablity."+e.PropertyName ) );
                                                };
            p2.PropertyChanged += ( s, e ) =>
                                    {
                                        Assert.That( s, Is.SameAs( p2 ) );
                                        Assert.That( propertyChanged.Add( "p2."+e.PropertyName ) );
                                    };
            p2.Capability.PropertyChanged += ( s, e ) =>
                                                {
                                                    Assert.That( s, Is.SameAs( p2.Capability ) );
                                                    Assert.That( propertyChanged.Add( "p2.Capablity."+e.PropertyName ) );
                                                };
            sA.PropertyChanged += ( s, e ) =>
                                    {
                                        Assert.That( s, Is.SameAs( sA ) );
                                        Assert.That( propertyChanged.Add( "sA."+e.PropertyName ) );
                                    };
            sA.Capability.PropertyChanged += ( s, e ) =>
                                                {
                                                    Assert.That( s, Is.SameAs( sA.Capability ) );
                                                    Assert.That( propertyChanged.Add( "sA.Capablity."+e.PropertyName ) );
                                                };

            IConfigurationLayer config = engine.Configuration.Layers.Create( "Default" );
            config.Items.Add( p1.FullName, ConfigurationStatus.Disabled );

            Assert.That( p1.Capability.CanStart && p1.Capability.CanStartWithFullStart
                        && p1.Capability.CanStartWithStartRecommended && p1.Capability.CanStartWithStopOptionalAndRunnable
                        && p1.Capability.CanStartWithFullStop, Is.False );

            Assert.That( p2.Capability.CanStart && sA.Capability.CanStart, Is.True );
            Assert.That( p2.Capability.CanStartWithFullStart && sA.Capability.CanStartWithFullStart, Is.True );
            Assert.That( p2.Capability.CanStartWithStartRecommended && sA.Capability.CanStartWithStartRecommended, Is.True );
            Assert.That( p2.Capability.CanStartWithStopOptionalAndRunnable && sA.Capability.CanStartWithStopOptionalAndRunnable, Is.True );
            Assert.That( p2.Capability.CanStartWithFullStop && sA.Capability.CanStartWithFullStop, Is.True );

            CollectionAssert.AreEquivalent( new string[]{
                "p1.Capablity.CanStart",
                "p1.Capablity.CanStartWithFullStart",
                "p1.Capablity.CanStartWithStartRecommended",
                "p1.Capablity.CanStartWithStopOptionalAndRunnable",
                "p1.Capablity.CanStartWithFullStop",
                "p1.DisabledReason",
                "p1.RunningStatus",
                "p1.ConfigOriginalStatus",
                "p1.WantedConfigSolvedStatus",
                "p1.FinalConfigSolvedStatus" }, propertyChanged );
            propertyChanged.Clear();

            config.Items.Add( p1.FullName, ConfigurationStatus.Optional );

            CollectionAssert.AreEquivalent( new string[]{
                "p1.Capablity.CanStart",
                "p1.Capablity.CanStartWithFullStart",
                "p1.Capablity.CanStartWithStartRecommended",
                "p1.Capablity.CanStartWithStopOptionalAndRunnable",
                "p1.Capablity.CanStartWithFullStop",
                "p1.DisabledReason",
                "p1.RunningStatus",
                "p1.ConfigOriginalStatus",
                "p1.WantedConfigSolvedStatus",
                "p1.FinalConfigSolvedStatus" }, propertyChanged );
        }
コード例 #7
0
        public void SetDiscoverdInfo()
        {
            #region graph
            /**
             *                  +--------+                              +--------+
             *      +---------->|ServiceA+-------+   *----------------->|ServiceB|
             *      |           |Running |       |   | Need ?           |Running |
             *      |           +---+----+       |   |                  +---+----+
             *      |               |            |   |                      |
             *      |               |            |   |                      |
             *      |               |            |   |                      |
             *  +---+-----+         |        +---+---*-+                    |
             *  |ServiceAx|     +---+-----+  |PluginA-2|                +---+-----+
             *  |Optional |     |PluginA-1|  |Optional |                |PluginB-1|
             *  +----+----+     |Optional |  +---------+                |Optional |
             *       |          +---------+                             +---------+
             *       |
             *  +----+-----+
             *  |PluginAx-1|
             *  |Running   |
             *  +----------+
             */
            #endregion

            DiscoveredInfo info = MockInfoFactory.CreateGraph001();
            info.FindPlugin( "PluginAx-1" ).AddServiceReference( info.FindService( "ServiceB" ), DependencyRequirement.Optional );

            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            engine.SetDiscoveredInfo( info );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();
            cl.Items.Add( "ServiceB", ConfigurationStatus.Running );
            cl.Items.Add( "ServiceA", ConfigurationStatus.Running );
            cl.Items.Add( "PluginAx-1", ConfigurationStatus.Running );

            IYodiiEngineResult res = engine.Start();

            res.CheckSuccess();

            info = MockInfoFactory.CreateGraph001();
            info.FindPlugin( "PluginAx-1" ).AddServiceReference( info.FindService( "ServiceB" ), DependencyRequirement.OptionalRecommended );

            res = engine.SetDiscoveredInfo( info );

            res.CheckSuccess();

            info = MockInfoFactory.CreateGraph001();
            info.FindPlugin( "PluginAx-1" ).AddServiceReference( info.FindService( "ServiceB" ), DependencyRequirement.Runnable );

            res = engine.SetDiscoveredInfo( info );

            res.CheckSuccess();

            info = MockInfoFactory.CreateGraph001();
            info.FindPlugin( "PluginAx-1" ).AddServiceReference( info.FindService( "ServiceB" ), DependencyRequirement.RunnableRecommended );

            res = engine.SetDiscoveredInfo( info );

            res.CheckSuccess();

            info = MockInfoFactory.CreateGraph001();
            info.FindPlugin( "PluginAx-1" ).AddServiceReference( info.FindService( "ServiceB" ), DependencyRequirement.Running );

            res = engine.SetDiscoveredInfo( info );

            res.CheckSuccess();
        }
コード例 #8
0
        public void InvalidCommonReferences2()
        {
            #region graph
            /*
            *                  +--------+                            +--------+
            *      +-----------|Service1+                            |Service2|---------------+                  +---------------+
            *      |           |Running |                            |Running |               |                  |AnotherBlocking+
            *      |           +---+----+                            +---+----+               |                  |    Runnable   |
            *      |               |                                      |                   |                  +-------+-------+
            *      |               |                                      |                   |                          |
            *      |               |                                      |                   |                          |
            *  +---+-----+         |                                      |                   |                          |
            *  |Plugin1  |     +---+-----+                            +---+-----+         +---+-----+                    |
            *  |Optional |     |Plugin2  |                            |Plugin3  |         |Plugin4  |            +-------+-------------+
            *  +----+----+     |Optional |                            |Optional |         |Optional |            |DisabledForBlocking  |
            *       |          +---------+                            +---------+         +-----+---+            |     Disabled        |
            *       |                   |                                 |                     |                +---------------------+
            *       |                   |                                 |                     |
            *       |                   |                                 |                     |
            *       |                   |                                 |                     |
            *       |                   |                                 |                     |
             *      |                   |                                 |                     |
            *       |                   |                                 |                     |
            *       |                   |           +--------+            |                     |
            *       |                   |           |Service3+            |                     |
            *       |       +-----------|-----------|Optional|------------|------+--------------+-----------+
            *       |       |           |           +---+----+            |      |              |           |
            *       |       |           |               |                 |      |              |           |
            *       |       |           |               |                 |      |              |           |
            *       |   +---+-------+   +-------->+-----+-----+           |  +---+-------+      |       +---+-------+
            *       |   |Service3.1 |             |Service3.2 |           |  |Service3.3 |      |       |Service3.4 |
            *       +-->|Optional   |             |Optional   |           +->|Optional   |      +------>|Optional   |
            *           +-----------+             +-----------+              +-----------+              +-----------+
            *           |           |             |           |              |           |              |           |
            *           |           |             |           |              |           |              |           |
            *           |           |             |           |              |           |              |           |
            *       +---+-----+ +---+-----+   +---+-----+ +---+-----+    +---+-----+ +---+-----+    +---+-----+ +---+-----+
            *       |Plugin5  | |Plugin6  |   |Plugin7  | |Plugin8  |    |Plugin9  | |Plugin10 |    |Plugin11 | |Plugin12 |
            *       |Optional | |Optional |   |Optional | |Optional |    |Optional | |Optional |    |Optional | |Optional |
            *       +---------+ +---------+   +---------+ +---------+    +---------+ +---------+    +---------+ +---------+
            *
            */
            #endregion
            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            var disco = MockInfoFactory.CreateGraph005b();
            var anotherBlocking = new ServiceInfo( "AnotherBlocking", disco.DefaultAssembly );
            var disabledForBlocking = new PluginInfo( "DisabledForBlocking", disco.DefaultAssembly );
            disabledForBlocking.Service = anotherBlocking;
            disco.ServiceInfos.Add( anotherBlocking );
            disco.PluginInfos.Add( disabledForBlocking );
            engine.SetDiscoveredInfo( disco );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();
            cl.Items.Add( "Service1", ConfigurationStatus.Running );
            cl.Items.Add( "Service2", ConfigurationStatus.Running );
            cl.Items.Add( "AnotherBlocking", ConfigurationStatus.Runnable );
            cl.Items.Add( "DisabledForBlocking", ConfigurationStatus.Disabled );

            engine.FullStaticResolutionOnly( res =>
               {
                   res.CheckAllBlockingServicesAre( "Service1 | Service2, AnotherBlocking" );
                   res.CheckNoBlockingPlugins();
               } );
        }
コード例 #9
0
        internal static YodiiEngine CreateInvalidRunnableRecommendedReference()
        {
            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            engine.SetDiscoveredInfo( MockInfoFactory.CreateGraph008() );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();
            cl.Items.Add( "Plugin1", ConfigurationStatus.Runnable );
            cl.Items.Add( "Plugin3", ConfigurationStatus.Disabled );
            cl.Items.Add( "Plugin4", ConfigurationStatus.Running );
            cl.Items.Add( "Plugin6", ConfigurationStatus.Disabled );
            cl.Items.Add( "Plugin8", ConfigurationStatus.Runnable );
            cl.Items.Add( "Plugin9", ConfigurationStatus.Disabled );
            cl.Items.Add( "Plugin10", ConfigurationStatus.Runnable );
            cl.Items.Add( "Plugin14", ConfigurationStatus.Disabled );
            cl.Items.Add( "Plugin17", ConfigurationStatus.Running );
            cl.Items.Add( "Plugin19", ConfigurationStatus.Runnable );
            cl.Items.Add( "Plugin20", ConfigurationStatus.Runnable );
            cl.Items.Add( "Plugin24", ConfigurationStatus.Disabled );

            cl.Items.Add( "Service2", ConfigurationStatus.Disabled );
            cl.Items.Add( "Service2.1", ConfigurationStatus.Running );
            cl.Items.Add( "Service1.1", ConfigurationStatus.Running );
            cl.Items.Add( "Service1.2", ConfigurationStatus.Runnable );
            cl.Items.Add( "Service1.1.2", ConfigurationStatus.Runnable );
            cl.Items.Add( "Service1.1.3", ConfigurationStatus.Runnable );

            return engine;
        }
コード例 #10
0
        public void Invalid004b()
        {
            #region graph
            /**
             *  +--------+
             *  |ServiceA+ ------+
             *  |Running |       |
             *  +---+----+       |
             *      |            |
             *      |            |
             *      |            |
             *      |         +---+------+
             *  +---+------+  |ServiceAx2|
             *  |ServiceAx1|  |Running   |
             *  |Running   |  +----------+
             *  +----------+      |
             *      |             |
             *      |             |
             *      |             |
             *      |          +---+-------+
             *  +---+-------+  |PluginAx2-1|
             *  |PluginAx1-1|  |Optional   |
             *  |Optional   |  +-----------+
             *  +-----------+
             */
            #endregion

            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            engine.SetDiscoveredInfo( MockInfoFactory.CreateGraph004() );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();
            cl.Items.Add( "ServiceA", ConfigurationStatus.Running );
            cl.Items.Add( "ServiceAx1", ConfigurationStatus.Running );
            cl.Items.Add( "ServiceAx2", ConfigurationStatus.Running );

            engine.FullStaticResolutionOnly( res =>
               {
                   res.CheckAllBlockingServicesAre( "ServiceA,ServiceAx1,ServiceAx2" );
               } );
        }
コード例 #11
0
        public void Invalid003MinusPluginA2()
        {
            #region graph
            /**
             *  +--------+
             *  |ServiceA|
             *  |Disabled|
             *  +---+----+
             *      |
             *      |
             *      |
             *      |
             *  +---+-----+
             *  |PluginA-1|
             *  |Running  |
             *  +---------+
             */
            #endregion

            DiscoveredInfo info = MockInfoFactory.CreateGraph003();

            info.PluginInfos.Remove( info.FindPlugin( "PluginA-2" ) );
            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            engine.SetDiscoveredInfo( info );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();
            cl.Items.Add( "ServiceA", ConfigurationStatus.Disabled );
            cl.Items.Add( "PluginA-1", ConfigurationStatus.Running );

            engine.FullStaticResolutionOnly( res =>
               {
                   res.CheckAllBlockingPluginsAre( "PluginA-1" );
               } );
        }
コード例 #12
0
        public void Invalid003e()
        {
            #region graph
            /**
             *  +--------+
             *  |ServiceA+ ------+
             *  |Disable |       |
             *  +---+----+       |
             *      |            |
             *      |            |
             *      |            |
             *      |        +---+---*-+
             *  +---+-----+  |PluginA-2|
             *  |PluginA-1|  |Optional |
             *  |Running  |  +---------+
             *  +---------+
             */
            #endregion

            DiscoveredInfo info = MockInfoFactory.CreateGraph003();
            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            engine.SetDiscoveredInfo( info );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();
            cl.Items.Add( "ServiceA", ConfigurationStatus.Disabled );
            cl.Items.Add( "PluginA-1", ConfigurationStatus.Running );

            engine.FullStaticResolutionOnly( res =>
                {
                    res.CheckAllBlockingPluginsAre( "PluginA-1" );
                    res.CheckWantedConfigSolvedStatusIs( "PluginA-1", SolvedConfigurationStatus.Running );
                } );
        }
コード例 #13
0
        internal static YodiiEngine CreateValidRunnableReferences()
        {
            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            engine.SetDiscoveredInfo( MockInfoFactory.CreateGraph006() );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();

            return engine;
        }
コード例 #14
0
        internal static YodiiEngine CreateValidOptionalReferences()
        {
            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            engine.SetDiscoveredInfo( MockInfoFactory.CreateGraph005e() );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();
            cl.Items.Add( "Service1", ConfigurationStatus.Running );

            return engine;
        }
コード例 #15
0
        internal static YodiiEngine CreateValid003f()
        {
            DiscoveredInfo info = MockInfoFactory.CreateGraph003();
            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            engine.SetDiscoveredInfo( info );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();
            cl.Items.Add( "ServiceA", ConfigurationStatus.Runnable );
            cl.Items.Add( "PluginA-1", ConfigurationStatus.Runnable );
            cl.Items.Add( "PluginA-2", ConfigurationStatus.Runnable );
            return engine;
        }
コード例 #16
0
        public void InvalidCommonReferences1()
        {
            #region graph
                /*
                *                  +--------+                            +--------+
                *      +-----------|Service1+                            |Service2|---------------+
                *      |           |Running |                            |Running |               |
                *      |           +---+----+                            +---+----+               |
                *      |               |                                      |                   |
                *      |               |                                      |                   |
                *      |               |                                      |                   |
                *  +---+-----+         |                                      |                   |
                *  |Plugin1  |     +---+-----+                            +---+-----+         +---+-----+
                *  |Optional |     |Plugin2  |                            |Plugin3  |         |Plugin4  |
                *  +----+----+     |Optional |                            |Optional |         |Optional |
                *       |          +---------+                            +---------+         +-----+---+
                *       |                   |                                 |                     |
                *       |                   |                                 |                     |
                *       |                   |                                 |                     |
                *       |                   |                                 |                     |
                *       |                   |                                 |                     |
                 *      |                   |                                 |                     |
                *       |                   |                                 |                     |
                *       |                   |           +--------+            |                     |
                *       |                   |           |Service3+            |                     |
                *       |       +-----------|-----------|Optional|------------|------+--------------+-----------+
                *       |       |           |           +---+----+            |      |              |           |
                *       |       |           |               |                 |      |              |           |
                *       |       |           |               |                 |      |              |           |
                *       |   +---+-------+   +-------->+-----+-----+           |  +---+-------+      |       +---+-------+
                *       |   |Service3.1 |             |Service3.2 |           |  |Service3.3 |      |       |Service3.4 |
                *       +-->|Optional   |             |Optional   |           +->|Optional   |<-----+       |Optional   |
                 *          +-----------+             +-----------+              +-----------+              +-----------+
                 *          |           |             |           |              |           |              |           |
                 *          |           |             |           |              |           |              |           |
                 *          |           |             |           |              |           |              |           |
                 *      +---+-----+ +---+-----+   +---+-----+ +---+-----+    +---+-----+ +---+-----+    +---+-----+ +---+-----+
                 *      |Plugin5  | |Plugin6  |   |Plugin7  | |Plugin8  |    |Plugin9  | |Plugin10 |    |Plugin11 | |Plugin12 |
                 *      |Optional | |Optional |   |Optional | |Optional |    |Optional | |Optional |    |Optional | |Optional |
                 *      +---------+ +---------+   +---------+ +---------+    +---------+ +---------+    +---------+ +---------+
                 *
                */
            #endregion
            DiscoveredInfo info = MockInfoFactory.CreateGraph005();
            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            engine.SetDiscoveredInfo( info );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();
            cl.Items.Add( "Service1", ConfigurationStatus.Running );
            cl.Items.Add( "Service2", ConfigurationStatus.Running );

            engine.FullStaticResolutionOnly( res =>
               {
                   res.CheckAllBlockingServicesAre( "Service1 | Service2" );
                   res.CheckNoBlockingPlugins();
               } );
        }
コード例 #17
0
        public void ConfigChanged()
        {
            /**
             *  +--------+
             *  |ServiceA+ ------+
             *  |        |       |
             *  +---+----+       |
             *      |            |
             *      |            |
             *      |            |
             *      |        +---+---*-+
             *  +---+-----+  |PluginA-2|
             *  |PluginA-1|  |         |
             *  |         |  +---------+
             *  +---------+
             */
            DiscoveredInfo info   = MockInfoFactory.CreateGraph003();
            YodiiEngine    engine = new YodiiEngine(new YodiiEngineHostMock());

            engine.SetDiscoveredInfo(info);
            engine.Start();
            ILiveServiceInfo sA = engine.LiveInfo.FindService("ServiceA");
            ILivePluginInfo  p1 = engine.LiveInfo.FindPlugin("PluginA-1");
            ILivePluginInfo  p2 = engine.LiveInfo.FindPlugin("PluginA-2");

            Assert.That(sA != null && p1 != null && p2 != null);

            Assert.That(p1.Capability.CanStart && p2.Capability.CanStart && sA.Capability.CanStart, Is.True);
            Assert.That(p1.Capability.CanStartWithFullStart && p2.Capability.CanStartWithFullStart && sA.Capability.CanStartWithFullStart, Is.True);
            Assert.That(p1.Capability.CanStartWithStartRecommended && p2.Capability.CanStartWithStartRecommended && sA.Capability.CanStartWithStartRecommended, Is.True);
            Assert.That(p1.Capability.CanStartWithStopOptionalAndRunnable && p2.Capability.CanStartWithStopOptionalAndRunnable && sA.Capability.CanStartWithStopOptionalAndRunnable, Is.True);
            Assert.That(p1.Capability.CanStartWithFullStop && p2.Capability.CanStartWithFullStop && sA.Capability.CanStartWithFullStop, Is.True);

            HashSet <string> propertyChanged = new HashSet <string>();

            p1.PropertyChanged += (s, e) =>
            {
                Assert.That(s, Is.SameAs(p1));
                Assert.That(propertyChanged.Add("p1." + e.PropertyName));
            };
            p1.Capability.PropertyChanged += (s, e) =>
            {
                Assert.That(s, Is.SameAs(p1.Capability));
                Assert.That(propertyChanged.Add("p1.Capablity." + e.PropertyName));
            };
            p2.PropertyChanged += (s, e) =>
            {
                Assert.That(s, Is.SameAs(p2));
                Assert.That(propertyChanged.Add("p2." + e.PropertyName));
            };
            p2.Capability.PropertyChanged += (s, e) =>
            {
                Assert.That(s, Is.SameAs(p2.Capability));
                Assert.That(propertyChanged.Add("p2.Capablity." + e.PropertyName));
            };
            sA.PropertyChanged += (s, e) =>
            {
                Assert.That(s, Is.SameAs(sA));
                Assert.That(propertyChanged.Add("sA." + e.PropertyName));
            };
            sA.Capability.PropertyChanged += (s, e) =>
            {
                Assert.That(s, Is.SameAs(sA.Capability));
                Assert.That(propertyChanged.Add("sA.Capablity." + e.PropertyName));
            };

            IConfigurationLayer config = engine.Configuration.Layers.Create("Default");

            config.Items.Add(p1.FullName, ConfigurationStatus.Disabled);

            Assert.That(p1.Capability.CanStart && p1.Capability.CanStartWithFullStart &&
                        p1.Capability.CanStartWithStartRecommended && p1.Capability.CanStartWithStopOptionalAndRunnable &&
                        p1.Capability.CanStartWithFullStop, Is.False);

            Assert.That(p2.Capability.CanStart && sA.Capability.CanStart, Is.True);
            Assert.That(p2.Capability.CanStartWithFullStart && sA.Capability.CanStartWithFullStart, Is.True);
            Assert.That(p2.Capability.CanStartWithStartRecommended && sA.Capability.CanStartWithStartRecommended, Is.True);
            Assert.That(p2.Capability.CanStartWithStopOptionalAndRunnable && sA.Capability.CanStartWithStopOptionalAndRunnable, Is.True);
            Assert.That(p2.Capability.CanStartWithFullStop && sA.Capability.CanStartWithFullStop, Is.True);


            CollectionAssert.AreEquivalent(new string[] {
                "p1.Capablity.CanStart",
                "p1.Capablity.CanStartWithFullStart",
                "p1.Capablity.CanStartWithStartRecommended",
                "p1.Capablity.CanStartWithStopOptionalAndRunnable",
                "p1.Capablity.CanStartWithFullStop",
                "p1.DisabledReason",
                "p1.RunningStatus",
                "p1.ConfigOriginalStatus",
                "p1.WantedConfigSolvedStatus",
                "p1.FinalConfigSolvedStatus"
            }, propertyChanged);
            propertyChanged.Clear();

            config.Items.Add(p1.FullName, ConfigurationStatus.Optional);

            CollectionAssert.AreEquivalent(new string[] {
                "p1.Capablity.CanStart",
                "p1.Capablity.CanStartWithFullStart",
                "p1.Capablity.CanStartWithStartRecommended",
                "p1.Capablity.CanStartWithStopOptionalAndRunnable",
                "p1.Capablity.CanStartWithFullStop",
                "p1.DisabledReason",
                "p1.RunningStatus",
                "p1.ConfigOriginalStatus",
                "p1.WantedConfigSolvedStatus",
                "p1.FinalConfigSolvedStatus"
            }, propertyChanged);
        }
コード例 #18
0
        public void Invalid001MinusPluginAx()
        {
            #region graph
            /**
             *                  +--------+                              +--------+
             *      +---------->|ServiceA+-------+   *----------------->|ServiceB|
             *      |           |Runnable|       |   | Need Running     |Runnable|
             *      |           +---+----+       |   |                  +---+----+
             *      |               |            |   |                      |
             *      |               |            |   |                      |
             *      |               |            |   |                      |
             *  +---+-----+         |        +---+---*-+                    |
             *  |ServiceAx|     +---+-----+  |PluginA-2|                +---+-----+
             *  |Runnable |     |PluginA-1|  |Runnable |                |PluginB-1|
             *  +----+----+     |Runnable |  +---------+                |Runnable |
             *                  +---------+                             +---------+
             */
            #endregion

            DiscoveredInfo info = MockInfoFactory.CreateGraph001();
            info.PluginInfos.Remove( info.FindPlugin( "PluginAx-1" ) );

            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            engine.SetDiscoveredInfo( info );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();
            cl.Items.Add( "ServiceA", ConfigurationStatus.Runnable );
            cl.Items.Add( "ServiceB", ConfigurationStatus.Runnable );
            cl.Items.Add( "ServiceAx", ConfigurationStatus.Runnable );
            cl.Items.Add( "PluginA-1", ConfigurationStatus.Runnable );
            cl.Items.Add( "PluginA-2", ConfigurationStatus.Runnable );
            cl.Items.Add( "PluginB-1", ConfigurationStatus.Runnable );

            engine.FullStaticResolutionOnly( res =>
                {

                    res.CheckAllBlockingServicesAre( "ServiceAx" );
                    res.CheckNoBlockingPlugins();
                    res.CheckWantedConfigSolvedStatusIs( "PluginA-2", SolvedConfigurationStatus.Runnable );
                } );
        }