public async Task SetUp() { HttpConfiguration configuration = new(); Container = new WindsorContainer(); InMemoryContext inMemoryContext = new(); Databases = new(inMemoryContext, inMemoryContext); CurrentTenant = new("TEST", "favicon", "touchicon", "touchiconsize", "title", 51538, "Hofvet"); _ = Container .AddFacility <LoggingFacility>(x => x.LogUsing <TestLoggerFactory>()) .Register(Component.For <Tenant>().Instance(CurrentTenant)) .Register(Component.For <IEmailService>().Instance(Mock.Of <IEmailService>())) .Install( new ControllerInstaller(), new ApiControllerInstaller(), new ControllerFactoryInstaller(), new RavenInstaller(new[] { CurrentTenant }, DocumentStoreMode.InMemory), new TaskHandlerInstaller(), new CompositionRootInstaller(), CommandHandlerInstaller.Scoped(), new DatabaseContextInstaller(() => Databases, LifestyleType.Scoped), EventStoreInstaller.FromAssembly(new[] { CurrentTenant }, typeof(MvcApplication).Assembly, DocumentStoreMode.InMemory), new EventStoreSessionInstaller(LifestyleType.Scoped), new MsmqInstaller(string.Empty)); HttpRequestBase requestMock = Mock.Of <HttpRequestBase>(x => x.ServerVariables == new NameValueCollection() { { "SERVER_NAME", "TEST" } }); HttpContextBase httpContextMock = Mock.Of <HttpContextBase>(x => x.Request == requestMock && x.Items == new Dictionary <object, object>() && x.Cache == new Cache()); _ = inMemoryContext.Tenants.Add(CurrentTenant); CurrentHttpContext.Instance = () => httpContextMock; await OnSetUp(Container); MvcApplication.Bootstrap(Container, configuration, () => new(inMemoryContext, inMemoryContext)); Client = new HttpClient(new HttpServer(configuration)); OnlyLocalAllowedAttribute.SkipValidation = true; LoggingExceptionLogger.ExceptionHandler += ExceptionHandler; await Act(); }