Beispiel #1
0
        public void exception_is_thrown()
        {
            RebusUnitOfWork.Initialize(unitOfWorkFactory: null);
            var fakeMessageContext = new FakeMessageContext();

            var ex = Should.Throw <InvalidOperationException>(() => RebusUnitOfWork.Create(fakeMessageContext));

            ex.Message.ShouldBe("RebusUnitOfWork has not been initialized! Please call RebusUnitOfWork.Initialize(...) before using it.");
        }
Beispiel #2
0
        public void Context()
        {
            var domainEventHandlerFactory = new FakeDomainEventHandlerFactory(domainEvent => _raisedDomainEvent = (TestDomainEvent)domainEvent);

            DomainEvents.Initialize(domainEventHandlerFactory);
            DomainEvents.ResetDelayedEventsStorage();

            var unitOfWorkFactory = IoC.Resolve <IUnitOfWorkFactory>();

            RebusUnitOfWork.Initialize(
                unitOfWorkFactory: unitOfWorkFactory,
                isolationLevel: IsolationLevel.ReadCommitted
                );
            _fakeMessageContext = new FakeMessageContext();
            _unitOfWork         = RebusUnitOfWork.Create(_fakeMessageContext);

            _simulateApplicationTransaction();

            RebusUnitOfWork.Commit(_fakeMessageContext, _unitOfWork);
            RebusUnitOfWork.Cleanup(_fakeMessageContext, _unitOfWork);
        }