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 }));
        }
        public void SetUp()
        {
            _provider = new SlaProvider();
            _processor = new SlaProcessor(_provider);

            SlaDefinitionBuilder.For<Request>(r => r.Id)
                .AddSla<Response>(_sla, r => r.Id)
                .Configure(_provider);

            _appender = InjectInMemoryAppender();
        }
        public void It_should_create_definitions()
        {
            var provider = new SlaProvider();

            SlaDefinitionBuilder.For<IRequest>(x => x.RequestId)
                .AddSla<IResponse>(TimeSpan.FromSeconds(1), x => x.ResponseId)
                .AddSla<IErrorResponse>(TimeSpan.FromSeconds(2), x => x.ResponseId)
                .Configure(provider);

            Assert.That(provider.GetRequestDefinitions(new Mock<IRequest>().Object).Count(), Is.EqualTo(1), "request mapping");

            Assert.That(provider.GetSlaDefinitionsFor(new Mock<IResponse>().Object).Single().Sla,Is.EqualTo(TimeSpan.FromSeconds(1)));
            Assert.That(provider.GetSlaDefinitionsFor(new Mock<IErrorResponse>().Object).Single().Sla, Is.EqualTo(TimeSpan.FromSeconds(2)));
        }
Beispiel #4
0
 public SlaProcessor(SlaProvider provider)
 {
     _provider = provider;
 }
        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 }));
        }
 public void SetUp()
 {
     _slaProvider = new SlaProvider();
     _slaProcessor = new TestableSlaProcessor(_slaProvider);
 }
 public TestableSlaProcessor(SlaProvider provider)
     : base(provider)
 {
 }