Esempio n. 1
0
        private void LoadSection(XmlReader reader, SettingsProviderExtensionManager settingsExtensionManager)
        {
            ValidateArg.NotNull <XmlReader>(reader, "reader");
            ValidateArg.NotNull <SettingsProviderExtensionManager>(settingsExtensionManager, "settingsExtensionManager");

            // Check for duplicate settings
            if (this.settings.ContainsKey(reader.Name))
            {
                TestSessionMessageLogger.Instance.SendMessage(
                    TestMessageLevel.Error,
                    string.Format(CultureInfo.CurrentCulture, CommonResources.DuplicateSettingsProvided, reader.Name));

                return;
            }

            // Look up the section for this node.
            var provider = settingsExtensionManager.GetSettingsProvider(reader.Name);

            if (provider != null)
            {
                try
                {
                    // Have the provider load the settings.
                    provider.Value.Load(reader.ReadSubtree());
                }
                catch (Exception e)
                {
                    // Setup to throw the exception when the section is requested.
                    provider = CreateLazyThrower(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            CommonResources.SettingsProviderInitializationError,
                            provider.Metadata.SettingsName,
                            e.Message),
                        provider.Metadata,
                        e);
                }
            }
            else
            {
                // Setup to throw when this section is requested.
                var metadata = new TestSettingsProviderMetadata(reader.Name);

                var message = string.Format(
                    CultureInfo.CurrentCulture,
                    CommonResources.SettingsProviderNotFound,
                    metadata.SettingsName);

                provider = CreateLazyThrower(message, metadata);
            }

            // Cache the provider instance so it can be looked up later when the section is requested.
            this.settings.Add(provider.Metadata.SettingsName, provider);
        }
Esempio n. 2
0
        private IEnumerable <LazyExtension <ISettingsProvider, ISettingsProviderCapabilities> > GetMockExtensions(params string[] settingNames)
        {
            var settingsList = new List <LazyExtension <ISettingsProvider, ISettingsProviderCapabilities> >();

            foreach (var settingName in settingNames)
            {
                var mockSettingsProvider = new Mock <ISettingsProvider>();
                var metadata             = new TestSettingsProviderMetadata(settingName);

                var extension =
                    new LazyExtension <ISettingsProvider, ISettingsProviderCapabilities>(
                        mockSettingsProvider.Object,
                        metadata);

                settingsList.Add(extension);
            }

            return(settingsList);
        }
Esempio n. 3
0
        public void ConstructorShouldSetSettingsName()
        {
            var metadata = new TestSettingsProviderMetadata("sample");

            Assert.AreEqual("sample", metadata.SettingsName);
        }