Пример #1
0
        public void ShouldThrowWhenContainerBuilderIsNotProvided()
        {
            Action action = () => AutofacExtensions.AddEnvReader(null);

            action.Should()
            .ThrowExactly <ArgumentNullException>();
        }
Пример #2
0
        public void ShouldThrowWhenContainerBuilderIsNull()
        {
            Action action = () => AutofacExtensions.AddEnv(null, builder => { });

            action.Should()
            .ThrowExactly <ArgumentNullException>();
        }
        public void WithParameter_AccessorIsNull_ThrowsArgumentNullException()
        {
            var    regBuilder    = Substitute.For <IRegistrationBuilder <ExampleType, ReflectionActivatorData, object> >();
            string parameterName = "value1";
            Func <IComponentContext, object> accessor = null;

            const string message = "valueAccessor should not be null.";

            Assert.That(() => AutofacExtensions.WithParameter(regBuilder, parameterName, accessor),
                        Throws.TypeOf <ArgumentNullException>()
                        .And.Message.Contains(message));
        }
        public void WithParameter_ParameterNameIsEmpty_ThrowsArgumentException()
        {
            var    regBuilder    = Substitute.For <IRegistrationBuilder <ExampleType, ReflectionActivatorData, object> >();
            string parameterName = String.Empty;
            Func <IComponentContext, object> accessor = c => new object();

            const string message = "parameterName should not be an empty string.";

            Assert.That(() => AutofacExtensions.WithParameter(regBuilder, parameterName, accessor),
                        Throws.TypeOf <ArgumentException>()
                        .And.Message.Contains(message));
        }
        public void WithProperty_RegistrationIsNull_ThrowsArgumentNullException()
        {
            IRegistrationBuilder <ExampleType, ReflectionActivatorData, object> regBuilder = null;
            string propertyName = "Value1";
            Func <IComponentContext, object> accessor = c => new object();

            const string message = "registration should not be null.";

            Assert.That(() => AutofacExtensions.WithProperty(regBuilder, propertyName, accessor),
                        Throws.TypeOf <ArgumentNullException>()
                        .And.Message.Contains(message));
        }
Пример #6
0
 protected override void Load(ContainerBuilder builder)
 {
     if (_isDevelopment)
     {
         RegisterDevelopmentOnlyDependencies(builder);
     }
     else
     {
         RegisterProductionOnlyDependencies(builder);
     }
     RegisterCommonDependencies(builder);
     RegisterPaymentHandlerDependencies(builder);
     AutofacExtensions.RegisterVimeoServicesDependencies(builder, _vimeoToken);
 }
Пример #7
0
        public async Task <IActionResult> Post()
        {
            var args         = this.GetArgs();
            var fileContents = await this.GetFileContentsAsync();


            var func = AutofacExtensions.ResolveNamed <IFunc>($"Func_{args.Func}");

            if (func == null)
            {
                return(this.StatusCode(521));
            }

            return(func.Do(fileContents, args));
        }