Exemple #1
0
        public void ShouldNotSerializeAnEventAsRabbitSubject()
        {
            //non routable property
            Expression <Func <TestEvent, bool> > validExpression = (ev) => (ev.AggregateId == "MySmallBusiness" && (ev.Broker == "Newedge" && ev.Counterparty == "SGCIB") && ev.Exchange == "SmallCap");

            var visitor = new TopicExchangeRabbitMQSubjectResolver(typeof(TestEvent));

            Assert.Throws <InvalidOperationException>(() =>
            {
                visitor.Visit(validExpression);
            });


            //type not allowed
            validExpression = (ev) => ev.Invalid == null;

            Assert.Throws <InvalidOperationException>(() =>
            {
                visitor.Visit(validExpression);
            });


            //member multiple reference
            validExpression = (ev) => ev.AggregateId == "EUR/USD" && ev.AggregateId == "EUR/GBP";

            Assert.Throws <InvalidOperationException>(() =>
            {
                visitor.Visit(validExpression);
            });

            //too complex lambda
            validExpression = (ev) => ev.AggregateId == "EUR/USD" && ev.Market != "Euronext";

            Assert.Throws <InvalidOperationException>(() =>
            {
                visitor.Visit(validExpression);
            });
        }
Exemple #2
0
        public RabbitMqQueueConfiguration(Expression <Func <TEvent, bool> >?routingStrategy = null,
                                          string?queueName  = null,
                                          bool isAutoAck    = false,
                                          bool isDurable    = true,
                                          bool isAutoDelete = false,
                                          bool isExclusive  = false)
        {
            if (null == routingStrategy)
            {
                routingStrategy = (_) => true;
            }

            var rabbitMQSubjectExpressionVisitor = new TopicExchangeRabbitMQSubjectResolver(typeof(TEvent));

            rabbitMQSubjectExpressionVisitor.Visit(routingStrategy);

            RoutingKey   = rabbitMQSubjectExpressionVisitor.GetSubject();
            QueueName    = queueName;
            IsAutoAck    = isAutoAck;
            IsDurable    = isDurable;
            IsAutoDelete = isAutoDelete;
            IsExclusive  = isExclusive;
        }
Exemple #3
0
        public void ShouldSerializeAnEventAsRabbitSubject()
        {
            Expression <Func <TestEvent, bool> > validExpression = (ev) => (ev.AggregateId == "MySmallBusiness" && (ev.Market == "Euronext" && ev.Counterparty == "SGCIB") && ev.Exchange == "SmallCap");

            var visitor = new TopicExchangeRabbitMQSubjectResolver(typeof(TestEvent));

            visitor.Visit(validExpression);

            var subject = visitor.GetSubject();

            Assert.AreEqual("TestEvent.MySmallBusiness.Euronext.SGCIB.SmallCap", subject);

            validExpression = (ev) => true;

            visitor.Visit(validExpression);

            subject = visitor.GetSubject();

            Assert.AreEqual("TestEvent.#", subject);

            validExpression = (ev) => ev.AggregateId == "MySmallBusiness";

            visitor.Visit(validExpression);

            subject = visitor.GetSubject();

            Assert.AreEqual("TestEvent.MySmallBusiness.*.*.*", subject);

            validExpression = (ev) => ev.Market == "Euronext";

            visitor.Visit(validExpression);

            subject = visitor.GetSubject();

            Assert.AreEqual("TestEvent.*.Euronext.*.*", subject);
        }