public void then_property_returns_null_element_reference()
        {
            var logExceptionHandler = viewModel.DescendentElements(x => x.ConfigurationType == typeof(LoggingExceptionHandlerData)).First();
            var logCategoryProperty = logExceptionHandler.Property("LogCategory");

            Assert.IsNull(((ElementReferenceProperty)logCategoryProperty).ReferencedElement);
        }
        public void then_property_value_is_element_reference_property()
        {
            var logExceptionHandler = viewModel.DescendentElements(x => x.ConfigurationType == typeof(LoggingExceptionHandlerData)).First();
            var logCategoryProperty = logExceptionHandler.Property("LogCategory");

            Assert.IsInstanceOfType(logCategoryProperty, typeof(ElementReferenceProperty));
            Assert.IsNotNull(((ElementReferenceProperty)logCategoryProperty).ReferencedElement);
        }
        public void then_properties_declared_on_elements_are_element_property()
        {
            var anyPolicyElement = viewModel.DescendentElements(x => x.ConfigurationType == typeof(ExceptionPolicyData)).FirstOrDefault();
            var nameProperty     = anyPolicyElement.Property("Name");

            Assert.IsNotNull(nameProperty);
            Assert.IsInstanceOfType(nameProperty, typeof(ElementProperty));
        }
        public void then_nametype_config_elements_offer_custom_property()
        {
            var elements = ViewModel.DescendentElements().Where(e => typeof(NameTypeConfigurationElement).IsAssignableFrom(e.ConfigurationType));

            Assert.IsTrue(elements.Count() > 0);
            foreach (var element in elements)
            {
                Assert.IsTrue(element.Properties.Any(p => typeof(TypeNameProperty).IsAssignableFrom(p.GetType())),
                              element.Name + " does not offer TypeNameProperty");
            }
        }
Exemple #5
0
        public void then_properties_are_initialized()
        {
            var property =
                sectionViewModel.DescendentElements().SelectMany(x => x.Properties).OfType <CustomProperty>().First();

            Assert.IsTrue(property.WasInitialized);
        }
        protected override void Act()
        {
            var configurationSource = Container.Resolve <ConfigurationSourceModel>();

            validationModel     = configurationSource.AddSection(ValidationSettings.SectionName, ValidationSection);
            stringTypeReference = validationModel.DescendentElements(x => x.ConfigurationType == typeof(ValidatedTypeReference)).First();
        }
        protected override void Arrange()
        {
            base.Arrange();

            var resources = new ResourceHelper <ConfigFileLocator>();

            resources.DumpResourceFileToDisk("empty.config");

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

            applicationViewModel.NewEnvironment();

            EhabModel            = sourceModel.AddSection(ExceptionHandlingSettings.SectionName, Section);
            EnvironmentViewModel = applicationViewModel.Environments.First();
            EnvironmentSection   = (EnvironmentalOverridesSection)EnvironmentViewModel.ConfigurationElement;

            ((EnvironmentSourceViewModel)EnvironmentViewModel).EnvironmentConfigurationFile = "empty.config";
            ((EnvironmentSourceViewModel)EnvironmentViewModel).EnvironmentDeltaFile         = "empty.config";

            WrapHandler = EhabModel.DescendentElements().Where(x => x.ConfigurationType == typeof(WrapHandlerData)).First();

            MainExceptionMessage       = WrapHandler.Property("ExceptionMessage");
            MainExceptionMessage.Value = "Main Value";

            OverridesProperty          = WrapHandler.Properties.Where(x => x.PropertyName.StartsWith("Overrides")).First();
            OverriddenExceptionMessage = OverridesProperty.ChildProperties.Where(x => x.PropertyName == "ExceptionMessage").First();
        }
        protected override void Arrange()
        {
            base.Arrange();

            Viewmodel = SectionViewModel.CreateSection(Container, ExceptionHandlingSettings.SectionName, Section);
            Handler   = (CollectionElementViewModel)Viewmodel.DescendentElements(x => typeof(ExceptionHandlerData).IsAssignableFrom(x.ConfigurationType)).First();
        }
        protected override void Arrange()
        {
            base.Arrange();

            var resources = new ResourceHelper<ConfigFileLocator>();
            resources.DumpResourceFileToDisk("empty.config");

            var applicationViewModel = Container.Resolve<ApplicationViewModel>();
            ConfigurationSourceModel sourceModel = applicationViewModel.CurrentConfigurationSource;
            applicationViewModel.NewEnvironment();

            EhabModel = sourceModel.AddSection(ExceptionHandlingSettings.SectionName, Section);
            EnvironmentViewModel = applicationViewModel.Environments.First();
            EnvironmentSection = (EnvironmentalOverridesSection)EnvironmentViewModel.ConfigurationElement;

            ((EnvironmentSourceViewModel)EnvironmentViewModel).EnvironmentConfigurationFile = "empty.config";
            ((EnvironmentSourceViewModel)EnvironmentViewModel).EnvironmentDeltaFile = "empty.config";

            WrapHandler = EhabModel.DescendentElements().Where(x => x.ConfigurationType == typeof(WrapHandlerData)).First();

            MainExceptionMessage = WrapHandler.Property("ExceptionMessage");
            MainExceptionMessage.Value = "Main Value";

            OverridesProperty = WrapHandler.Properties.Where(x => x.PropertyName.StartsWith("Overrides")).First(); 
            OverriddenExceptionMessage = OverridesProperty.ChildProperties.Where(x => x.PropertyName == "ExceptionMessage").First();
        }
        public void then_configuration_elements_collection_has_element_type()
        {
            ElementCollectionViewModel connectionStringsCollection = (ElementCollectionViewModel)
                                                                     connectionStringsModel.DescendentElements(x => x.ConfigurationType == typeof(ConnectionStringSettingsCollection)).First();

            Assert.IsNotNull(connectionStringsCollection);
            Assert.AreEqual(typeof(ConnectionStringSettings), connectionStringsCollection.CollectionElementType);
        }
        protected override void Arrange()
        {
            base.Arrange();

            Viewmodel = SectionViewModel.CreateSection(Container, ExceptionHandlingSettings.SectionName, Section);
            Handler = (CollectionElementViewModel) Viewmodel.DescendentElements(x => typeof(ExceptionHandlerData).IsAssignableFrom(x.ConfigurationType)).First();
            
        }
        public void then_has_element_if_reference_can_be_found()
        {
            var anyHandler             = ehabModel.DescendentElements().Where(x => typeof(ExceptionHandlerData).IsAssignableFrom(x.ConfigurationType)).First();
            ElementReference reference = lookup.CreateReference(anyHandler.Path);

            Assert.IsNotNull(reference.Element);
        }
        protected override void Act()
        {
            var configurationSourceModel = Container.Resolve<ConfigurationSourceModel>();
            viewModel = configurationSourceModel.AddSection(ExceptionHandlingSettings.SectionName, Section);
            loggingModel = configurationSourceModel.AddSection(LoggingSettings.SectionName, LogginSettings);

            numberOfLogCategories = loggingModel.DescendentElements(x => x.ConfigurationType == typeof(TraceSourceData)).Count();
            numberOfLogCategories -= 3; //3 special sources
        }
        protected override void Act()
        {
            var configurationSourceModel = Container.Resolve <ConfigurationSourceModel>();

            viewModel    = configurationSourceModel.AddSection(ExceptionHandlingSettings.SectionName, Section);
            loggingModel = configurationSourceModel.AddSection(LoggingSettings.SectionName, LogginSettings);

            numberOfLogCategories  = loggingModel.DescendentElements(x => x.ConfigurationType == typeof(TraceSourceData)).Count();
            numberOfLogCategories -= 3; //3 special sources
        }
Exemple #15
0
        public void then_trace_listener_collection_has_custom_trace_listener_types()
        {
            var tracelistenerCollection = (ElementCollectionViewModel)loggingViewModel.DescendentElements().Where(x => typeof(TraceListenerDataCollection) == x.ConfigurationType).First();

            Assert.IsTrue(tracelistenerCollection.PolymorphicCollectionElementTypes.Contains(typeof(SystemDiagnosticsTraceListenerData)));
            Assert.IsTrue(tracelistenerCollection.PolymorphicCollectionElementTypes.Contains(typeof(CustomTraceListenerData)));
        }
        private void AssertForAllProperties(Action <PropertyDescriptor, Property> assertion)
        {
            var allProperties = model.DescendentElements().Select(x => new { Element = x, Properties = x.Properties });

            foreach (var propertyContext in allProperties)
            {
                var PropertiesForGrid = TypeDescriptor.GetProperties(new ComponentModelElement(propertyContext.Element, Container.Resolve <IServiceProvider>())).OfType <PropertyDescriptor>();

                foreach (Property propertyFromModel in propertyContext.Properties.Where(x => !x.Hidden))
                {
                    var propertyforGrid = PropertiesForGrid.Where(x => x.Name == propertyFromModel.PropertyName).FirstOrDefault();

                    assertion(propertyforGrid, propertyFromModel);
                }
            }
        }
Exemple #17
0
        public void then_element_reference_signals_name_change()
        {
            var anyHandler = ehabModel.DescendentElements().Where(x => typeof(ExceptionHandlerData).IsAssignableFrom(x.ConfigurationType)).First();
            ElementReference reference = lookup.CreateReference(anyHandler.Path);

            string newName = string.Empty;
            reference.NameChanged += (sender, args) =>
                {
                    newName = args.Value;
                };

            anyHandler.Property("Name").Value = "new name";

            Assert.IsFalse(string.IsNullOrEmpty(newName));
            Assert.IsTrue(newName.Equals("new name"));
        }
        protected override void Arrange()
        {
            base.Arrange();

            var source = new DesignDictionaryConfigurationSource();
            new TestConfigurationBuilder().AddExceptionSettings().Build(source);

            var sourceModel = Container.Resolve<ConfigurationSourceModel>();
            sourceModel.Load(source);
            exceptionSection =
                sourceModel.Sections.Where(x => x.ConfigurationType == typeof(ExceptionHandlingSettings)).Single();

            policy = exceptionSection.DescendentElements()
                .Where(x => x.ConfigurationType == typeof(ExceptionPolicyData))
                .First();

            this.Container.RegisterInstance(new Mock<IAssemblyDiscoveryService>().Object);
        }
        protected override void Arrange()
        {
            base.Arrange();

            var source = new DesignDictionaryConfigurationSource();

            new TestConfigurationBuilder().AddExceptionSettings().Build(source);

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

            sourceModel.Load(source);
            exceptionSection =
                sourceModel.Sections.Where(x => x.ConfigurationType == typeof(ExceptionHandlingSettings)).Single();

            policy = exceptionSection.DescendentElements()
                     .Where(x => x.ConfigurationType == typeof(ExceptionPolicyData))
                     .First();

            this.Container.RegisterInstance(new Mock <IAssemblyDiscoveryService>().Object);
        }
Exemple #20
0
        public void then_extended_property_provider_can_add_properties_to_element()
        {
            var aWrapHandler = ehabModel.DescendentElements(x => x.ConfigurationType == typeof(WrapHandlerData)).First();

            Assert.IsTrue(aWrapHandler.Properties.Where(x => x.PropertyName == "Extended Property").Any());
        }
 protected override void Act()
 {
     var configurationSource = Container.Resolve<ConfigurationSourceModel>();
     validationModel = configurationSource.AddSection(ValidationSettings.SectionName, ValidationSection);
     stringTypeReference = validationModel.DescendentElements(x => x.ConfigurationType == typeof(ValidatedTypeReference)).First();
 }
        protected override void Act()
        {
            SectionViewModel loggingSection = SectionViewModel.CreateSection(Container, LoggingSettings.SectionName, LoggingSection);

            allElementPaths = loggingSection.DescendentElements().Select(x => x.Path).ToArray();
        }
        public static void InitializeSection(SectionViewModel section, InitializeContext context)
        {
            //first init section
            section.Initialize(context);

            // then initialize elements
            var elements = section.DescendentElements().OfType<ElementViewModel>();
            foreach (var element in elements)
            {
                element.Initialize(context);
            }

            //then init properties
            var sectionPropertiesThatNeedInitialization = section.Properties;
            var propertiesOfContainedElementsThatNeedInitialization =
                section.DescendentElements().SelectMany(x => x.Properties);

            foreach (var propertyThatNeedsInitialization in
                sectionPropertiesThatNeedInitialization.Concat(
                    propertiesOfContainedElementsThatNeedInitialization))
            {
                propertyThatNeedsInitialization.Initialize(context);
            }
        }
        public void then_policies_can_be_found_in_view_model()
        {
            var exceptionPolicies = viewModel.DescendentElements(x => x.ConfigurationType == typeof(ExceptionPolicyData));

            Assert.IsNotNull(exceptionPolicies);
            Assert.IsTrue(exceptionPolicies.Any());
        }
 public void then_element_collection_view_model_has_specified_type()
 {
     Assert.IsTrue(viewModel.DescendentElements().OfType <ElementCollectionViewModelEx>().Any());
 }
 protected override void Act()
 {
     viewModel = SectionViewModel.CreateSection(Container, "mockSection", section);
     customProviderElement = viewModel.DescendentElements(x => x.ConfigurationType == typeof(CustomProviderConfigurationElement)).First();
     attributesProperty = customProviderElement.Property("Attributes");
 }
 protected override void Act()
 {
     viewModel             = SectionViewModel.CreateSection(Container, "mockSection", section);
     customProviderElement = viewModel.DescendentElements(x => x.ConfigurationType == typeof(CustomProviderConfigurationElement)).First();
     attributesProperty    = customProviderElement.Property("Attributes");
 }