Ejemplo n.º 1
0
        public void VisitActionNode_NoParameters_CreatesMethod()
        {
            var node = new ActionTreeNode("Index");

            controller.AddChild(node);

            generator.Visit(controller);

            CodeDomAssert.AssertHasField(source.Ccu.Namespaces[0].Types[0], "_services");
            CodeDomAssert.AssertHasMethod(source.Ccu.Namespaces[0].Types[0], "Index");
        }
Ejemplo n.º 2
0
        public void VisitControllerNode_Always_CreatesType()
        {
            ControllerTreeNode node = new ControllerTreeNode("HomeController", "ControllerNamespace");

            _mocks.ReplayAll();
            _generator.Visit(node);
            _mocks.VerifyAll();

            CodeDomAssert.AssertHasProperty(_source.Ccu.Namespaces[0].Types[0], "MyActions");
            CodeDomAssert.AssertHasProperty(_source.Ccu.Namespaces[0].Types[0], "MyViews");
            CodeDomAssert.AssertHasProperty(_source.Ccu.Namespaces[0].Types[0], "MyRoutes");
            CodeDomAssert.AssertHasMethod(_source.Ccu.Namespaces[0].Types[0], "PerformGeneratedInitialize");
        }
Ejemplo n.º 3
0
        public void VisitActionNode_NoParameters_CreatesMethod()
        {
            ActionTreeNode node = new ActionTreeNode("Index");

            _controller.AddChild(node);

            _mocks.ReplayAll();
            _generator.Visit(_controller);
            _mocks.VerifyAll();

            CodeDomAssert.AssertHasField(_source.Ccu.Namespaces[0].Types[0], "_services");
            CodeDomAssert.AssertHasMethod(_source.Ccu.Namespaces[0].Types[0], "Index");
        }
Ejemplo n.º 4
0
        public void VisitRouteNode_OneParameters_CreatesMethod()
        {
            var node           = new StaticRouteTreeNode("AuthenticateLogIn", "login/authenticate/<userName:string>/<password:string>");
            var actionTreeNode = new ActionTreeNode("action");

            actionTreeNode.AddChild(node);
            controller.AddChild(actionTreeNode);
            node.AddChild(new ParameterTreeNode("userName", "System.String"));

            generator.Visit(controller);

            CodeDomAssert.AssertHasField(source.Ccu.Namespaces[0].Types[0], "_services");
            CodeDomAssert.AssertHasMethod(source.Ccu.Namespaces[0].Types[2], "AuthenticateLogIn");
        }
Ejemplo n.º 5
0
        public void VisitRouteNode_NoParameters_CreatesMethod()
        {
            RouteTreeNode  node           = new StaticRouteTreeNode("Index", "index");
            ActionTreeNode actionTreeNode = new ActionTreeNode("action");

            actionTreeNode.AddChild(node);
            controller.AddChild(actionTreeNode);

            mocks.ReplayAll();
            generator.Visit(controller);
            mocks.VerifyAll();

            CodeDomAssert.AssertHasField(source.Ccu.Namespaces[0].Types[0], "_services");
            CodeDomAssert.AssertHasMethod(source.Ccu.Namespaces[0].Types[2], "Index");
        }
Ejemplo n.º 6
0
        public void VisitActionNode_OneParameters_CreatesMethod()
        {
            ActionTreeNode node = new ActionTreeNode("Index");

            _controller.AddChild(node);
            node.AddChild(new ParameterTreeNode("id", typeof(Int32)));

            using (_mocks.Unordered())
            {
            }

            _mocks.ReplayAll();
            _generator.Visit(_controller);
            _mocks.VerifyAll();

            CodeDomAssert.AssertHasField(_source.Ccu.Namespaces[0].Types[0], "_services");
            CodeDomAssert.AssertHasMethod(_source.Ccu.Namespaces[0].Types[0], "Index");
        }
Ejemplo n.º 7
0
        public void VisitRouteNode_OneParameters_CreatesMethod()
        {
            RouteTreeNode  node           = new StaticRouteTreeNode("AuthenticateLogIn", "login/authenticate/<userName:string>/<password:string>");
            ActionTreeNode actionTreeNode = new ActionTreeNode("action");

            actionTreeNode.AddChild(node);
            controller.AddChild(actionTreeNode);
            node.AddChild(new ParameterTreeNode("userName", typeof(string)));

            using (mocks.Unordered())
            {
            }

            mocks.ReplayAll();
            generator.Visit(controller);
            mocks.VerifyAll();

            CodeDomAssert.AssertHasField(source.Ccu.Namespaces[0].Types[0], "_services");
            CodeDomAssert.AssertHasMethod(source.Ccu.Namespaces[0].Types[2], "AuthenticateLogIn");
        }
Ejemplo n.º 8
0
        public void VisitActionNode_NullableParameter_CreatesMethod()
        {
            var node = new ActionTreeNode("Index");

            controller.AddChild(node);
            node.AddChild(new ParameterTreeNode("id", "System.Nullable<System.Int32>"));

            generator.Visit(controller);

            var type = source.Ccu.Namespaces[0].Types[0];

            CodeDomAssert.AssertHasField(type, "_services");
            CodeDomAssert.AssertHasMethod(type, "Index");

            var method = type.Members.OfType <CodeMemberMethod>().First(m => m.Name == "Index");

            CodeDomAssert.AssertHasParameter(method, "id");

            var parameter = method.Parameters.OfType <CodeParameterDeclarationExpression>().First(p => p.Name == "id");

            Assert.AreEqual("System.Nullable`1", parameter.Type.BaseType);
            Assert.AreEqual(1, parameter.Type.TypeArguments.Count);
            Assert.AreEqual("System.Int32", parameter.Type.TypeArguments[0].BaseType);
        }