public void CanDeserializeSerializedConfiguration()
        {
            string sourceName1 = "source1";
            string sourceName2 = "source2";

            string sourceFile1 = "file 1";

            ConfigurationSourceSection settings = new ConfigurationSourceSection();

            ConfigurationSourceElement data1 = new FileConfigurationSourceElement(sourceName1, sourceFile1);
            ConfigurationSourceElement data2 = new SystemConfigurationSourceElement(sourceName2);

            settings.Sources.Add(data1);
            settings.Sources.Add(data2);
            settings.SelectedSource = sourceName1;

            IDictionary<string, ConfigurationSection> sections = new Dictionary<string, ConfigurationSection>();
            sections[ConfigurationSourceSection.SectionName] = settings;
            IConfigurationSource configurationSource
                = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);

            ConfigurationSourceSection roSettigs = (ConfigurationSourceSection)configurationSource.GetSection(ConfigurationSourceSection.SectionName);

            Assert.IsNotNull(roSettigs);
            Assert.AreEqual(2, roSettigs.Sources.Count);
            Assert.AreEqual(sourceName1, roSettigs.SelectedSource);

            Assert.IsNotNull(roSettigs.Sources.Get(sourceName1));
            Assert.AreSame(typeof(FileConfigurationSourceElement), roSettigs.Sources.Get(sourceName1).GetType());
            Assert.AreEqual(sourceFile1, ((FileConfigurationSourceElement)roSettigs.Sources.Get(sourceName1)).FilePath);

            Assert.IsNotNull(roSettigs.Sources.Get(sourceName2));
            Assert.AreSame(typeof(SystemConfigurationSourceElement), roSettigs.Sources.Get(sourceName2).GetType());
        }
        /// <summary>
        /// Initialize a new instance of the <see cref="FileConfigurationSourceElement"/> class with a <see cref="FileConfigurationSourceElement"/>.
        /// </summary>
        /// <param name="element">The <see cref="FileConfigurationSourceElement"/> to initialize.</param>
        public FileConfigurationSourceElementNode(FileConfigurationSourceElement element)
            : base(null == element ? string.Empty : element.Name)
        {
            if (null == element) throw new ArgumentNullException("element");

            this.filePath = element.FilePath;
            this.type = element.Type;
        }
        protected override void Arrange()
        {
            base.Arrange();

            var resourceHelper = new ResourceHelper<ConfigFiles.ConfigFileLocator>();
            mainFilePath = resourceHelper.DumpResourceFileToDisk("empty.config", "ds_inv_rel_path");
            mainConfigurationSource = new DesignConfigurationSource(mainFilePath);

            configurationSourceElement = new FileConfigurationSourceElement("relativefile", "doesnt-exist\\relative.config");

            var mainFileDirectory = Path.GetDirectoryName(mainFilePath);
            expectedFilePath = Path.Combine(mainFileDirectory, configurationSourceElement.FilePath);
        }
        protected override void Arrange()
        {
            base.Arrange();

            var resourceHelper = new ResourceHelper<ConfigFiles.ConfigFileLocator>();
            mainFilePath = resourceHelper.DumpResourceFileToDisk("empty.config", "ds_abs_ro_path");
            mainConfigurationSource = new DesignConfigurationSource(mainFilePath);

            var mainFileDirectory = Path.GetDirectoryName(mainFilePath);
            expectedFilePath = Path.Combine(mainFileDirectory, "absolutefile.config");

            configurationSourceElement = new FileConfigurationSourceElement("absolutefile", expectedFilePath);
            File.WriteAllText(expectedFilePath, "<configuration/>");
            File.SetAttributes(expectedFilePath, FileAttributes.ReadOnly);
        }