public void behavior_tracers_deeper()
        {
            var node  = Wrapper.For <SimpleBehavior>();
            var chain = new BehaviorChain();

            chain.AddToEnd(node);
            node.AddAfter(Wrapper.For <DifferentBehavior>());

            ApplyTracing.ApplyToChain(chain);



            var objectDef = chain.As <IContainerModel>().ToObjectDef().FindDependencyDefinitionFor <IActionBehavior>();

            objectDef.Type.ShouldEqual(typeof(BehaviorTracer));
            var child1 = objectDef.FindDependencyDefinitionFor <IActionBehavior>();

            child1.Type.ShouldEqual(typeof(SimpleBehavior));

            var child2 = child1.FindDependencyDefinitionFor <IActionBehavior>();

            child2.Type.ShouldEqual(typeof(BehaviorTracer));

            var child3 = child2.FindDependencyDefinitionFor <IActionBehavior>();

            child3.Type.ShouldEqual(typeof(DifferentBehavior));
        }
Beispiel #2
0
        public void adding_a_route_alias_adds_a_RouteAliasAdded_event()
        {
            var chain = new BehaviorChain();
            var alias = new RouteDefinition("something/else");

            chain.AddRouteAlias(alias);

            chain.As <ITracedModel>().StagedEvents.Last().ShouldEqual(new RouteAliasAdded(alias));
        }
Beispiel #3
0
        public void adding_a_route_adds_a_RouteDefined_event()
        {
            var chain = new BehaviorChain();
            var route = new RouteDefinition("something");

            chain.Route = route;

            chain.As <ITracedModel>().StagedEvents.Last().ShouldEqual(new RouteDetermined(route));
        }
Beispiel #4
0
        public void adding_a_filter_logs()
        {
            var filter = MockRepository.GenerateMock <IBehaviorInvocationFilter>();

            var chain = new BehaviorChain();

            chain.AddFilter(filter);

            chain.As <ITracedModel>().StagedEvents.OfType <FilterAdded>().Single().ShouldEqual(new FilterAdded(filter));
        }
        public void the_replace_method_puts_a_node_replaced_event_on_the_chain()
        {
            var original = new SimpleNode();
            var newNode  = new SimpleNode();

            var chain = new BehaviorChain();

            chain.AddToEnd(original);

            original.ReplaceWith(newNode);

            chain.As <ITracedModel>().StagedEvents.Last()
            .ShouldEqual(new NodeReplaced(original, newNode));
        }
Beispiel #6
0
        public void should_register_an_endpoint_authorizor_if_there_are_any_authorization_rules()
        {
            var chain = new BehaviorChain();

            chain.AddToEnd(ActionCall.For <OneController>(x => x.Query(null)));
            chain.Authorization.AddRole("Role 1");
            chain.Prepend(chain.Authorization);

            var container = new Container();
            var facility  = new StructureMapContainerFacility(container);

            chain.As <IRegisterable>().Register(DiagnosticLevel.None, facility.Register);

            facility.BuildFactory();

            container.GetInstance <IEndPointAuthorizor>(chain.UniqueId.ToString())
            .ShouldNotBeNull().ShouldBeOfType <EndPointAuthorizor>();
        }
        public void the_remove_method_puts_a_node_removed_event_on_the_chain()
        {
            var chain = new BehaviorChain();

            chain.AddToEnd(new SimpleNode());

            var nodeToBeRemoved = new SimpleNode();

            chain.AddToEnd(nodeToBeRemoved);

            chain.AddToEnd(new SimpleNode());
            chain.AddToEnd(new SimpleNode());

            nodeToBeRemoved.Remove();

            chain.As <ITracedModel>().StagedEvents.Last()
            .ShouldEqual(new NodeRemoved(nodeToBeRemoved));
        }
Beispiel #8
0
        public void should_not_register_an_endpoint_authorizor_if_there_are_no_authorization_roles()
        {
            var chain = new BehaviorChain();

            chain.AddToEnd(ActionCall.For <OneController>(x => x.Query(null)));
            //chain.Authorization.AddRole("Role 1");

            var container = new Container();
            var facility  = new StructureMapContainerFacility(container);

            chain.As <IRegisterable>().Register(facility.Register);

            facility.BuildFactory();

            Debug.WriteLine(chain.UniqueId);
            Debug.WriteLine(container.WhatDoIHave());

            container.GetInstance <IEndPointAuthorizor>(chain.UniqueId.ToString())
            .ShouldBeOfType <NulloEndPointAuthorizor>();
        }
        public void the_remove_method_puts_a_node_removed_event_on_the_chain()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(new SimpleNode());

            var nodeToBeRemoved = new SimpleNode();
            chain.AddToEnd(nodeToBeRemoved);

            chain.AddToEnd(new SimpleNode());
            chain.AddToEnd(new SimpleNode());

            nodeToBeRemoved.Remove();

            chain.As<ITracedModel>().StagedEvents.Last()
                .ShouldEqual(new NodeRemoved(nodeToBeRemoved));
        }
Beispiel #10
0
        public void should_not_register_an_endpoint_authorizor_if_there_are_no_authorization_roles()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<OneController>(x => x.Query(null)));
            //chain.Authorization.AddRole("Role 1");

            var container = new Container();
            var facility = new StructureMapContainerFacility(container);

            chain.As<IRegisterable>().Register(facility.Register);

            facility.BuildFactory(DiagnosticLevel.None);

            Debug.WriteLine(chain.UniqueId);
            Debug.WriteLine(container.WhatDoIHave());

            container.GetInstance<IEndPointAuthorizor>(chain.UniqueId.ToString())
                .ShouldBeOfType<NulloEndPointAuthorizor>();
        }
Beispiel #11
0
        public void adding_a_filter_logs()
        {
            var filter = MockRepository.GenerateMock<IBehaviorInvocationFilter>();

            var chain = new BehaviorChain();
            chain.AddFilter(filter);

            chain.As<ITracedModel>().StagedEvents.OfType<FilterAdded>().Single().ShouldEqual(new FilterAdded(filter));
        }
Beispiel #12
0
 public void starts_with_the_ChainCreated_event()
 {
     var chain = new BehaviorChain();
     chain.As<ITracedModel>().StagedEvents.Single().ShouldBeOfType<Created>();
 }
Beispiel #13
0
        public void adding_a_route_alias_adds_a_RouteAliasAdded_event()
        {
            var chain = new BehaviorChain();
            var alias = new RouteDefinition("something/else");

            chain.AddRouteAlias(alias);

            chain.As<ITracedModel>().StagedEvents.Last().ShouldEqual(new RouteAliasAdded(alias));
        }
 private Instance toObjectDef()
 {
     return(theChain.As <IContainerModel>().ToInstance());
 }
Beispiel #15
0
        public string UrlFor(BehaviorChain chain, RouteParameters parameters)
        {
            var url = chain.As <RoutedChain>().Route.Input.CreateUrlFromParameters(parameters);

            return(_httpRequest.ToFullUrl(url));
        }
Beispiel #16
0
        public string UrlFor(object model, BehaviorChain chain)
        {
            var url = chain.As <RoutedChain>().Route.CreateUrlFromInput(model);

            return(_httpRequest.ToFullUrl(url));
        }
        public void adding_a_route_adds_a_RouteDefined_event()
        {
            var chain = new BehaviorChain();
            var route = new RouteDefinition("something");

            chain.Route = route;

            chain.As<ITracedModel>().StagedEvents.Last().ShouldEqual(new RouteDefined(route));
        }
Beispiel #18
0
 public EndpointToken(BehaviorChain chain)
 {
     RoutePattern = chain is RoutedChain ? chain.As<RoutedChain>().GetRoutePattern() : string.Empty;
     Actions = chain.Calls.Select(x => new ActionToken(x)).ToArray();
 }
Beispiel #19
0
 public void the_chain_can_build_its_object_def_smoke_test()
 {
     theChain.As <IContainerModel>().ToObjectDef().ShouldNotBeNull();
 }
 public string UrlFor(object model, BehaviorChain chain)
 {
     var url = chain.As<RoutedChain>().Route.CreateUrlFromInput(model);
     return _httpRequest.ToFullUrl(url);
 }
Beispiel #21
0
        public void starts_with_the_ChainCreated_event()
        {
            var chain = new BehaviorChain();

            chain.As <ITracedModel>().StagedEvents.Single().ShouldBeOfType <Created>();
        }
        public string UrlFor(BehaviorChain chain, RouteParameters parameters)
        {
            var url = chain.As<RoutedChain>().Route.Input.CreateUrlFromParameters(parameters);

            return _httpRequest.ToFullUrl(url);
        }
        public void should_register_an_endpoint_authorizor_if_there_are_any_authorization_rules()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<OneController>(x => x.Query(null)));
            chain.Authorization.AddRole("Role 1");
            chain.Prepend(chain.Authorization);

            var container = new Container();
            var facility = new StructureMapContainerFacility(container);

            chain.As<IRegisterable>().Register(DiagnosticLevel.None, facility.Register);

            facility.BuildFactory();

            container.GetInstance<IEndPointAuthorizor>(chain.UniqueId.ToString())
                .ShouldNotBeNull().ShouldBeOfType<EndPointAuthorizor>();
        }
        public void the_replace_method_puts_a_node_replaced_event_on_the_chain()
        {
            var original = new SimpleNode();
            var newNode = new SimpleNode();

            var chain = new BehaviorChain();
            chain.AddToEnd(original);

            original.ReplaceWith(newNode);

            chain.As<ITracedModel>().StagedEvents.Last()
                .ShouldEqual(new NodeReplaced(original, newNode));
        }
Beispiel #25
0
        public EndpointToken(BehaviorChain chain)
        {
            RoutePattern = chain is RoutedChain?chain.As <RoutedChain>().GetRoutePattern() : string.Empty;

            Actions = chain.Calls.Select(x => new ActionToken(x)).ToArray();
        }
Beispiel #26
0
 private ObjectDef toObjectDef()
 {
     return(theChain.As <IContainerModel>().ToObjectDef());
 }