public void Log_error_for_configuration_invalid_loglevel() { var logger = Substitute.For <ILogEvents>(); string config = @"<AggregatorConfiguration><runtime><logging level='Diag'/></runtime></AggregatorConfiguration>"; var settings = TFSAggregatorSettings.LoadXml(config, logger); Assert.IsNull(settings); logger.Received().InvalidConfiguration( XmlSeverityType.Error, "The 'level' attribute is invalid - The value 'Diag' is invalid according to its datatype 'String' - The Enumeration constraint failed.", 1, 44); }
public void Log_warning_for_unused_rule() { var logger = Substitute.For <ILogEvents>(); string config = @" <AggregatorConfiguration> <rule name='r1'/> <rule name='r2'/> <policy name='p1'> <ruleRef name='r2'/> </policy> </AggregatorConfiguration>"; var settings = TFSAggregatorSettings.LoadXml(config, logger); Assert.IsNotNull(settings); logger.Received().UnreferencedRule("r1"); }
public void Log_error_for_policy_with_no_rules() { var logger = Substitute.For <ILogEvents>(); string config = @" <AggregatorConfiguration> <rule name='r1'/> <policy name='p1'/> </AggregatorConfiguration>"; var settings = TFSAggregatorSettings.LoadXml(config, logger); Assert.IsNull(settings); logger.Received().InvalidConfiguration( XmlSeverityType.Error, "The element 'policy' has incomplete content. List of possible elements expected: 'collectionScope, templateScope, projectScope, ruleRef'.", 4, 6); }
public void Policy_ServerBaseUrl_succeed() { var logger = Substitute.For <ILogEvents>(); string config = @" <AggregatorConfiguration> <runtime> <server baseUrl = ""http://tfs.example.local:8080/"" /> </runtime> <rule name='dummy' /> <policy name='dummy' > <ruleRef name='dummy' /> </policy> </AggregatorConfiguration>"; var settings = TFSAggregatorSettings.LoadXml(config, logger); Assert.AreEqual(settings.ServerBaseUrl, new Uri("http://tfs.example.local:8080/")); }
public void LoadsGivenrateLimitsWhenInteralAttributeIsPresent() { var logger = Substitute.For <ILogEvents>(); string config = @" <AggregatorConfiguration> <runtime> <rateLimiting interval=""01:00:00.0"" /> </runtime> <rule name='dummy' /> <policy name='dummy' > <ruleRef name='dummy' /> </policy> </AggregatorConfiguration>"; var settings = TFSAggregatorSettings.LoadXml(config, logger); Assert.AreEqual(settings.RateLimit?.Interval, TimeSpan.FromHours(1)); }
public void LoadsGivenrateLimitsWhenChangesAttributesIsPresent() { var logger = Substitute.For <ILogEvents>(); string config = @" <AggregatorConfiguration> <runtime> <rateLimiting changes=""100"" /> </runtime> <rule name='dummy' /> <policy name='dummy' > <ruleRef name='dummy' /> </policy> </AggregatorConfiguration>"; var settings = TFSAggregatorSettings.LoadXml(config, logger); Assert.AreEqual(settings.RateLimit?.Changes, 100); }
public void Log_error_for_mismatched_rule_name() { var logger = Substitute.For <ILogEvents>(); string config = @" <AggregatorConfiguration> <rule name='r1'/> <policy name='p1'> <ruleRef name='r2'/> </policy> </AggregatorConfiguration>"; var settings = TFSAggregatorSettings.LoadXml(config, logger); Assert.IsNull(settings); logger.Received().InvalidConfiguration( XmlSeverityType.Error, "Reference to undeclared ID is 'r2'.", 5, 18); }
public void LoadDefaultRateLimitsWhenTagIsPresentButEmpty() { var logger = Substitute.For <ILogEvents>(); string config = @" <AggregatorConfiguration> <runtime> <rateLimiting /> </runtime> <rule name='dummy' /> <policy name='dummy' > <ruleRef name='dummy' /> </policy> </AggregatorConfiguration>"; var settings = TFSAggregatorSettings.LoadXml(config, logger); Assert.IsNotNull(settings); Assert.IsNotNull(settings.RateLimit); Assert.AreEqual(settings.RateLimit?.Interval, TimeSpan.FromSeconds(1)); Assert.AreEqual(settings.RateLimit?.Changes, 5); }
public static TFSAggregatorSettings LoadConfigFromResourceFile(string fileName, ILogEvents logger) { var configXml = LoadTextFromEmbeddedResource(fileName); return(TFSAggregatorSettings.LoadXml(configXml, logger)); }