/// <summary>
 /// Initializes a new instance of the <see cref="Output"/> class.
 /// </summary>
 /// <param name="routeReader">The route reader.</param>
 /// <param name="controllerReader">Controller action reader.</param>
 public Output(RouteReader routeReader, ControllerReader controllerReader, IEnumerable<IJavaScriptAddition> additions)
 {
     if (routeReader == null) throw new ArgumentNullException("reader");
     this.routeReader = routeReader;
     this.controllerReader = controllerReader;
     this.additions = additions ?? Enumerable.Empty<IJavaScriptAddition>();
 }
        public void Ctr_ControllerActionParameters_DefaultValueSetToDefaultVAlueIfSpecified()
        {
            var types = new[]
            {
                typeof(TestController3),
            };

            var reader = new ControllerReader(types, new IControllerActionInterceptor[0]);
            Assert.Equal("\"" + TestController3.defaultValue + "\"", reader.Definitions.First(a => a.ActionName.Equals("DefaultTest")).Parameters.First.Value.DefaultValue);
        }
        public void Ctr_ControllerActionParameters_SetToOptionalIfDefaultValueSpecified()
        {
            var types = new[]
            {
                typeof(TestController3),
            };

            var reader = new ControllerReader(types, new IControllerActionInterceptor[0]);
            Assert.True(reader.Definitions.First(a => a.ActionName.Equals("DefaultTest")).Parameters.First.Value.Optional);
        }
        public void Ctr_ControllerActionParameters_WithCorrectName()
        {
            var types = new[]
            {
                typeof(TestController3),
            };

            var reader = new ControllerReader(types, new IControllerActionInterceptor[0]);
            Assert.Equal("id", reader.Definitions.First(a => a.ActionName.Equals("ParamTest")).Parameters.First.Value.Name);
        }
        public void Ctr_AddsControllerParameters()
        {
            var types = new[]
            {
                typeof(TestController3),
            };

            var reader = new ControllerReader(types, new IControllerActionInterceptor[0]);
            Assert.NotEmpty(reader.Definitions.First(a => a.ActionName.Equals("ParamTest")).Parameters);
        }
        public void Ctr_ControllerActionParameters_SetToOptionalIfDefaultValueSpecified()
        {
            var container = new Container(config =>
            {
                config.AddType(typeof(ControllerBase), typeof(TestController3));
            });

            var reader = new ControllerReader(container, new IControllerActionInterceptor[0]);
            Assert.True(reader.Definitions.First(a => a.ActionName.Equals("DefaultTest")).Parameters.First.Value.Optional);
        }
        public void Ctr_ControllerActionParameters_WithCorrectName()
        {
            var container = new Container(config =>
            {
                config.AddType(typeof(ControllerBase), typeof(TestController3));
            });

            var reader = new ControllerReader(container, new IControllerActionInterceptor[0]);
            Assert.Equal("id", reader.Definitions.First(a => a.ActionName.Equals("ParamTest")).Parameters.First.Value.Name);
        }
        public void Ctr_AddsControllerParameters()
        {
            var container = new Container(config =>
            {
                config.AddType(typeof(ControllerBase), typeof(TestController3));
            });

            var reader = new ControllerReader(container, new IControllerActionInterceptor[0]);
            Assert.NotEmpty(reader.Definitions.First(a => a.ActionName.Equals("ParamTest")).Parameters);
        }
        public void Ctr_DoesNotAddController_WhenInterceptorReturnsFalse()
        {
            var types = new []
            {
                typeof(TestController),
                typeof(TestController2),
            };

            var reader = new ControllerReader(types, new[] { new BlankInterceptor { ReturnValue = true }, new BlankInterceptor { ReturnValue = false }, new BlankInterceptor { ReturnValue = true } });
            Assert.Equal(0, reader.Definitions.Count());
        }
        public void Ctr_AddsControllerActions_FromContainerModel()
        {
            var container = new Container(config =>
            {
                config.AddType(typeof(ControllerBase), typeof(TestController));
                config.AddType(typeof(ControllerBase), typeof(TestController2));
            });

            var reader = new ControllerReader(container, new IControllerActionInterceptor[0]);
            Assert.Equal(2, reader.Definitions.Count());
        }
        public void Ctr_DoesNotAddController_WhenInterceptorReturnsFalse()
        {
            var container = new Container(config =>
            {
                config.AddType(typeof(ControllerBase), typeof(TestController));
                config.AddType(typeof(ControllerBase), typeof(TestController2));
            });

            var reader = new ControllerReader(container, new[] { new BlankInterceptor { ReturnValue = true }, new BlankInterceptor { ReturnValue = false }, new BlankInterceptor { ReturnValue = true } });
            Assert.Equal(0, reader.Definitions.Count());
        }
 public void Ctr_AddsControllerActions_FromContainerModel()
 {
     var reader = new ControllerReader(new [] { typeof(TestController), typeof(TestController2) }, new IControllerActionInterceptor[0]);
     Assert.Equal(2, reader.Definitions.Count());
 }
        public void Ctr_ControllerActionParameters_SetsDescription_IfDocumentationSpecified()
        {
            var container = new Container(config =>
            {
                config.AddType(typeof(ControllerBase), typeof(TestController3));
            });

            var reader = new ControllerReader(container, new IControllerActionInterceptor[0]);
            Assert.NotEmpty(reader.Definitions.First(a => a.ActionName.Equals("SummaryTest")).Parameters.First.Value.Description);
        }
        public void Ctr_ControllerActionParameters_DefaultValueSetToDefaultVAlueIfSpecified()
        {
            var container = new Container(config =>
            {
                config.AddType(typeof(ControllerBase), typeof(TestController3));
            });

            var reader = new ControllerReader(container, new IControllerActionInterceptor[0]);
            Assert.Equal("\"" + TestController3.defaultValue + "\"", reader.Definitions.First(a => a.ActionName.Equals("DefaultTest")).Parameters.First.Value.DefaultValue);
        }
        public void Ctr_ControllerActionParameters_SetsDescription_IfDocumentationSpecified()
        {
            var types = new[]
            {
                typeof(TestController3),
            };

            var reader = new ControllerReader(types, new IControllerActionInterceptor[0]);
            Assert.NotEmpty(reader.Definitions.First(a => a.ActionName.Equals("SummaryTest")).Parameters.First.Value.Description);
        }
        public void Ctr_ControllerAction_SetsDescription_WhenSummaryXMLContainsSummary()
        {
            var types = new[]
            {
                typeof(TestController3),
            };

            var reader = new ControllerReader(types, new IControllerActionInterceptor[0]);
            Assert.NotEmpty(reader.Definitions.First(a => a.ActionName.Equals("ActionSummaryTest")).Description);
        }
        public void Ctr_ControllerAction_SetsDescription_WhenSummaryXMLContainsSummary()
        { 
            var container = new Container(config =>
            {
                config.AddType(typeof(ControllerBase), typeof(TestController3));
            });

            var reader = new ControllerReader(container, new IControllerActionInterceptor[0]);
            Assert.NotEmpty(reader.Definitions.First(a => a.ActionName.Equals("ActionSummaryTest")).Description);
        }