Пример #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();
        }