Esempio n. 1
0
        private void UpdateServicePropertyNameWithTextbox(System.Windows.Controls.TextBox textBox)
        {
            if (LiveServiceInfo == null)
            {
                return;
            }
            LabServiceInfo liveService = textBox.DataContext as LabServiceInfo;

            if (liveService.ServiceInfo.ServiceFullName == textBox.Text)
            {
                return;
            }
            if (String.IsNullOrWhiteSpace(textBox.Text))
            {
                return;
            }

            DetailedOperationResult r = ServiceInfoManager.RenameService(liveService.ServiceInfo, textBox.Text);

            if (!r)
            {
                textBox.Text = liveService.ServiceInfo.ServiceFullName;
                MessageBox.Show(String.Format("Couldn't change service name.\n{0}", r.Reason), "Couldn't change service name", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK);
            }
        }
Esempio n. 2
0
        YodiiGraphVertex CreateServiceVertex(LabServiceInfo liveService)
        {
            YodiiGraphVertex serviceVertex = new YodiiGraphVertex(this, liveService)
            {
                ID = currentId++
            };

            this.AddVertex(serviceVertex);
            liveService.ServiceInfo.PropertyChanged += ServiceInfo_PropertyChanged;


            if (liveService.ServiceInfo.Generalization != null)
            {
                YodiiGraphVertex generalizationVertex = FindOrCreateServiceVertex(liveService.ServiceInfo.Generalization);

                YodiiGraphEdge edge = new YodiiGraphEdge(serviceVertex, generalizationVertex, YodiiGraphEdgeType.Specialization)
                {
                    ID = currentId++
                };

                this.AddEdge(edge);
            }


            return(serviceVertex);
        }
Esempio n. 3
0
        private void LookupAndBindLiveServiceInfoToService(ILiveServiceInfo info)
        {
            Debug.Assert(info.ServiceInfo is ServiceInfo);

            LabServiceInfo labService = _labServiceInfos.GetByKey((ServiceInfo)info.ServiceInfo);

            labService.LiveServiceInfo = info;
        }
Esempio n. 4
0
        YodiiGraphVertex FindOrCreateServiceVertex(LabServiceInfo service)
        {
            YodiiGraphVertex serviceVertex = this.Vertices.FirstOrDefault(v => v.LabServiceInfo == service);

            if (serviceVertex == null)
            {
                serviceVertex = CreateServiceVertex(service);
            }
            return(serviceVertex);
        }
Esempio n. 5
0
        void RemoveServiceVertex(LabServiceInfo service)
        {
            YodiiGraphVertex toRemove = Vertices.Where(v => v.LabServiceInfo == service).FirstOrDefault();

            service.ServiceInfo.PropertyChanged -= ServiceInfo_PropertyChanged;

            if (toRemove != null)
            {
                RemoveVertex(toRemove);
            }
        }
Esempio n. 6
0
        private void LookupAndUnbindLiveServiceInfoFromService(ILiveServiceInfo info)
        {
            Debug.Assert(info.ServiceInfo is ServiceInfo);

            bool           exists;
            LabServiceInfo labService = _labServiceInfos.GetByKey((ServiceInfo)info.ServiceInfo, out exists);

            if (exists)
            {
                labService.LiveServiceInfo = null;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Creates a new service vertex.
        /// </summary>
        /// <param name="parentGraph"></param>
        /// <param name="service"></param>
        internal YodiiGraphVertex(YodiiGraph parentGraph, LabServiceInfo service)
            : this()
        {
            Debug.Assert(parentGraph != null);
            Debug.Assert(service != null);

            _isPlugin    = false;
            _liveService = service;
            _parentGraph = parentGraph;

            _liveService.ServiceInfo.PropertyChanged += StaticInfo_PropertyChanged;
            _liveService.PropertyChanged             += _labService_PropertyChanged;
        }
Esempio n. 8
0
        /// <summary>
        /// Creates a lab wrapper item around an existing mock service, and adds it to our collection.
        /// </summary>
        /// <param name="s">Existing mock service</param>
        private void CreateLabService(ServiceInfo s)
        {
            LabServiceInfo newServiceInfo;

            if (s.Generalization != null)
            {
                LabServiceInfo generalizationLiveInfo = _labServiceInfos.GetByKey((ServiceInfo)s.Generalization);
                newServiceInfo = new LabServiceInfo(s);   // TODO: Running requirement
            }
            else
            {
                newServiceInfo = new LabServiceInfo(s);
            }
            _labServiceInfos.Add(newServiceInfo);
        }
Esempio n. 9
0
        /// <summary>
        /// Creates a lab wrapper item around an existing mock plugin, and adds it to our collection.
        /// </summary>
        /// <param name="p">Existing mock plugin</param>
        private void CreateLabPlugin(PluginInfo p)
        {
            LabPluginInfo lp;

            if (p.Service != null)
            {
                p.Service.InternalImplementations.Add(p);
                LabServiceInfo liveService = _labServiceInfos.GetByKey(p.Service);
                lp = new LabPluginInfo(p);
            }
            else
            {
                lp = new LabPluginInfo(p);
            }

            _labPluginInfos.Add(lp);
        }
Esempio n. 10
0
        YodiiGraphVertex FindOrCreateServiceVertex(IServiceInfo serviceInfo)
        {
            LabServiceInfo info = _serviceInfos.Where(s => s.ServiceInfo == serviceInfo).First();

            return(FindOrCreateServiceVertex(info));
        }
Esempio n. 11
0
        internal static MainWindowViewModel CreateViewModelWithGraph001()
        {
            /** Imagine a graph like this:
             *                 +RUNNING-+                              +--------+
             *     +---------->|ServiceA+-------+   *----------------->|ServiceB|
             *     |           +---+----+       |   | Need Running     +---+----+
             *     |               |            |   |                      |
             *     |               |            |   |                      |
             *     |               |            |   |                      |
             *     |               |            |   |                      |
             * +---+-----+     +---+-----+  +RUNNING*-+                +---+-----+
             * |ServiceAx|     |PluginA-1|  |PluginA-2|                |PluginB-1|
             * +----+----+     +---------+  +---------+                +---------+
             *      |
             *      |
             * +----+-----+    +----------------------+
             * |PluginAx-1|    |Plugin.Without.Service|
             * +----------+    +----------------------+
             */
            MainWindowViewModel vm = new MainWindowViewModel();

            Assert.That(vm.LabState.Engine.IsRunning, Is.False);

            // Services
            IServiceInfo serviceA = vm.CreateNewService("ServiceA");

            Assert.That(vm.ServiceInfos.Contains(serviceA));
            Assert.That(vm.ServiceInfos.Count == 1);
            Assert.That(vm.LabState.LabServiceInfos.Count == 1);
            Assert.That(vm.LabState.LabServiceInfos.Where(x => x.ServiceInfo == serviceA).Count() == 1);

            LabServiceInfo labServiceA = vm.LabState.LabServiceInfos.Where(x => x.ServiceInfo == serviceA).First();

            IServiceInfo serviceB = vm.CreateNewService("ServiceB");

            Assert.That(vm.ServiceInfos.Contains(serviceB));
            Assert.That(vm.ServiceInfos.Count == 2);
            Assert.That(vm.LabState.LabServiceInfos.Count == 2);
            Assert.That(vm.LabState.LabServiceInfos.Where(x => x.ServiceInfo == serviceB).Count() == 1);

            IServiceInfo serviceAx = vm.CreateNewService("ServiceAx", serviceA);

            Assert.That(vm.ServiceInfos.Contains(serviceAx));
            Assert.That(vm.ServiceInfos.Count == 3);
            Assert.That(vm.LabState.LabServiceInfos.Count == 3);
            Assert.That(vm.LabState.LabServiceInfos.Where(x => x.ServiceInfo == serviceAx).Count() == 1);

            LabServiceInfo labServiceAx = vm.LabState.LabServiceInfos.Where(x => x.ServiceInfo == serviceAx).First();

            Assert.That(labServiceAx.ServiceInfo.Generalization == labServiceA.ServiceInfo);

            Assert.That(serviceA.Generalization == null);
            Assert.That(serviceB.Generalization == null);
            Assert.That(serviceAx.Generalization == serviceA);

            // Plugins
            IPluginInfo pluginWithoutService = vm.CreateNewPlugin("Plugin.Without.Service");

            IPluginInfo pluginA1 = vm.CreateNewPlugin("Plugin.A1", serviceA);

            IPluginInfo pluginA2 = vm.CreateNewPlugin("Plugin.A2", serviceA);

            IPluginInfo pluginAx1 = vm.CreateNewPlugin("Plugin.Ax1", serviceAx);

            IPluginInfo pluginB1 = vm.CreateNewPlugin("Plugin.B1", serviceB);

            vm.SetPluginDependency(pluginA2, serviceB, DependencyRequirement.Running);

            Assert.That(pluginA2.ServiceReferences.Count == 1);
            Assert.That(pluginA2.ServiceReferences[0].Reference == serviceB);
            Assert.That(pluginA2.ServiceReferences[0].Requirement == DependencyRequirement.Running);

            Assert.That(serviceA.Implementations.Count == 2);
            Assert.That(serviceB.Implementations.Count == 1);
            Assert.That(serviceAx.Implementations.Count == 1);

            // Set configuration
            var cLayer1 = vm.LabState.Engine.Configuration.Layers.Create("Test layer");
            var result  = cLayer1.Items.Add(serviceA.ServiceFullName, ConfigurationStatus.Running, "Test reason");

            Assert.That(result.Success);

            var cLayer2 = vm.LabState.Engine.Configuration.Layers.Create("Test layer 2");

            result = cLayer2.Items.Add(pluginA2.PluginFullName, ConfigurationStatus.Running, "Test reason 2");
            Assert.That(result.Success);

            // Testing tests
            foreach (var si in vm.ServiceInfos)
            {
                EquivalenceExtensions.AssertServiceEquivalence(si, si, true);
            }
            foreach (var pi in vm.PluginInfos)
            {
                EquivalenceExtensions.AssertPluginEquivalence(pi, pi, true);
            }

            EquivalenceExtensions.AssertManagerEquivalence(vm.LabState.Engine.Configuration, vm.LabState.Engine.Configuration);

            return(vm);
        }