public void data_are_correctly_retrieved_from_http_context_from_multiple_storage_instances() { var fakeHttpContext = FakeHttpContextHelper.GetFakeHttpContext(); HttpContext.Current = fakeHttpContext; var ambientStorageOne = new AmbientStorage <int> { Value = 23 }; var ambientStorageTwo = new AmbientStorage <int> { Value = 24 }; var threadAmbientStorageOneValue = 0; var threadAmbientStorageTwoValue = 0; var thread = new Thread(() => { HttpContext.Current = fakeHttpContext; threadAmbientStorageOneValue = ambientStorageOne.Value; threadAmbientStorageTwoValue = ambientStorageTwo.Value; }); thread.Start(); thread.Join(); threadAmbientStorageOneValue.ShouldBe(23); threadAmbientStorageTwoValue.ShouldBe(24); }
public void Context() { HttpContext.Current = FakeHttpContextHelper.GetFakeHttpContext(); var domainEventHandlerFactory = new FakeDomainEventHandlerFactory(domainEvent => _raisedDomainEvent = (TestDomainEvent)domainEvent); DomainEvents.Initialize(domainEventHandlerFactory, isDelayedDomainEventHandlingEnabled: true); DomainEvents.ResetDelayedEventsStorage(); var unitOfWorkFactory = IoC.Resolve <IUnitOfWorkFactory>(); UnitOfWorkHttpModule.Initialize(unitOfWorkFactory); var unitOfWorkHttpModule = new UnitOfWorkHttpModule(); var httpApplication = new FakeHttpApplication(); unitOfWorkHttpModule.Init(httpApplication); httpApplication.FireBeginRequest(); try { _simulateApplicationTransactionWhichThrowsAnException(); } catch { httpApplication.FireError(); } }
public void Context() { HttpContext.Current = FakeHttpContextHelper.GetFakeHttpContext(); var domainEventHandlerFactory = new FakeDomainEventHandlerFactory(domainEvent => _raisedDomainEvent = (TestDomainEvent)domainEvent); DomainEvents.Initialize(domainEventHandlerFactory); _volatileResourceManager = new VolatileResourceManager(); var unitOfWorkFactory = IoC.Resolve <IUnitOfWorkFactory>(); TransactionScopeUnitOfWorkHttpModule.Initialize( unitOfWorkFactory: unitOfWorkFactory, transactionScopeEnlistmentAction: transactionScope => _volatileResourceManager.EnlistIntoTransactionScope(transactionScope) ); var transactionScopeUnitOfWorkHttpModule = new TransactionScopeUnitOfWorkHttpModule(); var httpApplication = new FakeHttpApplication(); transactionScopeUnitOfWorkHttpModule.Init(httpApplication); httpApplication.FireBeginRequest(); _simulateApplicationTransaction(); httpApplication.FireEndRequest(); }
public void data_are_correctly_retrieved_from_http_context() { var fakeHttpContext = FakeHttpContextHelper.GetFakeHttpContext(); HttpContext.Current = fakeHttpContext; var ambientStorage = new AmbientStorage <int> { Value = 23 }; var threadValue = 0; var thread = new Thread(() => { HttpContext.Current = fakeHttpContext; threadValue = ambientStorage.Value; }); thread.Start(); thread.Join(); threadValue.ShouldBe(23); }