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 GetLastSerilogWebErrorReturnsNullWhenThereIsNoError() { var app = new FakeHttpApplication(); var context = app.Context; var returned = context.GetLastSerilogWebError(); Assert.Null(returned); }
public ClassicRequestEventHandlerTests() { ApplicationLifecycleModule.ResetConfiguration(); App = new FakeHttpApplication(); Events = new List <LogEvent>(); LevelSwitch = new LoggingLevelSwitch(LogEventLevel.Verbose); Log.Logger = new LoggerConfiguration() .MinimumLevel.ControlledBy(LevelSwitch) .WriteTo.Sink(new DelegatingSink(ev => Events.Add(ev))) .CreateLogger(); }
public void AddSerilogWebErrorCanBeRetrievedOnHttpContextBase() { var app = new FakeHttpApplication(); var context = app.Context; var original = new Exception("It failed"); context.AddSerilogWebError(original); var returned = context.GetLastSerilogWebError(); Assert.Same(original, returned); }
public void GetLastSerilogWebErrorReturnsLastAddedError() { var app = new FakeHttpApplication(); var context = app.Context; var first = new Exception("It failed once"); context.AddSerilogWebError(first); var second = new Exception("It failed twice"); context.AddSerilogWebError(second); var returned = context.GetLastSerilogWebError(); Assert.Same(second, returned); }