Esempio n. 1
0
        public void then_trace_listener_reference_suggested_values_include_name()
        {
            var traceListenerReference = loggingViewModel.GetDescendentsOfType <TraceListenerReferenceData>().First();

            var nameProperty = traceListenerReference.Property("Name");

            Assert.IsTrue(nameProperty.SuggestedValues.Contains(nameProperty.Value));
        }
        public void then_readonly_properties_with_editors_dont_offer_editors()
        {
            var exceptionType    = model.GetDescendentsOfType <ExceptionTypeData>().First();
            var typeNameProperty = new ElementProperty(Container.Resolve <IServiceProvider>(),
                                                       exceptionType,
                                                       TypeDescriptor.GetProperties(typeof(ExceptionTypeData)).OfType <PropertyDescriptor>().Where(x => x.Name == "TypeName").First(),
                                                       new Attribute[] { new EditorAttribute(typeof(TypeSelectionEditor), typeof(UITypeEditor)) });

            Assert.IsTrue(typeNameProperty.ReadOnly);
            Assert.IsTrue(typeNameProperty.BindableProperty is PopupEditorBindableProperty);
            Assert.IsNull(typeNameProperty.BindableProperty.GetEditor(typeof(UITypeEditor)));
        }
Esempio n. 3
0
        public void then_trace_sources_have_listeners_as_related_elements()
        {
            var traceSources = loggingViewModel.GetDescendentsOfType <TraceSourceData>();

            foreach (var source in traceSources)
            {
                foreach (var listener in source.GetDescendentsOfType <TraceListenerReferenceData>())
                {
                    var thisListener = listener;

                    Assert.IsTrue(loggingViewModel.GetRelatedElements(source)
                                  .Where(x => x.Name == listener.Name && typeof(TraceListenerData).IsAssignableFrom(x.ConfigurationType))
                                  .Any());
                }
            }
        }
        protected override void Arrange()
        {
            base.Arrange();

            exceptionSettingsViewModel = SectionViewModel.CreateSection(Container, ExceptionHandlingSettings.SectionName, new ExceptionHandlingSettings());
            var exceptionPolicyContainer = exceptionSettingsViewModel.GetDescendentsOfType <NamedElementCollection <ExceptionPolicyData> >().First();

            addExceptionPolicyCommand = exceptionPolicyContainer.AddCommands.OfType <AddExceptionPolicyCommand>().First();
        }
        protected override void Arrange()
        {
            base.Arrange();

            exceptionSettingsViewModel = SectionViewModel.CreateSection(Container, ExceptionHandlingSettings.SectionName, new ExceptionHandlingSettings());
            var exceptionPolicyContainer = exceptionSettingsViewModel.GetDescendentsOfType<NamedElementCollection<ExceptionPolicyData>>().First();
            
            addExceptionPolicyCommand = exceptionPolicyContainer.AddCommands.OfType<AddExceptionPolicyCommand>().First();
        }
Esempio n. 6
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;
        }
        public void then_database_block_has_default_connection_string()
        {
            var configurationSourceModel     = Container.Resolve <ConfigurationSourceModel>();
            SectionViewModel databaseSection = configurationSourceModel.Sections.Where(x => x.SectionName == "connectionStrings").First();

            ElementViewModel addedConnectionString = databaseSection.GetDescendentsOfType <ConnectionStringSettings>().FirstOrDefault();

            string defaultDatabase = (string)databaseSection.Property("DefaultDatabase").Value;

            Assert.AreEqual(addedConnectionString.Property("Name").Value, defaultDatabase);
        }
        protected override void Arrange()
        {
            base.Arrange();

            HostAdapter = new SingleHierarchyConfigurationUIHostAdapter(new HostAdapterConfiguration(AppDomain.CurrentDomain.BaseDirectory), null);
            ConfigurationSourceModel sourceModel = (ConfigurationSourceModel)HostAdapter.GetService(typeof(ConfigurationSourceModel));
            
            sourceModel.AddSection(CacheManagerSettings.SectionName, new CacheManagerSettings {DefaultCacheManager = "Cache Manager",  CacheManagers = { { new CacheManagerData { Name = "Cache Manager" } } }, BackingStores = {{ new CustomCacheStorageData("name", "custom store type") }} });

            CachingViewModel = sourceModel.Sections.Single();
            CacheManager = CachingViewModel.GetDescendentsOfType<CacheManagerData>().First();
        }
        protected override void Arrange()
        {
            base.Arrange();

            var sourceModel = Container.Resolve<ConfigurationSourceModel>();
            LoggingViewModel = sourceModel.AddSection(LoggingSettings.SectionName, LoggingSection);

            defaultCategoryProperty = (ElementReferenceProperty)LoggingViewModel.Property("DefaultCategory");
            defaultCategoryProperty.Initialize(null);

            traceSource = LoggingViewModel.GetDescendentsOfType<TraceSourceData>().First();

            defaultCacheManagerPropertyChangedListener = new PropertyChangedListener(defaultCategoryProperty);
        }
        protected override void Act()
        {
            var referencedSection = new TestReferencedSection();

            configSource.AddSection("referencedSection", referencedSection);
            newSection = configSource.Sections.Where(x => x.SectionName == "referencedSection").Single();

            var referencedItems = newSection
               .GetDescendentsOfType<NamedElementCollection<ReferencedItemType>>()
               .OfType<ElementCollectionViewModel>().First();

            var newItem = referencedItems.AddNewCollectionElement(typeof(ReferencedItemType));
            newItem.Property("Name").Value = "ReferringTo";
        }
Esempio n. 11
0
        protected override void Act()
        {
            var referencedSection = new TestReferencedSection();

            configSource.AddSection("referencedSection", referencedSection);
            newSection = configSource.Sections.Where(x => x.SectionName == "referencedSection").Single();

            var referencedItems = newSection
                                  .GetDescendentsOfType <NamedElementCollection <ReferencedItemType> >()
                                  .OfType <ElementCollectionViewModel>().First();

            var newItem = referencedItems.AddNewCollectionElement(typeof(ReferencedItemType));

            newItem.Property("Name").Value = "ReferringTo";
        }
        protected override void Arrange()
        {
            base.Arrange();

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

            LoggingViewModel = sourceModel.AddSection(LoggingSettings.SectionName, LoggingSection);

            defaultCategoryProperty = (ElementReferenceProperty)LoggingViewModel.Property("DefaultCategory");
            defaultCategoryProperty.Initialize(null);

            traceSource = LoggingViewModel.GetDescendentsOfType <TraceSourceData>().First();

            defaultCacheManagerPropertyChangedListener = new PropertyChangedListener(defaultCategoryProperty);
        }
Esempio n. 13
0
        protected override void Arrange()
        {
            base.Arrange();

            HostAdapter = new SingleHierarchyConfigurationUIHostAdapter(new HostAdapterConfiguration(AppDomain.CurrentDomain.BaseDirectory), null);
            ConfigurationSourceModel sourceModel = (ConfigurationSourceModel)HostAdapter.GetService(typeof(ConfigurationSourceModel));

            sourceModel.AddSection(CacheManagerSettings.SectionName, new CacheManagerSettings {
                DefaultCacheManager = "Cache Manager", CacheManagers = { { new CacheManagerData {
                                                                               Name = "Cache Manager"
                                                                           } } }, BackingStores = { { new CustomCacheStorageData("name", "custom store type") } }
            });

            CachingViewModel = sourceModel.Sections.Single();
            CacheManager     = CachingViewModel.GetDescendentsOfType <CacheManagerData>().First();
        }
        protected override void Arrange()
        {
            base.Arrange();

            HostAdapter = new SingleHierarchyConfigurationUIHostAdapter(new HostAdapterConfiguration(AppDomain.CurrentDomain.BaseDirectory), null);
            ConfigurationSourceModel sourceModel = (ConfigurationSourceModel)HostAdapter.GetService(typeof(ConfigurationSourceModel));

            sourceModel.AddSection(
                LoggingSettings.SectionName,
                new LoggingSettings
            {
                DefaultCategory = "category",
                TraceSources    = { new TraceSourceData("category", System.Diagnostics.SourceLevels.Critical) },
                TraceListeners  = { new FormattedEventLogTraceListenerData("event log", "source", "formatter") },
                Formatters      = { new CustomFormatterData("formatter", "custom formatter type") }
            });

            LoggingViewModel = sourceModel.Sections.Single();
            TraceListener    = LoggingViewModel.GetDescendentsOfType <TraceListenerData>().First();
        }
        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();
        }
        protected override void Arrange()
        {
            base.Arrange();

            ApplicationModel = Container.Resolve <IApplicationModel>();

            var configurationSection = new MockSectionWithSingleChild
            {
                Children =
                {
                    { new TestHandlerDataWithChildren {
                          Name = "Element"
                      } }
                }
            };

            SectionViewModel sectionViewmodel = SectionViewModel.CreateSection(Container, "MockSection", configurationSection);

            Element = sectionViewmodel.GetDescendentsOfType <TestHandlerDataWithChildren>().First();
            ApplicationModel.OnSelectedElementChanged(null);
            ElementContainer = new ElementModelContainer {
                DataContext = Element
            };
        }
Esempio n. 17
0
        protected override void Act()
        {
            var tracelistener = sectionViewModel.GetDescendentsOfType <FormattedEventLogTraceListenerData>().First();

            relatedElements = sectionViewModel.GetRelatedElements(tracelistener);
        }
        public void then_has_add_command()
        {
            var exceptionPolicy = sectionViewModel.GetDescendentsOfType <ExceptionPolicyData>().First();

            Assert.IsTrue(exceptionPolicy.Commands.Where(x => x.Placement == CommandPlacement.ContextAdd).Any());
        }
 protected override void Act()
 {
     removedElement = sectionViewModel.GetDescendentsOfType <ExceptionTypeData>().First();
     removedElement.DeleteCommand.Execute(null);
 }
Esempio n. 20
0
 public void then_custom_attribute_property_applied()
 {
     Assert.IsTrue(
         sectionViewModel.GetDescendentsOfType <ElementWithExtendedViewModel>().First()
         .Properties.Where(p => p.PropertyName == "Attributes").Any());
 }
Esempio n. 21
0
 protected override void Act()
 {
     collection =
         ViewModel.GetDescendentsOfType <UnnamedChildCollection>().OfType <ElementCollectionViewModel>().First();
     collection.AddNewCollectionElement(typeof(UnnamedChild));
 }