コード例 #1
0
        protected IbanNetOptionsBuilderTests()
        {
            var module = new IbanNetModule(true);

            _builder          = new AutofacIbanNetOptionsBuilder(module);
            _containerBuilder = new ContainerBuilder();
            _containerBuilder.RegisterModule(module);
        }
コード例 #2
0
        /// <summary>
        /// Registers IbanNet services using specified options builder.
        /// </summary>
        /// <param name="containerBuilder">The container builder.</param>
        /// <param name="configure">The options builder.</param>
        /// <param name="preserveStaticValidator"><see langword="true" /> to preserve the static validator in <see cref="Iban.Validator" />, or <see langword="false" /> to replace with the configured instance.</param>
        /// <returns>The container builder so that additional calls can be chained.</returns>
        public static ContainerBuilder RegisterIbanNet(this ContainerBuilder containerBuilder, Action <IIbanNetOptionsBuilder> configure, bool preserveStaticValidator = false)
        {
            if (containerBuilder is null)
            {
                throw new ArgumentNullException(nameof(containerBuilder));
            }

            if (configure is null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var module  = new IbanNetModule(preserveStaticValidator);
            var builder = new AutofacIbanNetOptionsBuilder(module);

            configure(builder);
            containerBuilder.RegisterModule(module);
            return(containerBuilder);
        }
コード例 #3
0
            public static IEnumerable <object[]> BuilderExtensionsWithoutBuilderInstance()
            {
                var instance = new AutofacIbanNetOptionsBuilder(new IbanNetModule(true));

                return(new NullArgumentTestCases
                {
                    // Instance
                    DelegateTestCase.Create <Action <DependencyResolverAdapter, IbanValidatorOptions>, IIbanNetOptionsBuilder>(
                        instance.Configure,
                        (s, o) => { }),

                    // Extensions
                    DelegateTestCase.Create <IIbanNetOptionsBuilder, Func <IComponentContext, TestValidationRule>, IIbanNetOptionsBuilder>(
                        IbanNetOptionsBuilderExtensions.WithRule,
                        instance,
                        s => new TestValidationRule()),
                    DelegateTestCase.Create <IIbanNetOptionsBuilder, Action <IComponentContext, IbanValidatorOptions>, IIbanNetOptionsBuilder>(
                        IbanNetOptionsBuilderExtensions.Configure,
                        instance,
                        (s, opts) => { })
                }.Flatten());
            }