Exemple #1
0
        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>();
        }
Exemple #2
0
        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>();
        }
Exemple #3
0
            public LambdaInstance <IServiceContext, T> Add(Func <IServiceContext, T> func)
            {
                var instance = LambdaInstance.For(func);

                _parent.Add(instance);

                return(instance);
            }
Exemple #4
0
            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);
            }
Exemple #5
0
 public void requires_service_provider()
 {
     LambdaInstance.For(s => new Clock())
     .RequiresServiceProvider.ShouldBeTrue();
 }
Exemple #6
0
 public void derive_the_default_name()
 {
     LambdaInstance.For(s => new Clock())
     .Name.ShouldBe(nameof(Clock));
 }