示例#1
0
        public void CacheManagerIsOverridenIfThereAreUserPolicyOverrides()
        {
            CacheManagerData data1 = new CacheManagerData();

            data1.Name         = "cache manager 1";
            data1.CacheStorage = "cache storage";
            data1.ExpirationPollFrequencyInSeconds       = 100;
            data1.MaximumElementsInCacheBeforeScavenging = 200;
            data1.NumberToRemoveWhenScavenging           = 300;
            section.CacheManagers.Add(data1);

            MockRegistryKey userCacheManagersKey = new MockRegistryKey(false);

            userKey.AddSubKey(CacheManagerSettingsManageabilityProvider.CacheManagersKeyName, userCacheManagersKey);
            MockRegistryKey userCacheManager1Key = new MockRegistryKey(false);

            userCacheManagersKey.AddSubKey(data1.Name, userCacheManager1Key);
            userCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerExpirationPollFrequencyInSecondsPropertyName, 160);
            userCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerMaximumElementsInCacheBeforeScavengingPropertyName, 260);
            userCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerNumberToRemoveWhenScavengingPropertyName, 360);

            provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings);

            Assert.AreEqual("cache storage", data1.CacheStorage);
            Assert.AreEqual(160, data1.ExpirationPollFrequencyInSeconds);
            Assert.AreEqual(260, data1.MaximumElementsInCacheBeforeScavenging);
            Assert.AreEqual(360, data1.NumberToRemoveWhenScavenging);

            Assert.IsTrue(
                MockRegistryKey.CheckAllClosed(userCacheManagersKey, userCacheManager1Key));
        }
        public void ConfigurationObjectIsModifiedIfThereAreUserPolicyOverrides()
        {
            // no need to test for attributes, it's tested for parent class
            configurationObject.Type               = typeof(Object);
            configurationObject.Formatter          = "formatter";
            configurationObject.InitData           = "init data";
            configurationObject.TraceOutputOptions = TraceOptions.Callstack;
            configurationObject.Filter             = SourceLevels.Error;

            userKey.AddStringValue(CustomTraceListenerDataManageabilityProvider.ProviderTypePropertyName, typeof(Object).AssemblyQualifiedName);
            userKey.AddStringValue(CustomTraceListenerDataManageabilityProvider.AttributesPropertyName, "");
            userKey.AddStringValue(CustomTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter");
            userKey.AddStringValue(CustomTraceListenerDataManageabilityProvider.InitDataPropertyName, "overriden init data");
            userKey.AddStringValue(CustomTraceListenerDataManageabilityProvider.FilterPropertyName, "Critical");
            userKey.AddSubKey(MsmqTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, userOptionsKey);
            userOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1);
            userOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1);

            provider.OverrideWithGroupPolicies(configurationObject, true, null, userKey);

            Assert.AreEqual("overriden formatter", configurationObject.Formatter);
            Assert.AreEqual("overriden init data", configurationObject.InitData);
            Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions);
            Assert.AreEqual(SourceLevels.Critical, configurationObject.Filter);
        }
        public void ConfigurationObjectIsModifiedIfThereAreUserPolicyOverrides()
        {
            configurationObject.EventId       = 100;
            configurationObject.FormatterType = typeof(ExceptionFormatter);
            configurationObject.LogCategory   = "category";
            configurationObject.Priority      = 50;
            configurationObject.Severity      = TraceEventType.Error;
            configurationObject.Title         = "title";

            userKey.AddIntValue(LoggingExceptionHandlerDataManageabilityProvider.EventIdPropertyName, 200);
            userKey.AddStringValue(LoggingExceptionHandlerDataManageabilityProvider.FormatterTypePropertyName, typeof(Object).AssemblyQualifiedName);
            userKey.AddStringValue(LoggingExceptionHandlerDataManageabilityProvider.LogCategoryPropertyName, "overriden category");
            userKey.AddIntValue(LoggingExceptionHandlerDataManageabilityProvider.PriorityPropertyName, 150);
            userKey.AddStringValue(LoggingExceptionHandlerDataManageabilityProvider.SeverityPropertyName, TraceEventType.Critical.ToString());
            userKey.AddStringValue(LoggingExceptionHandlerDataManageabilityProvider.TitlePropertyName, "overriden title");

            provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(configurationObject, true, null, userKey, true, wmiSettings);

            Assert.AreEqual(200, configurationObject.EventId);
            Assert.AreSame(typeof(Object), configurationObject.FormatterType);
            Assert.AreEqual("overriden category", configurationObject.LogCategory);
            Assert.AreEqual(150, configurationObject.Priority);
            Assert.AreEqual(TraceEventType.Critical, configurationObject.Severity);
            Assert.AreEqual("overriden title", configurationObject.Title);
        }
        public void ConfigurationObjectIsModifiedIfThereAreUserPolicyOverrides()
        {
            configurationObject.Formatter          = "formatter";
            configurationObject.Log                = "log";
            configurationObject.MachineName        = "machine name";
            configurationObject.Source             = "source";
            configurationObject.TraceOutputOptions = TraceOptions.None;
            configurationObject.Filter             = SourceLevels.Error;

            userKey.AddStringValue(FormattedEventLogTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter");
            userKey.AddStringValue(FormattedEventLogTraceListenerDataManageabilityProvider.LogPropertyName, "overriden log");
            userKey.AddStringValue(FormattedEventLogTraceListenerDataManageabilityProvider.MachineNamePropertyName, "overriden machine name");
            userKey.AddStringValue(FormattedEventLogTraceListenerDataManageabilityProvider.SourcePropertyName, "overriden source");
            userKey.AddStringValue(FormattedEventLogTraceListenerDataManageabilityProvider.FilterPropertyName, "Critical");
            userKey.AddSubKey(FormattedEventLogTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, userOptionsKey);
            userOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1);
            userOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1);

            provider.OverrideWithGroupPolicies(configurationObject, true, null, userKey);

            Assert.AreEqual("overriden formatter", configurationObject.Formatter);
            Assert.AreEqual("overriden log", configurationObject.Log);
            Assert.AreEqual("overriden machine name", configurationObject.MachineName);
            Assert.AreEqual("overriden source", configurationObject.Source);
            Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions);
            Assert.AreEqual(SourceLevels.Critical, configurationObject.Filter);
        }
示例#5
0
        public void ConfigurationObjectIsModifiedIfThereAreMachinePolicyOverrides()
        {
            configurationObject.FileName  = "file name";
            configurationObject.Formatter = "formatter";
            configurationObject.RollFileExistsBehavior = RollFileExistsBehavior.Increment;
            configurationObject.RollInterval           = RollInterval.Month;
            configurationObject.RollSizeKB             = 100;
            configurationObject.TimeStampPattern       = "pattern";
            configurationObject.TraceOutputOptions     = TraceOptions.None;
            configurationObject.Header = "header";
            configurationObject.Footer = "footer";

            machineKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.FileNamePropertyName, "overriden file name");
            machineKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter");
            machineKey.AddEnumValue <RollFileExistsBehavior>(RollingFlatFileTraceListenerDataManageabilityProvider.RollFileExistsBehaviorPropertyName, RollFileExistsBehavior.Overwrite);
            machineKey.AddEnumValue <RollInterval>(RollingFlatFileTraceListenerDataManageabilityProvider.RollIntervalPropertyName, RollInterval.Day);
            machineKey.AddIntValue(RollingFlatFileTraceListenerDataManageabilityProvider.RollSizeKBPropertyName, 200);
            machineKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.TimeStampPatternPropertyName, "overriden pattern");
            machineKey.AddEnumValue <TraceOptions>(RollingFlatFileTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, TraceOptions.ProcessId | TraceOptions.ThreadId);
            machineKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.HeaderPropertyName, "overriden header");
            machineKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.FooterPropertyName, "overriden footer");

            provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(configurationObject, true, machineKey, null, true, wmiSettings);

            Assert.AreEqual("overriden file name", configurationObject.FileName);
            Assert.AreEqual("overriden formatter", configurationObject.Formatter);
            Assert.AreEqual(RollFileExistsBehavior.Overwrite, configurationObject.RollFileExistsBehavior);
            Assert.AreEqual(RollInterval.Day, configurationObject.RollInterval);
            Assert.AreEqual(200, configurationObject.RollSizeKB);
            Assert.AreEqual("overriden pattern", configurationObject.TimeStampPattern);
            Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions);
            Assert.AreEqual("overriden header", configurationObject.Header);
            Assert.AreEqual("overriden footer", configurationObject.Footer);
        }
        public void ConfigurationObjectIsModifiedIfThereAreMachinePolicyOverrides()
        {
            configurationObject.AddCategoryStoredProcName = "add category";
            configurationObject.DatabaseInstanceName      = "database";
            configurationObject.Formatter = "formatter";
            configurationObject.WriteLogStoredProcName = "write";
            configurationObject.TraceOutputOptions     = TraceOptions.None;
            configurationObject.Filter = SourceLevels.Error;

            machineKey.AddStringValue(FormattedDatabaseTraceListenerDataManageabilityProvider.AddCategoryStoredProcNamePropertyName, "overriden add category");
            machineKey.AddStringValue(FormattedDatabaseTraceListenerDataManageabilityProvider.DatabaseInstanceNamePropertyName, "overriden database");
            machineKey.AddStringValue(FormattedDatabaseTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter");
            machineKey.AddStringValue(FormattedDatabaseTraceListenerDataManageabilityProvider.WriteLogStoredProcNamePropertyName, "overriden write");
            machineKey.AddStringValue(FormattedDatabaseTraceListenerDataManageabilityProvider.FilterPropertyName, "Critical");
            machineKey.AddSubKey(FormattedDatabaseTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, machineOptionsKey);
            machineOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1);
            machineOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1);

            provider.OverrideWithGroupPolicies(configurationObject, true, machineKey, null);

            Assert.AreEqual("overriden add category", configurationObject.AddCategoryStoredProcName);
            Assert.AreEqual("overriden database", configurationObject.DatabaseInstanceName);
            Assert.AreEqual("overriden formatter", configurationObject.Formatter);
            Assert.AreEqual("overriden write", configurationObject.WriteLogStoredProcName);
            Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions);
        }
示例#7
0
        public void ConfigurationObjectIsModifiedIfThereAreMachinePolicyOverrides()
        {
            configurationObject.Formatter          = "formatter";
            configurationObject.FromAddress        = "from";
            configurationObject.SmtpPort           = 25;
            configurationObject.SmtpServer         = "smtp server";
            configurationObject.SubjectLineEnder   = "subject line ender";
            configurationObject.SubjectLineStarter = "subject line starter";
            configurationObject.ToAddress          = "to";
            configurationObject.TraceOutputOptions = TraceOptions.None;

            machineKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter");
            machineKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.FromAddressPropertyName, "overriden from");
            machineKey.AddIntValue(EmailTraceListenerDataManageabilityProvider.SmtpPortPropertyName, 26);
            machineKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.SmtpServerPropertyName, "overriden smtp server");
            machineKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.SubjectLineEnderPropertyName, "overriden subject line ender");
            machineKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.SubjectLineStarterPropertyName, "overriden subject line starter");
            machineKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.ToAddressPropertyName, "overriden to");
            machineKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, "ProcessId, ThreadId");

            provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(configurationObject, true, machineKey, null, true, wmiSettings);

            Assert.AreEqual("overriden formatter", configurationObject.Formatter);
            Assert.AreEqual("overriden from", configurationObject.FromAddress);
            Assert.AreEqual(26, configurationObject.SmtpPort);
            Assert.AreEqual("overriden smtp server", configurationObject.SmtpServer);
            Assert.AreEqual("overriden subject line ender", configurationObject.SubjectLineEnder);
            Assert.AreEqual("overriden subject line starter", configurationObject.SubjectLineStarter);
            Assert.AreEqual("overriden to", configurationObject.ToAddress);
            Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions);
        }
示例#8
0
        public void ConfigurationObjectIsModifiedIfThereAreMachinePolicyOverrides()
        {
            configurationObject.FileName           = "file name";
            configurationObject.Footer             = "footer";
            configurationObject.Formatter          = "formatter";
            configurationObject.Header             = "header";
            configurationObject.TraceOutputOptions = TraceOptions.None;
            configurationObject.Filter             = SourceLevels.Error;

            machineKey.AddStringValue(FlatFileTraceListenerDataManageabilityProvider.FileNamePropertyName, "overriden file name");
            machineKey.AddStringValue(FlatFileTraceListenerDataManageabilityProvider.FooterPropertyName, "overriden footer");
            machineKey.AddStringValue(FlatFileTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter");
            machineKey.AddStringValue(FlatFileTraceListenerDataManageabilityProvider.HeaderPropertyName, "overriden header");
            machineKey.AddStringValue(FlatFileTraceListenerDataManageabilityProvider.FilterPropertyName, "Critical");
            machineKey.AddSubKey(FlatFileTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, machineOptionsKey);
            machineOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1);
            machineOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1);

            provider.OverrideWithGroupPolicies(configurationObject, true, machineKey, null);

            Assert.AreEqual("overriden file name", configurationObject.FileName);
            Assert.AreEqual("overriden footer", configurationObject.Footer);
            Assert.AreEqual("overriden formatter", configurationObject.Formatter);
            Assert.AreEqual("overriden header", configurationObject.Header);
            Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions);
            Assert.AreEqual(SourceLevels.Critical, configurationObject.Filter);
        }
示例#9
0
        public void CacheManagerIsNotOverridenIfThereArePolicyOverridesForDifferentName()
        {
            CacheManagerData data1 = new CacheManagerData();

            data1.Name         = "cache manager 1";
            data1.CacheStorage = "cache storage";
            data1.ExpirationPollFrequencyInSeconds       = 100;
            data1.MaximumElementsInCacheBeforeScavenging = 200;
            data1.NumberToRemoveWhenScavenging           = 300;
            section.CacheManagers.Add(data1);

            MockRegistryKey machineCacheManagersKey = new MockRegistryKey(false);

            machineKey.AddSubKey(CacheManagerSettingsManageabilityProvider.CacheManagersKeyName, machineCacheManagersKey);
            MockRegistryKey machineCacheManager1Key = new MockRegistryKey(false);

            machineCacheManagersKey.AddSubKey("cache manager 2", machineCacheManager1Key);
            machineCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerExpirationPollFrequencyInSecondsPropertyName, 150);
            machineCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerMaximumElementsInCacheBeforeScavengingPropertyName, 250);
            machineCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerNumberToRemoveWhenScavengingPropertyName, 350);

            provider.OverrideWithGroupPolicies(section, true, machineKey, userKey);

            Assert.AreEqual("cache storage", data1.CacheStorage);
            Assert.AreEqual(100, data1.ExpirationPollFrequencyInSeconds);
            Assert.AreEqual(200, data1.MaximumElementsInCacheBeforeScavenging);
            Assert.AreEqual(300, data1.NumberToRemoveWhenScavenging);

            Assert.IsTrue(
                MockRegistryKey.CheckAllClosed(machineCacheManagersKey, machineCacheManager1Key));
        }
        public void ConfigurationObjectIsModifiedIfThereAreMachinePolicyOverrides()
        {
            configurationObject.MaximumPriority = 10;
            configurationObject.MinimumPriority = 5;

            machineKey.AddIntValue(PriorityFilterDataManageabilityProvider.MaximumPriorityPropertyName, 9);
            machineKey.AddIntValue(PriorityFilterDataManageabilityProvider.MinimumPriorityPropertyName, 3);

            provider.OverrideWithGroupPolicies(configurationObject, true, machineKey, userKey);

            Assert.AreEqual(9, configurationObject.MaximumPriority);
            Assert.AreEqual(3, configurationObject.MinimumPriority);
        }
示例#11
0
        public void ConfigurationObjectIsModifiedIfThereAreUserPolicyOverrides()
        {
            configurationObject.MaximumPriority = 10;
            configurationObject.MinimumPriority = 5;

            userKey.AddIntValue(PriorityFilterDataManageabilityProvider.MaximumPriorityPropertyName, 9);
            userKey.AddIntValue(PriorityFilterDataManageabilityProvider.MinimumPriorityPropertyName, 3);

            provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(configurationObject, true, null, userKey, true, wmiSettings);

            Assert.AreEqual(9, configurationObject.MaximumPriority);
            Assert.AreEqual(3, configurationObject.MinimumPriority);
        }
        public void ConfigurationObjectIsModifiedIfThereAreUserPolicyOverrides()
        {
            configurationObject.TraceOutputOptions = TraceOptions.None;
            configurationObject.Filter             = SourceLevels.Error;

            userKey.AddStringValue(WmiTraceListenerDataManageabilityProvider.FilterPropertyName, "Critical");
            userKey.AddSubKey(WmiTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, userOptionsKey);
            userOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1);
            userOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1);

            provider.OverrideWithGroupPolicies(configurationObject, true, null, userKey);

            Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions);
            Assert.AreEqual(SourceLevels.Critical, configurationObject.Filter);
        }
示例#13
0
        public void ConfigurationObjectIsModifiedIfThereAreUserPolicyOverrides()
        {
            configurationObject.CacheManager       = "cache manager";
            configurationObject.AbsoluteExpiration = 100;
            configurationObject.SlidingExpiration  = 200;

            userKey.AddStringValue(CachingStoreProviderDataManageabilityProvider.CacheManagerPropertyName, "user cache manager");
            userKey.AddIntValue(CachingStoreProviderDataManageabilityProvider.AbsoluteExpirationPropertyName, 150);
            userKey.AddIntValue(CachingStoreProviderDataManageabilityProvider.SlidingExpirationPropertyName, 250);

            provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(configurationObject, true, null, userKey, true, wmiSettings);

            Assert.AreEqual("user cache manager", configurationObject.CacheManager);
            Assert.AreEqual(150, configurationObject.AbsoluteExpiration);
            Assert.AreEqual(250, configurationObject.SlidingExpiration);
        }
示例#14
0
        public void ConfigurationObjectIsModifiedIfThereAreMachinePolicyOverrides()
        {
            configurationObject.CacheManager       = "cache manager";
            configurationObject.AbsoluteExpiration = 100;
            configurationObject.SlidingExpiration  = 200;

            machineKey.AddStringValue(CachingStoreProviderDataManageabilityProvider.CacheManagerPropertyName, "machine cache manager");
            machineKey.AddIntValue(CachingStoreProviderDataManageabilityProvider.AbsoluteExpirationPropertyName, 150);
            machineKey.AddIntValue(CachingStoreProviderDataManageabilityProvider.SlidingExpirationPropertyName, 250);

            provider.OverrideWithGroupPolicies(configurationObject, true, machineKey, userKey);

            Assert.AreEqual("machine cache manager", configurationObject.CacheManager);
            Assert.AreEqual(150, configurationObject.AbsoluteExpiration);
            Assert.AreEqual(250, configurationObject.SlidingExpiration);
        }
        public void ConfigurationObjectIsModifiedIfThereAreMachinePolicyOverrides()
        {
            configurationObject.Formatter          = "formatter";
            configurationObject.MessagePriority    = MessagePriority.Normal;
            configurationObject.QueuePath          = "queue";
            configurationObject.Recoverable        = true;
            configurationObject.TimeToBeReceived   = TimeSpan.FromSeconds(500);
            configurationObject.TimeToReachQueue   = TimeSpan.FromSeconds(1000);
            configurationObject.TraceOutputOptions = TraceOptions.None;
            configurationObject.Filter             = SourceLevels.Error;
            configurationObject.TransactionType    = MessageQueueTransactionType.None;
            configurationObject.UseAuthentication  = false;
            configurationObject.UseDeadLetterQueue = true;
            configurationObject.UseEncryption      = false;

            machineKey.AddStringValue(MsmqTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter");
            machineKey.AddStringValue(MsmqTraceListenerDataManageabilityProvider.MessagePriorityPropertyName, MessagePriority.High.ToString());
            machineKey.AddStringValue(MsmqTraceListenerDataManageabilityProvider.QueuePathPropertyName, "overriden queue");
            machineKey.AddBooleanValue(MsmqTraceListenerDataManageabilityProvider.RecoverablePropertyName, false);
            machineKey.AddStringValue(MsmqTraceListenerDataManageabilityProvider.TimeToBeReceivedPropertyName, Convert.ToString(TimeSpan.FromSeconds(100), CultureInfo.CurrentCulture));
            machineKey.AddStringValue(MsmqTraceListenerDataManageabilityProvider.TimeToReachQueuePropertyName, Convert.ToString(TimeSpan.FromSeconds(200), CultureInfo.CurrentCulture));
            machineKey.AddStringValue(MsmqTraceListenerDataManageabilityProvider.FilterPropertyName, "Critical");
            machineKey.AddStringValue(MsmqTraceListenerDataManageabilityProvider.TransactionTypePropertyName, MessageQueueTransactionType.Single.ToString());
            machineKey.AddBooleanValue(MsmqTraceListenerDataManageabilityProvider.UseAuthenticationPropertyName, true);
            machineKey.AddBooleanValue(MsmqTraceListenerDataManageabilityProvider.UseDeadLetterQueuePropertyName, false);
            machineKey.AddBooleanValue(MsmqTraceListenerDataManageabilityProvider.UseEncryptionPropertyName, true);
            machineKey.AddSubKey(MsmqTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, machineOptionsKey);
            machineOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1);
            machineOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1);

            provider.OverrideWithGroupPolicies(configurationObject, true, machineKey, null);

            Assert.AreEqual("overriden formatter", configurationObject.Formatter);
            Assert.AreEqual(MessagePriority.High, configurationObject.MessagePriority);
            Assert.AreEqual("overriden queue", configurationObject.QueuePath);
            Assert.AreEqual(false, configurationObject.Recoverable);
            Assert.AreEqual(TimeSpan.FromSeconds(100), configurationObject.TimeToBeReceived);
            Assert.AreEqual(TimeSpan.FromSeconds(200), configurationObject.TimeToReachQueue);
            Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions);
            Assert.AreEqual(SourceLevels.Critical, configurationObject.Filter);
            Assert.AreEqual(MessageQueueTransactionType.Single, configurationObject.TransactionType);
            Assert.AreEqual(true, configurationObject.UseAuthentication);
            Assert.AreEqual(false, configurationObject.UseDeadLetterQueue);
            Assert.AreEqual(true, configurationObject.UseEncryption);
        }
        public void ConfigurationObjectIsModifiedIfThereAreUserPolicyOverrides()
        {
            configurationObject.FileName  = "file name";
            configurationObject.Formatter = "formatter";
            configurationObject.RollFileExistsBehavior = RollFileExistsBehavior.Increment;
            configurationObject.RollInterval           = RollInterval.Month;
            configurationObject.RollSizeKB             = 100;
            configurationObject.TimeStampPattern       = "pattern";
            configurationObject.TraceOutputOptions     = TraceOptions.None;
            configurationObject.Filter           = SourceLevels.Error;
            configurationObject.Header           = "header";
            configurationObject.Footer           = "footer";
            configurationObject.MaxArchivedFiles = 10;

            userKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.FileNamePropertyName, "overriden file name");
            userKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter");
            userKey.AddEnumValue <RollFileExistsBehavior>(RollingFlatFileTraceListenerDataManageabilityProvider.RollFileExistsBehaviorPropertyName, RollFileExistsBehavior.Overwrite);
            userKey.AddEnumValue <RollInterval>(RollingFlatFileTraceListenerDataManageabilityProvider.RollIntervalPropertyName, RollInterval.Day);
            userKey.AddIntValue(RollingFlatFileTraceListenerDataManageabilityProvider.RollSizeKBPropertyName, 200);
            userKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.TimeStampPatternPropertyName, "overriden pattern");
            userKey.AddEnumValue <SourceLevels>(RollingFlatFileTraceListenerDataManageabilityProvider.FilterPropertyName, SourceLevels.Critical);
            userKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.HeaderPropertyName, "overriden header");
            userKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.FooterPropertyName, "overriden footer");
            userKey.AddIntValue(RollingFlatFileTraceListenerDataManageabilityProvider.MaxArchivedFilesPropertyName, 20);
            userKey.AddSubKey(RollingFlatFileTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, userOptionsKey);
            userOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1);
            userOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1);

            provider.OverrideWithGroupPolicies(configurationObject, true, null, userKey);

            Assert.AreEqual("overriden file name", configurationObject.FileName);
            Assert.AreEqual("overriden formatter", configurationObject.Formatter);
            Assert.AreEqual(RollFileExistsBehavior.Overwrite, configurationObject.RollFileExistsBehavior);
            Assert.AreEqual(RollInterval.Day, configurationObject.RollInterval);
            Assert.AreEqual(200, configurationObject.RollSizeKB);
            Assert.AreEqual("overriden pattern", configurationObject.TimeStampPattern);
            Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions);
            Assert.AreEqual(SourceLevels.Critical, configurationObject.Filter);
            Assert.AreEqual("overriden header", configurationObject.Header);
            Assert.AreEqual("overriden footer", configurationObject.Footer);
            Assert.AreEqual(20, configurationObject.MaxArchivedFiles);
        }
        public void ConfigurationObjectIsModifiedIfThereAreUserPolicyOverrides()
        {
            configurationObject.Formatter          = "formatter";
            configurationObject.FromAddress        = "from";
            configurationObject.SmtpPort           = 25;
            configurationObject.SmtpServer         = "smtp server";
            configurationObject.SubjectLineEnder   = "subject line ender";
            configurationObject.SubjectLineStarter = "subject line starter";
            configurationObject.ToAddress          = "to";
            configurationObject.TraceOutputOptions = TraceOptions.None;
            configurationObject.Filter             = SourceLevels.Error;

            userKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter");
            userKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.FromAddressPropertyName, "overriden from");
            userKey.AddIntValue(EmailTraceListenerDataManageabilityProvider.SmtpPortPropertyName, 26);
            userKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.SmtpServerPropertyName, "overriden smtp server");
            userKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.SubjectLineEnderPropertyName, "overriden subject line ender");
            userKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.SubjectLineStarterPropertyName, "overriden subject line starter");
            userKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.ToAddressPropertyName, "overriden to");
            userKey.AddStringValue(EmailTraceListenerDataManageabilityProvider.FilterPropertyName, "Critical");
            userKey.AddSubKey(EmailTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, userOptionsKey);
            userOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1);
            userOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1);

            provider.OverrideWithGroupPolicies(configurationObject, true, null, userKey);

            Assert.AreEqual("overriden formatter", configurationObject.Formatter);
            Assert.AreEqual("overriden from", configurationObject.FromAddress);
            Assert.AreEqual(26, configurationObject.SmtpPort);
            Assert.AreEqual("overriden smtp server", configurationObject.SmtpServer);
            Assert.AreEqual("overriden subject line ender", configurationObject.SubjectLineEnder);
            Assert.AreEqual("overriden subject line starter", configurationObject.SubjectLineStarter);
            Assert.AreEqual("overriden to", configurationObject.ToAddress);
            Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions);
            Assert.AreEqual(SourceLevels.Critical, configurationObject.Filter);
        }
示例#18
0
 public void GetStringWhenValueIsOfWrongTypeThrows()
 {
     registryKey.AddIntValue("name", 0);
     ((RegistryKeyBase)registryKey).GetStringValue("name");
 }
        public void CacheManagerIsNotOverridenIfThereArePolicyOverridesForDifferentName()
        {
            CacheManagerData data1 = new CacheManagerData();
            data1.Name = "cache manager 1";
            data1.CacheStorage = "cache storage";
            data1.ExpirationPollFrequencyInSeconds = 100;
            data1.MaximumElementsInCacheBeforeScavenging = 200;
            data1.NumberToRemoveWhenScavenging = 300;
            section.CacheManagers.Add(data1);

            MockRegistryKey machineCacheManagersKey = new MockRegistryKey(false);
            machineKey.AddSubKey(CacheManagerSettingsManageabilityProvider.CacheManagersKeyName, machineCacheManagersKey);
            MockRegistryKey machineCacheManager1Key = new MockRegistryKey(false);
            machineCacheManagersKey.AddSubKey("cache manager 2", machineCacheManager1Key);
            machineCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerExpirationPollFrequencyInSecondsPropertyName, 150);
            machineCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerMaximumElementsInCacheBeforeScavengingPropertyName, 250);
            machineCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerNumberToRemoveWhenScavengingPropertyName, 350);

            provider.OverrideWithGroupPolicies(section, true, machineKey, userKey);

            Assert.AreEqual("cache storage", data1.CacheStorage);
            Assert.AreEqual(100, data1.ExpirationPollFrequencyInSeconds);
            Assert.AreEqual(200, data1.MaximumElementsInCacheBeforeScavenging);
            Assert.AreEqual(300, data1.NumberToRemoveWhenScavenging);

            Assert.IsTrue(
                MockRegistryKey.CheckAllClosed(machineCacheManagersKey, machineCacheManager1Key));
        }