public void nested_container_scoping_within_a_request() { var instance1 = ContainerFacilitySource.BuildBehavior(new ServiceArguments(), ObjectDef.ForType <Behavior1>(), x => { x.Register(typeof(IService), ObjectDef.ForType <SimpleService>()); }).As <Behavior1>(); // "IService" is not a singleton, therefore, there should *only* be one created // and shared throughout the entire request. // This is vital for services like IFubuRequest instance1.Services.GetInstance <IService>().ShouldBeTheSameAs(instance1.Service); instance1.Service.ShouldBeTheSameAs(instance1.Guy.Service); }
public void will_set_properties_that_are_explicitly_set_on_ObjectDef() { var node = Process.For <OutsideBehavior>(); node.AddAfter(Process.For <InsideBehavior>()); var def = node.As <IContainerModel>().ToObjectDef(); var behavior = ContainerFacilitySource .BuildBehavior(new ServiceArguments(), def, x => { }) .As <OutsideBehavior>(); behavior.InsideBehavior.ShouldBeOfType <InsideBehavior>(); }
public void can_inject_arguments_into_the_behavior_factory() { var standInCurrentHttpRequest = new StandInCurrentHttpRequest(); var inMemoryFubuRequest = new InMemoryFubuRequest(); var arguments = new ServiceArguments() .With <ICurrentHttpRequest>(standInCurrentHttpRequest) .With <IFubuRequest>(inMemoryFubuRequest); var behavior = ContainerFacilitySource .BuildBehavior(arguments, ObjectDef.ForType <GuyWhoNeedsRequest>(), x => { }) .As <GuyWhoNeedsRequest>(); behavior.Http.ShouldBeTheSameAs(standInCurrentHttpRequest); behavior.Request.ShouldBeTheSameAs(inMemoryFubuRequest); }