Beispiel #1
0
        public void VisitTypeDeclaration_AControllerNoChildren_PushesAndPops()
        {
            TypeDeclaration type = new TypeDeclaration(Modifiers.Public | Modifiers.Partial, new List <AttributeSection>());

            type.Name = "SomeRandomController";

            using (_mocks.Unordered())
            {
                _treeService.PushNode(new ControllerTreeNode("SomeRandomController", "SomeNamespace"));
                _treeService.PopNode();
            }

            _mocks.ReplayAll();
            _visitor.VisitTypeDeclaration(type, null);
            _mocks.VerifyAll();
        }
Beispiel #2
0
        public void AddViewSource(string path)
        {
            string   viewName = Path.GetFileNameWithoutExtension(path);
            TreeNode node     = null;

            foreach (string part in BreakPath(path))
            {
                string controllerName = part + "Controller";
                node = _treeService.FindNode(controllerName);
                if (node == null)
                {
                    string viewComponentName = part + "Component";
                    node = _treeService.FindNode(viewComponentName);
                    if (node == null)
                    {
                        node = _treeService.FindNode(part);
                        if (node == null)
                        {
                            continue;
                        }
                    }
                }
                _treeService.PushNode(node);
            }
            _treeService.PopToRoot();
            if (node == null)
            {
                _logger.LogInfo("Unable to map view: {0}", path);
                return;
            }

            node.AddChild(new ViewTreeNode(viewName));
        }
Beispiel #3
0
        public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
        {
            if (!IsController(typeDeclaration))
            {
                return(null);
            }

            var area          = GetArea(typeDeclaration);
            var typeNamespace = GetNamespace(typeDeclaration);

            if (!String.IsNullOrEmpty(area))
            {
                var areas = area.Split('/');

                for (var i = 0; i < areas.Length; i++)
                {
                    var areaNode = treeService.FindNode(areas[i]) ?? new AreaTreeNode(areas[i]);

                    treeService.PushNode(areaNode);
                }
            }

            var node = IsWizardController(typeDeclaration)
                ? new WizardControllerTreeNode(typeDeclaration.Name, typeNamespace, new string[0])
                : new ControllerTreeNode(typeDeclaration.Name, typeNamespace);

            node.RestRoutesDescriptor = GetRestRoutesDescriptor(typeDeclaration);

            treeService.PushNode(node);

            var r = base.VisitTypeDeclaration(typeDeclaration, data);

            if (!String.IsNullOrEmpty(area))
            {
                var areas = area.Split('/');

                for (var i = 0; i < areas.Length; i++)
                {
                    treeService.PopNode();
                }
            }

            treeService.PopNode();

            return(r);
        }
Beispiel #4
0
        public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
        {
            if (!IsController(typeDeclaration))
            {
                return(null);
            }

            string area          = GetArea(typeDeclaration);
            string typeNamespace = GetNamespace(typeDeclaration);

            if (!String.IsNullOrEmpty(area))
            {
                string[] areas = area.Split('/');
                for (int i = 0; i < areas.Length; i++)
                {
                    TreeNode areaNode = _treeService.FindNode(areas[i]);
                    if (areaNode == null)
                    {
                        areaNode = new AreaTreeNode(areas[i]);
                    }
                    _treeService.PushNode(areaNode);
                }
            }

            ControllerTreeNode node = IsWizardController(typeDeclaration)
                                                        ? new WizardControllerTreeNode(typeDeclaration.Name, typeNamespace, new string[0])
                                                        : new ControllerTreeNode(typeDeclaration.Name, typeNamespace);

            _treeService.PushNode(node);

            object r = base.VisitTypeDeclaration(typeDeclaration, data);

            if (!String.IsNullOrEmpty(area))
            {
                string[] areas = area.Split('/');
                for (int i = 0; i < areas.Length; i++)
                {
                    _treeService.PopNode();
                }
            }
            _treeService.PopNode();

            return(r);
        }
Beispiel #5
0
        public void AddViewSource_ViewForValidTopLevelController_AddsViewNode()
        {
            var node = new ControllerTreeNode("HomeController", "SomeNamespace");
            var root = new AreaTreeNode("Root");

            root.AddChild(node);

            using (mocks.Unordered())
            {
                Expect.Call(treeService.FindNode("HomeController")).Return(node);
                treeService.PushNode(node);
                treeService.PopToRoot();
            }

            mocks.ReplayAll();
            mapper.AddViewSource(@"Projects\Eleutian.Web.Site\Views\Home\Index.brail");
            mocks.VerifyAll();

            AssertHasViewNode(node);
        }
Beispiel #6
0
        public void VisitTypeDeclaration_AViewComponentNoChildren_PushesAndPops()
        {
            var type = new TypeDeclaration(Modifiers.Public | Modifiers.Partial, new List <AttributeSection>())
            {
                Name = "SomeRandomComponent"
            };

            using (mocks.Unordered())
            {
                treeService.PushNode(new ViewComponentTreeNode("SomeRandomComponent", "SomeNamespace"));
                treeService.PopNode();
            }

            mocks.ReplayAll();
            visitor.VisitTypeDeclaration(type, null);
            mocks.VerifyAll();
        }
Beispiel #7
0
        public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
        {
            if (!IsViewComponent(typeDeclaration))
            {
                return(null);
            }

            var typeNamespace = GetNamespace(typeDeclaration);
            var node          = new ViewComponentTreeNode(typeDeclaration.Name, typeNamespace);

            treeService.PushNode(node);

            var r = base.VisitTypeDeclaration(typeDeclaration, data);

            treeService.PopNode();

            return(r);
        }