コード例 #1
0
        public static FubuMVC.Swank.Specification.Specification GetSpec(Action <Swank> configure = null)
        {
            var graph            = Behavior.BuildGraph().AddActionsInThisNamespace();
            var moduleConvention = new ModuleConvention(new MarkerConvention <ModuleDescription>());

            var resourceConvention = new ResourceConvention(
                new MarkerConvention <ResourceDescription>(),
                new BehaviorSource(graph, Swank.CreateConfig(x => x.AppliesToThisAssembly().Where(ActionFilter))));

            var configuration = Swank.CreateConfig(x =>
            {
                x.AppliesToThisAssembly().Where(ActionFilter).WithEnumValueTypeOf(EnumValue.AsString);
                if (configure != null)
                {
                    configure(x);
                }
            });
            var specBuilder = new FubuMVC.Swank.Specification.SpecificationService(configuration,
                                                                                   new BehaviorSource(graph, configuration),
                                                                                   new TypeDescriptorCache(),
                                                                                   moduleConvention,
                                                                                   resourceConvention,
                                                                                   new EndpointConvention(),
                                                                                   new MemberConvention(),
                                                                                   new OptionConvention(),
                                                                                   new StatusCodeConvention(),
                                                                                   new HeaderConvention(),
                                                                                   new TypeConvention(),
                                                                                   new MergeService());

            return(specBuilder.Generate());
        }
コード例 #2
0
 public void Setup()
 {
     _graph = Behavior.BuildGraph().AddActionsInThisNamespace();
     _resourceConvention = new ResourceConvention(
         new MarkerConvention <ResourceDescription>(),
         new BehaviorSource(_graph, Swank.CreateConfig(x => x.AppliesToThisAssembly()
                                                       .Where(y => y.FirstCall().HandlerType.InNamespace <Tests>()))));
 }
コード例 #3
0
        public void should_exclude_complex_type_quertstring_members()
        {
            var action = Behavior.BuildGraph().AddAndGetAction <QuerystringPostHandler>();

            should_be_complex_type(CreateFactory()
                                   .BuildGraph(typeof(QuerystringModel), action), 1)
            .Members.Single().Name.ShouldEqual("Member");
        }
コード例 #4
0
        public void should_exclude_complex_type_url_parameter_members()
        {
            var action = Behavior.BuildGraph().AddAndGetAction <UrlParameterPostHandler>();

            should_be_complex_type(CreateFactory()
                                   .BuildGraph(typeof(UrlParameterModel), action), 1)
            .Members.Single().Name.ShouldEqual("Member");
        }
コード例 #5
0
        public void should_return_complex_type_member_sample_value_with_custom_format()
        {
            var action = Behavior.BuildGraph().AddAndGetAction <SampleValuePostHandler>();

            var member = should_be_complex_type(CreateFactory(x => x.SampleRealFormat = "0.0").BuildGraph(
                                                    typeof(ComplexTypeWithSampleValue), action), 1)
                         .Members.Single();

            should_match_member(member, "Member",
                                sampleValue: "3.1",
                                required: true,
                                type: x => should_be_simple_type(x, "decimal"));
        }
コード例 #6
0
        public void should_return_complex_type_member_default_value_for_input_type()
        {
            var action = Behavior.BuildGraph().AddAndGetAction <DefaultValuePostHandler>();

            var member = should_be_complex_type(CreateFactory().BuildGraph(
                                                    typeof(ComplexTypeWithDefaultValue), action), 1)
                         .Members.Single();

            should_match_member(member, "Member",
                                defaultValue: "3.14159",
                                required: true,
                                type: x => should_be_simple_type(x, "decimal"));
        }
コード例 #7
0
        public void SetUp()
        {
            _graph = Behavior.BuildGraph();

            _graph.AddAction <PostHandler>();
            var chain = _graph.GetAction <PostHandler>().ParentChain();

            var secondAction = new ActionCall(typeof(Handlers.Widgets.PostHandler), ReflectionHelper.GetMethod <Handlers.Widgets.PostHandler>(x => x.Execute_Id(null)));

            chain.AddToEnd(secondAction);

            _spec = BuildSpec <PostHandler>(_graph);
        }
コード例 #8
0
ファイル: Tests.cs プロジェクト: mikeobrien/FubuMVC.Swank
        public void SetUp()
        {
            var graph = Behavior.BuildGraph();

            graph.AddAction <PostHandler>();
            var chain = graph.GetAction <PostHandler>().ParentChain();

            var secondAction = new ActionCall(typeof(Handlers.Widgets.PostHandler), ReflectionHelper.GetMethod <Handlers.Widgets.PostHandler>(x => x.Execute_Id(null)));

            chain.AddToEnd(secondAction);

            var spec = BuildSpec <PostHandler>(graph);

            var endpoint = spec.Modules[0].Resources[0].Endpoints[0];

            _request  = endpoint.Request.Body.Description[0];
            _response = endpoint.Response.Body.Description[0];
        }
コード例 #9
0
        public void should_return_complex_type_optional_member_when_input()
        {
            var action = Behavior.BuildGraph().AddAndGetAction <OptionalMemberPostHandler>();

            var members = should_be_complex_type(CreateFactory().BuildGraph(
                                                     typeof(ComplexTypeWithOptionalMember), action), 4).Members;

            should_match_member(members[0], "OptionalMember",
                                required: false,
                                optional: true,
                                type: x => should_be_simple_type(x, "string"));

            should_match_member(members[1], "NullableMember",
                                required: false,
                                optional: true,
                                type: x => should_be_simple_type(x, "int"));

            should_match_member(members[2], "RequiredMember",
                                required: true,
                                optional: false,
                                type: x => should_be_simple_type(x, "string"));

            should_match_member(members[3].Type.Members[0], "OptionalMember",
                                required: false,
                                optional: true,
                                type: x => should_be_simple_type(x, "string"));

            should_match_member(members[3].Type.Members[1], "NullableMember",
                                required: false,
                                optional: true,
                                type: x => should_be_simple_type(x, "int"));

            should_match_member(members[3].Type.Members[2], "RequiredMember",
                                required: true,
                                optional: false,
                                type: x => should_be_simple_type(x, "string"));
        }
コード例 #10
0
 public void Setup()
 {
     _graph = Behavior.BuildGraph().AddActionsInThisNamespace();
     _statusCodeConvention = new StatusCodeConvention();
 }
コード例 #11
0
ファイル: Tests.cs プロジェクト: mikeobrien/FubuMVC.Swank
 public void Setup()
 {
     _graph = Behavior.BuildGraph().AddActionsInThisNamespace();
 }
コード例 #12
0
ファイル: Tests.cs プロジェクト: mikeobrien/FubuMVC.Swank
 public void Setup()
 {
     _moduleConvention = new ModuleConvention(new MarkerConvention <ModuleDescription>());
     _graph            = Behavior.BuildGraph().AddActionsInThisNamespace();
 }
コード例 #13
0
 public void Setup()
 {
     _graph = Behavior.BuildGraph().AddActionsInThisNamespace();
     _mimeTypeConvention = new MimeTypeConvention();
 }
コード例 #14
0
 public void Setup()
 {
     _graph            = Behavior.BuildGraph().AddActionsInThisNamespace();
     _headerConvention = new HeaderConvention();
 }
コード例 #15
0
 public void Setup()
 {
     _graph = Behavior.BuildGraph().AddActionsInThisNamespace();
     _endpointConvention = new EndpointConvention();
 }
コード例 #16
0
        protected FubuMVC.Swank.Specification.Specification BuildSpec <TNamespace>(Action <Swank> configure = null, string specFile = null)
        {
            var graph = Behavior.BuildGraph().AddActionsInNamespace(GetType());

            return(BuildSpec <TNamespace>(graph, configure, specFile));
        }