Exemplo n.º 1
0
        public void IsActive()
        {
            var mapper = new ThreadBatchIdMapper();
            var guid   = mapper.Create(mapper);

            Assert.True(mapper.IsActive);
        }
Exemplo n.º 2
0
        public void CreateTwo_ReleaseUnknown()
        {
            var mapper = new ThreadBatchIdMapper();

            mapper.Create(mapper);
            mapper.Create(this);

            Assert.Throws <InvalidOperationException>(() => mapper.Release(new object()));
        }
Exemplo n.º 3
0
        public void CreateAndGet()
        {
            var mapper = new ThreadBatchIdMapper();
            var guid   = mapper.Create(mapper);

            var result = mapper.Release(mapper);

            Assert.Equal(guid, result);
        }
Exemplo n.º 4
0
        public void CreateTwo_ReleaseOne()
        {
            var mapper = new ThreadBatchIdMapper();

            mapper.Create(mapper);
            mapper.Create(this);

            mapper.Release(mapper);

            Assert.True(mapper.IsActive);
        }
        public void UowDispatcher_UowNotReleased()
        {
            var uowAdapter = new FakeUowAdapter();
            var storage    = Substitute.For <IDomainEventStorage>();
            var context    = Substitute.For <IDownstreamContext>();
            var msg        = new DispatchEvent(new FakeEvent());
            var uowMapper  = new ThreadBatchIdMapper();

            var handler = new TransactionalHandler(uowAdapter, storage, uowMapper);

            uowAdapter.Observer.Create(uowAdapter);
            handler.HandleDownstream(context, msg);


            storage.Received().Hold(uowMapper.GetBatchId(), msg.DomainEvent);
        }
        public void UowDispatcher_UowReleasedFailed()
        {
            var uowAdapter = new FakeUowAdapter();
            var storage    = Substitute.For <IDomainEventStorage>();
            var context    = Substitute.For <IDownstreamContext>();
            var msg        = new DispatchEvent(new FakeEvent());
            var uowMapper  = new ThreadBatchIdMapper();
            var handler    = new TransactionalHandler(uowAdapter, storage, uowMapper);

            uowAdapter.Observer.Create(uowAdapter);
            var batchId = uowMapper.GetBatchId();

            storage.Release(batchId).Returns(new[] { new FakeEvent() });

            handler.HandleDownstream(context, msg);
            context.DidNotReceive().SendDownstream(msg);
            uowAdapter.Observer.Released(uowAdapter, false);


            storage.Received().Hold(batchId, msg.DomainEvent);
            storage.Received().Delete(batchId);
            context.DidNotReceive().SendDownstream(Arg.Any <DispatchEvent>());
        }
Exemplo n.º 7
0
        public void IsNotActive()
        {
            var mapper = new ThreadBatchIdMapper();

            Assert.False(mapper.IsActive);
        }
Exemplo n.º 8
0
        public void Create()
        {
            var mapper = new ThreadBatchIdMapper();

            mapper.Create(mapper);
        }
Exemplo n.º 9
0
        public void CreateNull()
        {
            var mapper = new ThreadBatchIdMapper();

            Assert.Throws <ArgumentNullException>(() => mapper.Create(null));
        }