public void Should_remove_timeouts_by_sagaid()
        {
            new TimeoutsIndex().Execute(store);

            var persister = new TimeoutPersister
            {
                DocumentStore = store,
                EndpointName  = "MyTestEndpoint",
            };

            var sagaId1 = Guid.NewGuid();
            var sagaId2 = Guid.NewGuid();
            var t1      = new TimeoutData
            {
                SagaId = sagaId1,
                Time   = DateTime.Now.AddYears(1),
                OwningTimeoutManager = "MyTestEndpoint",
                Headers = new Dictionary <string, string>
                {
                    { "Header1", "Value1" }
                }
            };
            var t2 = new TimeoutData
            {
                SagaId = sagaId2,
                Time   = DateTime.Now.AddYears(1),
                OwningTimeoutManager = "MyTestEndpoint",
                Headers = new Dictionary <string, string>
                {
                    { "Header1", "Value1" }
                }
            };

            persister.Add(t1);
            persister.Add(t2);

            WaitForIndexing(store);

            persister.RemoveTimeoutBy(sagaId1);
            persister.RemoveTimeoutBy(sagaId2);

            using (var session = store.OpenSession())
            {
                Assert.Null(session.Load <Timeout>(new Guid(t1.Id)));
                Assert.Null(session.Load <Timeout>(new Guid(t2.Id)));
            }
        }
Example #2
0
        public void RemoveTimeoutBy_RemovesAllTimeoutsForSaga()
        {
            AddTimeouts();
            var timeout    = _dbContext.Timeouts.First();
            var another    = Build(DateTime.UtcNow);
            var yetAnother = Build(DateTime.UtcNow);

            another.SagaId    = timeout.SagaId;
            yetAnother.SagaId = timeout.SagaId;
            _dbContext.Timeouts.Add(another);
            _dbContext.Timeouts.Add(yetAnother);
            _dbContext.SaveChanges();

            _persister.RemoveTimeoutBy(timeout.SagaId);

            _dbContext.Timeouts.Count(t => t.SagaId == timeout.SagaId).Should().Be(0);
        }