public async Task CanLoadAndSaveSagaData()
        {
            var initialSagaData = new BasicSagaData
            {
                Id           = Guid.NewGuid(),
                IntegerField = 77,
                StringField  = "Springfield"
            };

            await _sagaStorage.Insert(initialSagaData, _correlationProperties);

            var match = await _sagaStorage.Find(typeof(BasicSagaData), nameof(BasicSagaData.StringField), "Springfield");

            Assert.That(match, Is.Not.Null);
            Assert.That(match.Id, Is.EqualTo(initialSagaData.Id));
        }
Ejemplo n.º 2
0
        public async Task Insert(ISagaData sagaData, IEnumerable <ISagaCorrelationProperty> correlationProperties)
        {
            await Task.Delay(_delayMilliseconds);

            await _sagaStorage.Insert(sagaData, correlationProperties);
        }
Ejemplo n.º 3
0
            public async Task Insert(ISagaData sagaData, IEnumerable <ISagaCorrelationProperty> correlationProperties)
            {
                await _innerSagaStorage.Insert(sagaData, correlationProperties);

                _persistentSagaData[sagaData.Id] = sagaData;
            }
        public async Task IncludesTypeAsFindCriteria_CorrelationById()
        {
            var knownId = Guid.NewGuid();
            var correlationProperties = new[] { new TestCorrelationProperty(nameof(ISagaData.Id), typeof(Data1)) };
            await _sagaStorage.Insert(new Data1 { Id = knownId }, correlationProperties);

            var resultLookingForData1 = await _sagaStorage.Find(typeof(Data1), nameof(ISagaData.Id), knownId);

            var resultLookingForData2 = await _sagaStorage.Find(typeof(Data2), nameof(ISagaData.Id), knownId);

            Assert.That(resultLookingForData1, Is.Not.Null);
            Assert.That(resultLookingForData2, Is.Null);
        }
Ejemplo n.º 5
0
        public void ChecksRevisionOnFirstInsert()
        {
            var ex = Assert.Throws <AggregateException>(() =>
            {
                _sagaStorage
                .Insert(new JustSomeSagaData
                {
                    Id       = Guid.NewGuid(),
                    Revision = 1
                }, _noCorrelationProperties)
                .Wait();
            });

            var invalidOperationException = ex.InnerExceptions.OfType <InvalidOperationException>().Single();

            Console.WriteLine(ex);

            Assert.That(invalidOperationException.Message, Is.StringContaining("revision must be 0 on first insert"));
        }