Ejemplo n.º 1
0
		public void The_saga_expression_should_be_converted_down_to_a_saga_only_filter()
		{
			Expression<Func<SimpleSaga, InitiateSimpleSaga, bool>> selector = (s, m) => s.CorrelationId == m.CorrelationId;

			var filter = new SagaFilterExpressionConverter<SimpleSaga, InitiateSimpleSaga>(_initiateSaga).Convert(selector);
			Trace.WriteLine(filter.ToString());

			var matches = _repository.Where(filter);

			Assert.AreEqual(1, matches.Count());
		}
Ejemplo n.º 2
0
		public void Matching_by_property_should_be_happy()
		{
			Expression<Func<SimpleSaga, ObservableSagaMessage, bool>> selector = (s, m) => s.Name == m.Name;

			var filter = new SagaFilterExpressionConverter<SimpleSaga, ObservableSagaMessage>(_observeSaga).Convert(selector);
			Trace.WriteLine(filter.ToString());

			var matches = _repository.Where(filter);

			Assert.AreEqual(1, matches.Count());
		}
Ejemplo n.º 3
0
        public async Task Matching_by_property_should_be_happy()
        {
            Expression<Func<SimpleSaga, ObservableSagaMessage, bool>> selector = (s, m) => s.Name == m.Name;

            Expression<Func<SimpleSaga, bool>> filter =
                new SagaFilterExpressionConverter<SimpleSaga, ObservableSagaMessage>(_observeSaga).Convert(selector);
            Trace.WriteLine(filter.ToString());

            Guid? matches = await _repository.ShouldContainSaga(filter, TestTimeout);

            Assert.IsTrue(matches.HasValue);
        }
Ejemplo n.º 4
0
        public void Matching_by_property_should_be_happy()
        {
            Expression <Func <SimpleSaga, ObservableSagaMessage, bool> > selector = (s, m) => s.Name == m.Name;

            var filter = new SagaFilterExpressionConverter <SimpleSaga, ObservableSagaMessage>(_observeSaga).Convert(selector);

            Trace.WriteLine(filter.ToString());

            var matches = _repository.Where(filter);

            Assert.AreEqual(1, matches.Count());
        }
Ejemplo n.º 5
0
        public void The_saga_expression_should_be_converted_down_to_a_saga_only_filter()
        {
            Expression <Func <SimpleSaga, InitiateSimpleSaga, bool> > selector = (s, m) => s.CorrelationId == m.CorrelationId;

            var filter = new SagaFilterExpressionConverter <SimpleSaga, InitiateSimpleSaga>(_initiateSaga).Convert(selector);

            Trace.WriteLine(filter.ToString());

            var matches = _repository.Where(filter);

            Assert.AreEqual(1, matches.Count());
        }
Ejemplo n.º 6
0
        public async Task Matching_by_property_should_be_happy()
        {
            Expression <Func <SimpleSaga, ObservableSagaMessage, bool> > selector = (s, m) => s.Name == m.Name;

            Expression <Func <SimpleSaga, bool> > filter =
                new SagaFilterExpressionConverter <SimpleSaga, ObservableSagaMessage>(_observeSaga).Convert(selector);

            Trace.WriteLine(filter.ToString());

            Guid?matches = await _repository.ShouldContainSaga(filter, TestTimeout);

            Assert.IsTrue(matches.HasValue);
        }
Ejemplo n.º 7
0
        public async Task The_saga_expression_should_be_converted_down_to_a_saga_only_filter()
        {
            Expression<Func<SimpleSaga, InitiateSimpleSaga, bool>> selector =
                (s, m) => s.CorrelationId == m.CorrelationId;

            Expression<Func<SimpleSaga, bool>> filter =
                new SagaFilterExpressionConverter<SimpleSaga, InitiateSimpleSaga>(_initiateSaga).Convert(selector);
            Trace.WriteLine(filter.ToString());

            Guid? matches = await _repository.ShouldContainSaga(filter, TestTimeout);

            Assert.IsTrue(matches.HasValue);
        }
Ejemplo n.º 8
0
        public async Task The_saga_expression_should_be_converted_down_to_a_saga_only_filter()
        {
            Expression <Func <SimpleSaga, InitiateSimpleSaga, bool> > selector =
                (s, m) => s.CorrelationId == m.CorrelationId;

            Expression <Func <SimpleSaga, bool> > filter =
                new SagaFilterExpressionConverter <SimpleSaga, InitiateSimpleSaga>(_initiateSaga).Convert(selector);

            Trace.WriteLine(filter.ToString());

            Guid?matches = await _repository.ShouldContainSaga(filter, TestTimeout);

            Assert.IsTrue(matches.HasValue);
        }
Ejemplo n.º 9
0
        public IEnumerable <Guid> Find(IConsumeContext <TMessage> context)
        {
            Expression <Func <TSaga, bool> > filter =
                new SagaFilterExpressionConverter <TSaga, TMessage>(context.Message).Convert(_filterExpression);

            var sagaFilter = new SagaFilter <TSaga>(filter);

            int count = 0;

            foreach (var sagaId in  _repository.Where(sagaFilter, x => x.CorrelationId))
            {
                yield return(sagaId);

                count++;
            }

            if (count == 0)
            {
                if (_policy.CanCreateInstance(context))
                {
                    yield return(_policy.GetNewSagaId(context));
                }
            }
        }