public void Provider_should_return_all_matching_request_definitions()
        {
            var provider = new SlaProvider();

            var def1 = new SlaDefinition(
                MessageDefinition.Create<IRequestOne>(r => r.OneId),
                MessageDefinition.Create<IResponseOne>(r => r.Id),
                TimeSpan.FromSeconds(1));

            var def2 = new SlaDefinition(
                MessageDefinition.Create<IRequestTwo>(r => r.TwoId),
                MessageDefinition.Create<IResponseTwo>(r => r.Id),
                TimeSpan.FromSeconds(2));

            var def3 = new SlaDefinition(
                MessageDefinition.Create<IExtendedRequestOne>(r => r.OneId),
                MessageDefinition.Create<IResponseOne>(r => r.Id),
                TimeSpan.FromSeconds(3));

            provider.Add(def1);
            provider.Add(def2);
            provider.Add(def3);

            var definitions = provider.GetRequestDefinitions(new Mock<IExtendedRequestOne>().Object);

            Assert.That(definitions.ToArray(), Is.EquivalentTo(new[] { def1.Request, def3.Request }));
        }
Beispiel #2
0
        protected virtual void ProcessSla(SlaDefinition definition, TimeSpan elapsed, Guid correlationId)
        {
            Action<string, object[]> log = _logger.DebugFormat;
            if (elapsed > definition.Sla)
                log = _logger.ErrorFormat;

            log("SLA={0} Response={1} ResponseTime={2} milliseconds CorrelationId={3}",new object[] {definition.Request.Type, definition.Response.Type, (long)elapsed.TotalMilliseconds, correlationId});
        }
 protected override void ProcessSla(SlaDefinition definition, TimeSpan elapsed, Guid correlationId)
 {
     Results.Enqueue(Tuple.Create(definition, elapsed, correlationId));
 }
        public void Provider_should_return_one_request_definition_if_multiple_slas_are_referring_to_the_same_request()
        {
            var provider = new SlaProvider();

            var requestDefinition = MessageDefinition.Create<IRequestOne>(r => r.OneId);

            var def1 = new SlaDefinition(
                requestDefinition,
                MessageDefinition.Create<IResponseOne>(r => r.Id),
                TimeSpan.FromSeconds(1));

            var def2 = new SlaDefinition(
                requestDefinition,
                MessageDefinition.Create<IResponseTwo>(r => r.Id),
                TimeSpan.FromSeconds(2));

            provider.Add(def1);
            provider.Add(def2);

            Assert.That(provider.GetRequestDefinitions(new Mock<IRequestOne>().Object).ToArray(), Is.EqualTo(new[] { requestDefinition }));
        }
Beispiel #5
0
 /// <summary>
 /// Adds SLA definition
 /// </summary>
 public void Add(SlaDefinition definition)
 {
     _definitions.Add(definition);
 }