Exemplo n.º 1
0
        public void TestValidListOfObjectLiterals()
        {
            var resolvers = new ObjectLiteral[]
            {
                CreateObject("kind", "SourceResolver"),
                CreateObject("kind", "SourceResolver")
            };

            // lazy because in case there is a _bug_ in the converter, we don't want this auxiliary conversion
            // to fail first, before the actual unit test (inside the for loop)
            var myConvertedResolversArrayLazy = Lazy.Create(() =>
                                                            resolvers.Select(r => ConfigurationConverter.Convert <IResolverSettings>(m_context, r)).ToArray());

            foreach (var resolversList in GetDifferentListRepresenations(resolvers))
            {
                IConfiguration conf = ConfigurationConverter.ConvertObjectLiteralToConfiguration(
                    m_context,
                    CreateObject("resolvers", resolversList));

                XAssert.IsNotNull(conf);
                AssertAlmostEqualToDefaultConfigurationObject(conf, "Resolvers");
                var confResolversArray = conf.Resolvers.ToArray();

                XAssert.IsTrue(MyEqual(myConvertedResolversArrayLazy.Value, confResolversArray));
            }
        }
Exemplo n.º 2
0
        public static void SetConfiguration(IConfigurationSection section)
        {
            var config = ConfigurationConverter.Convert(section);

            MessageManager = new MessageManager(config);
            Configuration  = config;
        }
Exemplo n.º 3
0
        public static void AddMail(this IServiceCollection services, IConfiguration configuration)
        {
            MailServiceJsonConfiguration jsonConfiguration = new MailServiceJsonConfiguration();

            configuration.Bind("MailService", jsonConfiguration);
            var converter = new ConfigurationConverter(new MailTemplateFactory());
            var options   = converter.Convert(jsonConfiguration);

            AddService(services, options);
        }
Exemplo n.º 4
0
 public void TestInvalidEnumMemberConversion()
 {
     Assert.Throws <ConversionException>(() =>
                                         ConfigurationConverter.Convert <MyClassWithEnum>(m_context, CreateObject("member", "enum.member")));
 }
Exemplo n.º 5
0
 public void TestValidEmptyObjectLiteral()
 {
     MyEqual(ConfigurationConverter.Convert <ConfigurationImpl>(m_context, s_emptyObjectLiteral), m_defaultConf);
     MyEqual(ConfigurationConverter.Convert <IConfiguration>(m_context, s_emptyObjectLiteral), m_defaultConf);
 }
Exemplo n.º 6
0
 public void ItExists()
 {
     _converter.Convert(_configuration);
 }