Exemple #1
0
        public async Task ItWorks()
        {
            _activator.Register(() => new MySaga());

            await _activator.Bus.SendLocal("hej");

            await _activator.Bus.SendLocal("med");

            await _activator.Bus.SendLocal("dig");

            await Task.Delay(TimeSpan.FromSeconds(1));

            var snapshots = SqlTestHelper
                            .Query <SagaSnapshot>(
                $@"
                    SELECT 
                        [Id],
                        [Revision]
                    FROM
                        [{TableName}]"
                )
                            .OrderBy(s => s.Revision)
                            .ToList();

            Assert.That(snapshots.Count, Is.EqualTo(3));

            Assert.That(snapshots.Select(s => s.Revision), Is.EqualTo(new[] { 0, 1, 2 }), "Expected snapshots of revision 0, 1, and 2");
            Assert.That(snapshots.GroupBy(s => s.Id).Count(), Is.EqualTo(1), "Expected three snapshots for the same saga ID");
        }
 private static IEnumerable <SagaSnapshot> QuerySagaSnaps()
 {
     return(SqlTestHelper
            .Query <SagaSnapshot>(
                $@"
             SELECT 
                 [Id],
                 [Revision]
             FROM
                 [{TableName}]"
                ));
 }