public void build_a_variable_returns_an_injected_service_field_when_a_singleton_and_not_build() { var instance = LambdaInstance.For <IClock>(s => new Clock(), ServiceLifetime.Singleton); instance.CreateVariable(BuildMode.Dependency, null, false) .ShouldBeOfType <InjectedServiceField>(); }
public void build_a_variable_returns_a_get_instance_frame_when_scoped() { var instance = LambdaInstance.For <IClock>(s => new Clock(), ServiceLifetime.Scoped); instance.CreateVariable(BuildMode.Inline, null, false) .Creator.ShouldBeOfType <GetInstanceFrame>(); }
public LambdaInstance <IServiceContext, T> Add(Func <IServiceContext, T> func) { var instance = LambdaInstance.For(func); _parent.Add(instance); return(instance); }
public LambdaInstance <IServiceContext, T> Add(Func <IServiceContext, T> func) { var instance = LambdaInstance.For(func); if (_lifetime != null) { instance.Lifetime = _lifetime.Value; } _parent.Add(instance); return(instance); }
public void requires_service_provider() { LambdaInstance.For(s => new Clock()) .RequiresServiceProvider.ShouldBeTrue(); }
public void derive_the_default_name() { LambdaInstance.For(s => new Clock()) .Name.ShouldBe(nameof(Clock)); }