Exemplo n.º 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();
        }
Exemplo n.º 2
0
        public static void FullStart(this YodiiEngine @this, Action <YodiiEngine, IYodiiEngineResult> tests, [CallerMemberName] string callerName = null)
        {
            IActivityMonitor   m = TestHelper.ConsoleMonitor;
            IYodiiEngineResult result;

            using (m.OpenInfo().Send("FullStart for {0}.", callerName))
            {
                using (m.OpenInfo().Send("FullStart()."))
                {
                    result = @this.Start(false, false);
                    result.Trace(m);
                    tests(@this, result);
                    @this.Stop();
                }
                using (m.OpenInfo().Send("FullStart( revertServices )."))
                {
                    result = @this.Start(true, false);
                    result.Trace(m);
                    tests(@this, result);
                    @this.Stop();
                }
                using (m.OpenInfo().Send("FullStart( revertPlugins )."))
                {
                    result = @this.Start(false, true);
                    result.Trace(m);
                    tests(@this, result);
                    @this.Stop();
                }
                using (m.OpenInfo().Send("FullStart( revertServices, revertPlugins )."))
                {
                    result = @this.Start(true, true);
                    result.Trace(m);
                    tests(@this, result);
                    @this.Stop();
                }
            }
        }
Exemplo n.º 3
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();
        }