Ejemplo n.º 1
0
        public void FindDependenciesLogHandlesTypeExpectedReturnsFindDependencyService()
        {
            var esb    = new FindDependencies();
            var result = esb.HandlesType();

            Assert.AreEqual("FindDependencyService", result);
        }
Ejemplo n.º 2
0
        public void FindDependenciesConstructor()
        {
            var esb = new FindDependencies();

            Assert.IsNotNull(esb);
            Assert.IsInstanceOfType(esb, typeof(IEsbManagementEndpoint));
        }
Ejemplo n.º 3
0
            /// <summary>
            /// Создает службу для инициализации общих объектов.
            /// </summary>
            public static IInitializationFactory Common(IDependencyContainer valueContainer)
            {
                var find   = FindDependencies.InFieldsPropertiesAndMethods(valueContainer);
                var inject = InsertDependencies.IntoFieldsPropertiesAndMethods(valueContainer);
                var init   = CreateBuildQueue(new InitStrategy());

                return(CreateInitializationFactory(find, inject, init));
            }
Ejemplo n.º 4
0
            /// <summary>
            /// Создает службу для инициализации объектов: <see cref="UniMvp.Interfaces.IService"/>.
            /// </summary>
            /// <param name="factory">Фабрика по созданию объектов и настройке зависимостей.</param>
            /// <param name="valueContainer"> DI контейнер для кэширования и поставки значений. </param>
            /// <returns></returns>
            public static IInitializationFactory Services(IDependencyFactory factory, IDependencyContainer valueContainer)
            {
                var find   = FindDependencies.InServices(factory, valueContainer);
                var inject = InsertDependencies.IntoFieldsPropertiesAndMethods(valueContainer);
                var init   = CreateBuildQueue(new InitCompositeStrategy(factory));

                return(CreateInitializationFactory(find, inject, init));
            }
Ejemplo n.º 5
0
        public void FindDependencies_Execute_NonGuidResourceId_Exception()
        {
            //------------Setup for test--------------------------
            var findDependencies = new FindDependencies();

            //------------Execute Test---------------------------
            findDependencies.Execute(new Dictionary <string, StringBuilder> {
                { "ResourceId", new StringBuilder("bob") }
            }, new Mock <IWorkspace>().Object);
            //------------Assert Results-------------------------
        }
Ejemplo n.º 6
0
        public void GetAuthorizationContextForService_ShouldReturnContext()
        {
            //------------Setup for test--------------------------
            var findDependencies = new FindDependencies();

            //------------Execute Test---------------------------
            var resId = findDependencies.GetAuthorizationContextForService();

            //------------Assert Results-------------------------
            Assert.AreEqual(AuthorizationContext.Any, resId);
        }
Ejemplo n.º 7
0
        public void GetResourceID_ShouldReturnEmptyGuid()
        {
            //------------Setup for test--------------------------
            var findDependencies = new FindDependencies();

            //------------Execute Test---------------------------
            var resId = findDependencies.GetResourceID(new Dictionary <string, StringBuilder>());

            //------------Assert Results-------------------------
            Assert.AreEqual(Guid.Empty, resId);
        }
Ejemplo n.º 8
0
        public void FindDependencies_Execute_ResourceIdKeyNotPresent_Exception()
        {
            //------------Setup for test--------------------------
            var findDependencies = new FindDependencies();

            //------------Execute Test---------------------------
            findDependencies.Execute(new Dictionary <string, StringBuilder> {
                { "Resource", new StringBuilder(Guid.NewGuid().ToString()) }
            }, new Mock <IWorkspace>().Object);
            //------------Assert Results-------------------------
        }
Ejemplo n.º 9
0
        public void FetchCurrentServerLogCreateServiceEntryExpectedReturnsDynamicService()
        {
            var esb    = new FindDependencies();
            var result = esb.CreateServiceEntry();

            Assert.AreEqual(esb.HandlesType(), result.Name);
            Assert.AreEqual(@"<DataList><ResourceId ColumnIODirection=""Input""/><GetDependsOnMe ColumnIODirection=""Input""/><Dev2System.ManagmentServicePayload ColumnIODirection=""Both""></Dev2System.ManagmentServicePayload></DataList>", result.DataListSpecification.ToString());
            Assert.AreEqual(1, result.Actions.Count);

            var serviceAction = result.Actions[0];

            Assert.AreEqual(esb.HandlesType(), serviceAction.Name);
            Assert.AreEqual(enActionType.InvokeManagementDynamicService, serviceAction.ActionType);
            Assert.AreEqual(esb.HandlesType(), serviceAction.SourceMethod);
        }
Ejemplo n.º 10
0
        public void FindDependencies_Execute_GetDependsOnMe_WhenCircular_ShouldReturnDependantsRecursive()
        {
            //------------Setup for test--------------------------
            var findDependencies    = new FindDependencies();
            var mockResourceCatalog = new Mock <IResourceCatalog>();
            var parentResourceId    = Guid.NewGuid();
            var parentDepId         = Guid.NewGuid();
            var parentDepDepId      = Guid.NewGuid();

            mockResourceCatalog.Setup(catalog => catalog.GetDependants(It.IsAny <Guid>(), parentResourceId)).Returns(new List <Guid> {
                parentDepId
            });
            mockResourceCatalog.Setup(catalog => catalog.GetDependants(It.IsAny <Guid>(), parentDepId)).Returns(new List <Guid> {
                parentDepDepId
            });
            mockResourceCatalog.Setup(catalog => catalog.GetDependants(It.IsAny <Guid>(), parentDepDepId)).Returns(new List <Guid> {
                parentResourceId
            });
            var mockParentResource = new Mock <IResource>();

            mockParentResource.Setup(resource => resource.ResourceID).Returns(parentResourceId);
            mockResourceCatalog.Setup(catalog => catalog.GetResource(It.IsAny <Guid>(), parentResourceId)).Returns(mockParentResource.Object);
            var mockParentResourceDep = new Mock <IResource>();

            mockParentResourceDep.Setup(resource => resource.ResourceID).Returns(parentDepId);
            mockResourceCatalog.Setup(catalog => catalog.GetResource(It.IsAny <Guid>(), parentDepId)).Returns(mockParentResourceDep.Object);
            var mockParentResourceDepDep = new Mock <IResource>();

            mockParentResourceDepDep.Setup(resource => resource.ResourceID).Returns(parentDepDepId);
            mockResourceCatalog.Setup(catalog => catalog.GetResource(It.IsAny <Guid>(), parentDepDepId)).Returns(mockParentResourceDepDep.Object);
            findDependencies.ResourceCatalog = mockResourceCatalog.Object;
            //------------Execute Test---------------------------
            var msg = findDependencies.Execute(new Dictionary <string, StringBuilder> {
                { "ResourceId", new StringBuilder(parentResourceId.ToString()) }, { "GetDependsOnMe", new StringBuilder("true") }
            }, new Mock <IWorkspace>().Object);
            //------------Assert Results-------------------------
            var execMsg = ConvertToMsg(msg);

            Assert.IsNotNull(execMsg);
            var xe = execMsg.Message.ToXElement();

            Assert.IsNotNull(xe);
            var graphElement = xe.AncestorsAndSelf("graph").FirstOrDefault();

            Assert.IsNotNull(graphElement);
            var nodeElements = graphElement.Elements("node");

            Assert.IsNotNull(nodeElements);
            var nodes = nodeElements as IList <XElement> ?? nodeElements.ToList();

            Assert.AreEqual(3, nodes.Count);

            var node1 = nodes[0];

            Assert.IsNotNull(node1);
            Assert.AreEqual(parentResourceId.ToString(), node1.Attribute("id").Value);
            var node1Dep = node1.Elements().FirstOrDefault();

            Assert.IsNotNull(node1Dep);
            Assert.AreEqual(parentDepId.ToString(), node1Dep.Attribute("id").Value);

            var node2 = nodes[1];

            Assert.IsNotNull(node2);
            Assert.AreEqual(parentDepId.ToString(), node2.Attribute("id").Value);
            var node2Dep = node2.Elements().FirstOrDefault();

            Assert.IsNotNull(node2Dep);
            Assert.AreEqual(parentDepDepId.ToString(), node2Dep.Attribute("id").Value);

            var node3 = nodes[2];

            Assert.IsNotNull(node3);
            Assert.AreEqual(parentDepDepId.ToString(), node3.Attribute("id").Value);
            var node3Dep = node3.Elements().FirstOrDefault();

            Assert.IsNotNull(node3Dep);
            Assert.AreEqual(parentResourceId.ToString(), node3Dep.Attribute("id").Value);
        }
Ejemplo n.º 11
0
        private void ShowDependencies(ResultRow[] dependencies)
        {
            _expandFiles = EditorGUILayout.Foldout(_expandFiles, _fileMode ? FileDependencies : SceneDependencies);
            if (!_fileMode)
            {
                if (_data.Target.Scene.IsValid() && !_data.Target.Scene.isLoaded)
                {
                    return;
                }
            }
            if (_expandFiles)
            {
                if (dependencies.Any())
                {
                    foreach (var dependency in dependencies)
                    {
                        DrawRow(dependency);
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("No file dependencies found.");
                }
            }
            EditorGUILayout.Space();

            var fileDep = _data as FileDependency;

            if (fileDep == null)
            {
                return;
            }

            if (fileDep.ScenePaths == null)
            {
                if (GUILayout.Button("Search Scenes"))
                {
                    fileDep.ScenePaths = FindDependencies.ScenesThatContain(_data.Target.Target).Select(p => new FileDependency.Pair {
                        Path = p, NicifiedPath = p.Replace("Assets/", string.Empty)
                    }).ToArray();
                }
                return;
            }

            _expandScenes = EditorGUILayout.Foldout(_expandScenes, "Scenes:");

            if (!_expandScenes)
            {
                return;
            }

            if (!fileDep.ScenePaths.Any())
            {
                EditorGUILayout.LabelField("No scene dependencies found.");
                return;
            }

            for (int i = 0; i < fileDep.ScenePaths.Length; i++)
            {
                var p = fileDep.ScenePaths[i];
                using (new EditorGUILayout.HorizontalScope())
                {
                    SceneIcon.text = p.NicifiedPath;

                    if (GUILayout.Button(SceneIcon, EditorStyles.label, GUILayout.Height(16f)))
                    {
                        Selection.activeObject = AssetDatabase.LoadAssetAtPath <SceneAsset>(p.Path);
                    }

                    if (!GUILayout.Button("Open scene & search", GUILayout.Width(200f)))
                    {
                        continue;
                    }

                    var s = SceneManager.GetSceneByPath(p.Path);
                    if (s.isLoaded)
                    {
                        InitSceneWindow(_data.Target.Target, p.Path);
                    }
                    else
                    {
                        if (s.isDirty && !EditorUtility.DisplayDialog("Unsaved Scene", "You have unsaved shanges in scene", "Discard scene", "Cancel search"))
                        {
                            return;
                        }

                        EditorSceneManager.OpenScene(p.Path);
                        EditorSceneExtensions.FireOnSceneOpenAndForget(() => InitSceneWindow(_data.Target.Target, p.Path));
                    }
                }
            }
        }