Beispiel #1
0
        protected override void Arrange()
        {
            base.Arrange();

            Mock <AssemblyLocator> assemblyLocator = new Mock <AssemblyLocator>();

            assemblyLocator.Setup(x => x.Assemblies).Returns(new Assembly[] { typeof(ManageableConfigurationSourceElement).Assembly });
            this.Container.RegisterType <ManageableConfigurationSourceViewModel>(
                new InjectionConstructor(
                    typeof(ElementCollectionViewModel),
                    typeof(ConfigurationElement),
                    new InjectionParameter <AssemblyLocator>(assemblyLocator.Object)));

            targetFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "manageableSourcetextnp.config");
            File.Create(targetFilePath).Dispose();
            File.WriteAllText(targetFilePath, "<configuration/>");

            var source = new DesignConfigurationSource(targetFilePath);

            ConfigurationSourceElement =
                new ManageableConfigurationSourceElement
            {
                Name     = "manageable",
                FilePath = "file.config",
                ConfigurationManageabilityProviders =
                {
                    new ConfigurationSectionManageabilityProviderData
                    {
                        Name     = "provider",
                        TypeName = typeof(object).AssemblyQualifiedName
                    }
                }
            };
            var section =
                new ConfigurationSourceSection
            {
                SelectedSource = "manageable",
                Sources        =
                {
                    ConfigurationSourceElement
                }
            };

            source.AddLocalSection(ConfigurationSourceSection.SectionName, section);


            var sourceModel = this.Container.Resolve <ConfigurationSourceModel>();

            sourceModel.Load(source);

            SectionViewModel =
                sourceModel.Sections.Where(x => x.ConfigurationType == typeof(ConfigurationSourceSection)).Single();

            ConfigurationSourceViewModel = SectionViewModel.GetDescendentsOfType <ManageableConfigurationSourceElement>().FirstOrDefault();
            ConfigurationSourceElement   = (ManageableConfigurationSourceElement)ConfigurationSourceViewModel.ConfigurationElement;
        }
        protected override void Arrange()
        {
            base.Arrange();

            targetFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "manageableSource.config");
            File.Create(targetFilePath).Dispose();
            File.WriteAllText(targetFilePath, "<configuration/>");

            var source = new DesignConfigurationSource(targetFilePath);

            var section =
                new ConfigurationSourceSection
            {
                SelectedSource = "manageable",
                Sources        =
                {
                    new ManageableConfigurationSourceElement
                    {
                        Name     = "manageable",
                        FilePath = "file.config",
                    }
                }
            };

            source.AddLocalSection(ConfigurationSourceSection.SectionName, section);


            var sourceModel = this.Container.Resolve <ConfigurationSourceModel>();

            sourceModel.Load(source);

            SectionViewModel =
                sourceModel.Sections.Where(x => x.ConfigurationType == typeof(ConfigurationSourceSection)).Single();

            ConfigurationSourceViewModel = SectionViewModel.GetDescendentsOfType <ManageableConfigurationSourceElement>().FirstOrDefault();
        }